2017 © Pedro Peláez
 

library list-delete

List delete behavior for OctoberCMS.

image

owl/list-delete

List delete behavior for OctoberCMS.

  • Sunday, July 12, 2015
  • by scottbedard
  • Repository
  • 3 Watchers
  • 14 Stars
  • 13,098 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 1 Versions
  • 10 % Grown

The README.md

List Delete Behavior

List delete behavior for OctoberCMS., (*1)

Packagist, (*2)

Installation

To install the List Delete behavior, add the following to your plugin's composer.json file., (*3)

"require": {
    "owl/list-delete": "~1.0@dev"
}

Next, implement the behavior in your controllers..., (*4)

public $implement = [
    'Backend.Behaviors.FormController',
    'Backend.Behaviors.ListController',
    'Owl.Behaviors.ListDelete.Behavior',    // <-- add this line
];

Then enable checkboxes in your config_list.yaml file..., (*5)

showCheckboxes: true    # <-- uncomment this line

And lastly, add a button to your _list_toolbar.htm file..., (*6)

<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., (*7)

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., (*8)

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., (*9)

public function overrideListRefresh()
{
    // do stuff here
}

The Versions

12/07 2015

dev-master

9999999-dev http://github.com/october-widgets

List delete behavior for OctoberCMS.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Scott Bedard

owl octobercms