Open leesherwood opened 16 hours ago
Should this change (or similar) not make it into the library, and someone stumble's across this, you can do the following to make it work.
->setTrAttributes(fn($row, $rowIndex) => [
'default' => false,
'class' => implode(' ', [
'dark:text-white',
($rowIndex % 2 === 0 ? 'bg-white dark:bg-gray-700' : 'bg-gray-50 dark:bg-gray-800'),
($row->status !== 'approved' ? 'cursor-not-allowed italic text-gray-400': 'cursor-pointer')])
]
)
Just means pulling the default style classes into your own code and disabling them from auto-applying.
Not as elegant but it works.
Leave this one with me, what you're saying makes sense, but I need to validate any other impact.
Given the propensity for people to publish the package views, it may be that a new method needs to be added to support this, while maintaining the current behaviour on the existing method.
Overview
Allow setting whether a table row has a clickable URL on a per-row basis
Detailed explanation
I have a table that lists a Document model which has a status of
pending
oraccepted
. Onlyaccepted
documents have a public URL you can click through too.So I added this:
This works, albeit with a some unneccessary markup in the HTML
but I also want to change the cursor, I don't want it to change to a pointer for
null
URLs. Ideally i'd have anot allowed
cursor. I tried this:but this outputs the following class list:
Because:
https://github.com/rappasoft/laravel-livewire-tables/blob/a28d2d8d75d81d478bdf01e5d406c948250310c6/resources/views/components/table/tr.blade.php#L27
https://github.com/rappasoft/laravel-livewire-tables/blob/a28d2d8d75d81d478bdf01e5d406c948250310c6/src/Traits/Helpers/TableAttributeHelpers.php#L108-L116
Notes
I propose that:
Is changed too: