robsontenorio / mary

Laravel Blade UI Components for Livewire 3
https://mary-ui.com
Other
990 stars 117 forks source link

Feature request: Setting the Table link option at the headers array #592

Closed flatcapco closed 1 month ago

flatcapco commented 1 month ago

My understanding is at present the only way to handle it is with a custom cell and disabling link off the main table and adding it back in manually on cells?

To help minimise repeated code it'd be really nice to handle if a cell was subject to being wrapped as a link when using the tables link attribute.

ie link being used here:

<x-table :headers="$headers" :rows="$rates" :sort-by="$sortBy"
                 link="/office/clients/{client_id}/seasons/{season_id}/rates/{id}/edit"

could then be excluded from the headers table like so:

            ['key' => 'saturday', 'label' => 'Saturday', 'sortable' => false, 'link' => false],
robsontenorio commented 1 month ago

I don’t get the point. What do you want to achieve ?

flatcapco commented 1 month ago

Sorry for the bad explanation.

My understanding is that the x-table link sets a link on every cell of the table using a href.

I like this feature but would like certain cells to have no links set if defined.

At the moment if I use the cell scope to add a link around some data like..

@scope('cell_example', $rate)
<a href="custom_link">{{ $xxx}}</a>
@endscope

Then what actually happens is the html renders like this

<a href="original row link"></a>
<a href="custom_link">xxx</a>

ie it makes 2 hrefs because the row is trying to set a href and because a href cannot sit inside a href it spits out the desired href underneath and messes with the formatting

robsontenorio commented 1 month ago

Your suggestion is about including a change on headers.

But we are talking about rows here, right ?

I can’t think a smart approach to conditionally determine if a row would have a link or not.

You can try an alternative approach:

Don’t use link for rows, but @row-click event. So you can determine your navigation logic through Livewire.

If you have a better approach let me know.

robsontenorio commented 1 month ago

@flatcapco Does #594 solve your problem?

This PR disable link for specifics columns, not rows.

flatcapco commented 1 month ago

@robsontenorio yep thats all that is needed thank you