owl / list-delete
List delete behavior for OctoberCMS.
Installs: 22 950
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 4
Forks: 0
Open Issues: 2
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2021-09-27 11:36:35 UTC
README
List delete behavior for OctoberCMS.
Installation
To install the List Delete behavior, add the following to your plugin's composer.json
file.
"require": { "owl/list-delete": "~1.0@dev" }
Next, implement the behavior in your controllers...
public $implement = [ 'Backend.Behaviors.FormController', 'Backend.Behaviors.ListController', 'Owl.Behaviors.ListDelete.Behavior', // <-- add this line ];
Then enable checkboxes in your config_list.yaml
file...
showCheckboxes: true # <-- uncomment this line
And lastly, add a button to your _list_toolbar.htm
file...
<button class="btn btn-default oc-icon-trash-o" disabled="disabled" onclick="$(this).data('request-data', { checked: $('.control-list').listWidget('getChecked') })" data-request="onDelete" data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>" data-trigger-action="enable" data-trigger=".control-list input[type=checkbox]" data-trigger-condition="checked" data-request-success="$(this).prop('disabled', false)" data-stripe-load-indicator> <?= e(trans('backend::lang.list.delete_selected')) ?> </button>
Overriding default actions
If you need to perform additional delete logic, simply add the following method to your controller.
public function overrideListDelete($record) { $record->delete(); // do whatever else you need to do }
To override what should happen after your records are deleted, add the following method to your controller.
public function afterListDelete() { Flash::success('Things were deleted!'); }
By default, the list will be refreshed after a delete has occured. If you'd like to override this behavior, add the following method to your controller.
public function overrideListRefresh() { // do stuff here }