m-a-k-o / nova-custom-table-card

Simple Nova Card for Custom Tables
MIT License
46 stars 26 forks source link

Call to undefined method Mako\CustomTableCard\Table\Cell::viewLink() #22

Closed gianmarxWebmapp closed 3 years ago

gianmarxWebmapp commented 3 years ago

I would like to insert a button on each line but every time I try to insert a view link after update it gives me an error!

(new \Mako\CustomTableCard\CustomTableCard)
                ->header([
                    new \Mako\CustomTableCard\Table\Cell('Name'),
                    new \Mako\CustomTableCard\Table\Cell('Description'),
                    new \Mako\CustomTableCard\Table\Cell('Created_at'),
                    new \Mako\CustomTableCard\Table\Cell('Updated_at'),
                ])
                ->data($tL->map(function ($order)
                {
                    return new \Mako\CustomTableCard\Table\Row(
                        new \Mako\CustomTableCard\Table\Cell($order['name']),
                        new \Mako\CustomTableCard\Table\Cell($order['description']),
                        new \Mako\CustomTableCard\Table\Cell($order['created_at']),
                       (new \Mako\CustomTableCard\Table\Cell($order['updated_at']))->viewLink('/resources/ecc'));

                })->toArray())
                ->title('Area Layers')
                ->viewall(['label' => 'View All', 'link' => '/nova/resources/track-layers'])

How can I insert a button after update? because if I put for example -> viewLink ('/ resources / orders / 1') it gives me an error:

Error Call to undefined method Mako\CustomTableCard\Table\Cell::viewLink()

m-a-k-o commented 3 years ago

@gianmarxWebmapp You can only use viewLink method on Row

gianmarxWebmapp commented 3 years ago

OK but what if you want to put a label on it?

return (new \Mako\CustomTableCard\Table\Row(
                        new \Mako\CustomTableCard\Table\Cell($order['name']),
                        new \Mako\CustomTableCard\Table\Cell($order['description']),
                        new \Mako\CustomTableCard\Table\Cell($order['created_at']),
                        new \Mako\CustomTableCard\Table\Cell($order['updated_at']),
                    ))->viewall(['label' => 'View All', 'link' => '/nova/resources/track-layers']);

so i see it doesn't work. Thanks

m-a-k-o commented 3 years ago

@gianmarxWebmapp

viewAll method will show button at the bottom of the table to navigate to resources on example. Used on CustomTableCard instance

viewLink will add eye icon to end of every row where viewLink is set. Used on Row instance

gianmarxWebmapp commented 3 years ago

in my case I should put a button with a string like "view", I was wondering if it was possible instead of the icon. How could I do it? thanks

m-a-k-o commented 3 years ago

No, it is not possible right now.

You can do PR to add functionality you need.

gianmarxWebmapp commented 3 years ago

how can i add this functionality ?

m-a-k-o commented 3 years ago

You need to make new branch, make updates, test and make pull request.

Closing.