Fohn-Group / fohn-ui

PHP framework using Tailwind Css
MIT License
2 stars 2 forks source link

Add table action button #17

Closed ibelar closed 1 year ago

ibelar commented 1 year ago

usage:

$actionDelete = (new Table\Action(['reloadTable' => true]))->setTrigger(Button::factory(['label' => 'Delete', 'color' => 'neutral']));
$actionMsg = new Table\Action\Messages();
$actionMsg->single = 'This action will delete 1 country. Are you sure?';
$actionMsg->multiple = 'This action will delete {#} countries. Are you sure?';

$actionDelete->addConfirmationDialog('Delete countries:', $actionMsg);
$table->addRowsAction($actionDelete)->onTrigger(function ($ids, $dialog) {
    // performs deletes on ids
    return JsStatements::with([JsToast::success('Delete Action! ' . implode(' / ', $ids)), $dialog->jsClose()]);
});

Note: Required Fohn-js version 1.5

Screenshot 2023-09-03 at 10 24 27 AM