-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated UltimateTags addon to use powergrid.
- Loading branch information
1 parent
00cb7b1
commit e70bb35
Showing
4 changed files
with
148 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace Addons\UltimateTags\Livewire; | ||
|
||
use Addons\UltimateTags\App\Models\Tag; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use PowerComponents\LivewirePowerGrid\Button; | ||
use PowerComponents\LivewirePowerGrid\Column; | ||
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; | ||
use PowerComponents\LivewirePowerGrid\PowerGridComponent; | ||
use PowerComponents\LivewirePowerGrid\PowerGridFields; | ||
|
||
final class TagsTable extends PowerGridComponent | ||
{ | ||
public string $tableName = 'tags-table'; | ||
|
||
public function setUp(): array | ||
{ | ||
return [ | ||
PowerGrid::header() | ||
->showSearchInput(), | ||
PowerGrid::footer() | ||
->showPerPage() | ||
->showRecordCount(), | ||
]; | ||
} | ||
|
||
public function datasource(): Builder | ||
{ | ||
return Tag::query(); | ||
} | ||
|
||
public function fields(): PowerGridFields | ||
{ | ||
return PowerGrid::fields() | ||
->add('id') | ||
->add('name') | ||
->add('tag_formatted', fn (Tag $model) => $model->tag) | ||
->add('description') | ||
->add('permission') | ||
->add('server'); | ||
} | ||
|
||
public function columns(): array | ||
{ | ||
return [ | ||
Column::make('Id', 'id') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Name', 'name') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Tag', 'tag') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Description', 'description') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Permission', 'permission') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Server', 'server') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::action('Action') | ||
->headerAttribute('text-center'), | ||
]; | ||
} | ||
|
||
public function actions(Tag $row): array | ||
{ | ||
return [ | ||
Button::add('edit') | ||
->attributes(['data-mdb-ripple-init' => '', 'data-mdb-modal-init' => '', 'data-mdb-target' => '#editTagModal']) | ||
->slot('<i class="material-icons text-warning">edit</i>') | ||
->can(auth()->user()->can('edit_tags')) | ||
->id() | ||
->class('bg-transparent border-0') | ||
->dispatch('edit', ['rowId' => $row->id]), | ||
Button::add('delete') | ||
->attributes(['data-mdb-ripple-init' => '', 'data-mdb-modal-init' => '', 'data-mdb-target' => '#deleteTagModal']) | ||
->slot('<i class="material-icons text-danger">delete</i>') | ||
->can(auth()->user()->can('edit_tags')) | ||
->id() | ||
->class('bg-transparent border-0') | ||
->dispatch('delete', ['rowId' => $row->id]), | ||
]; | ||
} | ||
} |
64 changes: 5 additions & 59 deletions
64
addons/UltimateTags/resources/views/livewire/show-tags.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters