Closed cheesegrits closed 2 months ago
Hey! Thanks for the PR and sorry for the delay on reviewing it.
I've made some changes so the code became more cleaner and customizable, please, lmk wyt.
Instead of defining each method again and hard coding the component on the form, users can now use the adjacencyList
method to customize the widget. The usage follows the same way that Filament uses to configure its form
, table
and infolist
.
class MyWidget extends AdjacencyListWidget {
protected function adjacencyList(AdjacencyList $adjacencyList): AdjacencyList {
return $adjacencyList
->label('Foo')
->editable()
->labelKey('nombre')
->childrenKey('hijos');
}
}
Instead of using the isClickable
aproach, users can now customize which action is triggered when clicking on an item, or instead define a url to be opened. This follows the same aproach as Filament's table ->recordAction
and ->recordUrl
methods.
class MyWidget extends AdjacencyListWidget {
protected function adjacencyList(AdjacencyList $adjacencyList): AdjacencyList {
return $adjacencyList
->itemAction('edit') // or view, delete, moveUp, indent etc ...
->itemUrl(
fn (array $item) => YourResource::getUrl('view', ['record' => $item['id']]) // for example
)
}
}
In an effort to align with Filament's theming methodology you will need to use a custom theme to use this plugin. This is the right way of doing it and it solves the problem we're facing earlier.
Fixed item gap when not using rules
Let me know what you think!
Adding a widget, plus a few bug fixes.