moonshine-software / moonshine

Laravel Admin panel and more. Simple for beginners and powerful for experts. Using Blade, Alpine.js and Tailwind CSS.
https://moonshine-laravel.com
MIT License
714 stars 94 forks source link

feat: TableBuilder sugar #1190

Closed lee-to closed 3 weeks ago

lee-to commented 3 weeks ago

New TableBuilder sugar methods clickAction, pushState, removeAfterClone

TableBuilder::make()
    ->fields([
        Text::make('Title'),
    ])
    ->items([
        ['title' => 'Test']
    ])
    ->buttons([
        ActionButton::make('Go', '#')
            ->class('some-class')
            ->inModal('Title')
    ])
    ->clickAction(ClickAction::EDIT, '.some-class')
    ->pushState()
    ->removeAfterClone()

ClickAction

When you click on a table row, a click occurs on a specific button (via a selector) by default the selector is '.js-(edit|detail)-button'

pushState

If the table is asynchronous, then the called URLs are saved in the browser history

removeAfterClone (system method)

An empty table row will be cloned into memory and deleted.