2017 © Pedro Peláez
 

yii2-extension yii2-actionbar

A control bar with bulk actions for the GridView widget.

image

mickgeek/yii2-actionbar

A control bar with bulk actions for the GridView widget.

  • Saturday, February 17, 2018
  • by mickgeek
  • Repository
  • 3 Watchers
  • 25 Stars
  • 9,625 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 7 Forks
  • 1 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

ActionBar

ActionBar is a Yii 2 widget that render the drop-down list for manipulation selected the GridView items and control buttons. The widget permits you to fully customize elements., (*1)

Screenshot, (*2)

Installation

You can install the widget using Composer. Just run the following command under your application folder:, (*3)

php composer.phar require --prefer-dist mickgeek/yii2-actionbar

Usage

use mickgeek\actionbar\Widget as ActionBar;

= ActionBar::widget([
    'grid' => 'user-grid',
]) ?>

But first, add the action to your controller:, (*4)

public function actions()
{
    return [
        'delete-multiple' => [
            'class' => 'mickgeek\actionbar\DeleteMultipleAction',
            'modelClass' => 'app\models\User',
        ],
    ];
}

Note: You can write your action without using DeleteMultipleAction class., (*5)

Tip: For information about properties and methods of the widget, see the bundled DOCUMENTATION.md., (*6)

Examples

Below are two examples showing some features of the widget., (*7)

Advanced Bulk Actions

Advanced Bulk Actions Screenshot, (*8)

The code in the view:, (*9)

use yii\helpers\Url;
use mickgeek\actionbar\Widget as ActionBar;

= ActionBar::widget([
    'grid' => 'user-grid',
    'templates' => [
        '{bulk-actions}' => ['class' => 'col-xs-4'],
        '{create}' => ['class' => 'col-xs-8 text-right'],
    ],
    'bulkActionsItems' => [
        'Update Status' => [
            'status-active' => 'Active',
            'status-blocked' => 'Blocked',
        ],
        'General' => ['general-delete' => 'Delete'],
    ],
    'bulkActionsOptions' => [
        'options' => [
            'status-active' => [
                'url' => Url::toRoute(['update-status', 'status' => 'active']),
                'disabled' => !Yii::$app->user->can('updateUserStatus'),
            ],
            'status-blocked' => [
                'url' => Url::toRoute(['update-status', 'status' => 'blocked']),
                'disabled' => !Yii::$app->user->can('updateUserStatus'),
            ],
            'general-delete' => [
                'url' => Url::toRoute('delete-multiple'),
                'data-confirm' => 'Are you sure?',
                'disabled' => !Yii::$app->user->can('deleteUser'),
            ],
        ],
        'class' => 'form-control',
    ],
]) ?>

The code in the User controller:, (*10)

public function actions()
{
    return [
        'delete-multiple' => [
            'class' => 'mickgeek\actionbar\DeleteMultipleAction',
            'modelClass' => 'app\models\User',
            'beforeDeleteCallback' => function ($action) {
                if (!Yii::$app->user->can('deleteOwnAccount', Yii::$app->getRequest()->post('ids'))) {
                    Yii::$app->getSession()->setFlash('error', 'You cannot delete your own account.');

                    $action->redirect();
                    Yii::$app->end();
                }
            },
            'afterDeleteCallback' => function ($action) {
                Yii::$app->getSession()->setFlash('success', 'The selected users have been deleted successfully.');
            },
        ],
    ];
}

public function actionUpdateStatus($status)
{
    ...
}

Custom Buttons

Custom Buttons Screenshot, (*11)

The code:, (*12)

use mickgeek\actionbar\Widget as ActionBar;

/* @var $model app\models\User */
= ActionBar::widget([
    'templates' => [
        '{back}' => ['class' => 'col-xs-4'],
        '{update} {delete}' => ['class' => 'col-xs-8 text-right'],
    ],
    'elements' => [
        'back' => Html::a(
            ' ' . 'Back',
            ['/users/index'],
            ['class' => 'btn btn-default']
        ),
        'update' => Html::a(
            ' ' . 'Update',
            ['/users/update', 'id' => $model->id],
            ['class' => 'btn btn-default']
        ),
        'delete' => Html::a(
            ' ' . 'Delete',
            ['/users/delete', 'id' => $model->id],
            ['class' => 'btn btn-default']
        ),
    ],
]) ?>

License

This extension is released under the BSD 3-Clause License. See the bundled LICENSE.md for details., (*13)

The Versions

17/02 2018

dev-master

9999999-dev https://github.com/mickgeek/yii2-actionbar

A control bar with bulk actions for the GridView widget.

  Sources   Download

BSD-3-Clause BSD 3-Clause

The Requires

 

by Oleg Belostotsky

extension yii2 widget grid dropdown bulk actions

10/03 2017

1.1.1

1.1.1.0 https://github.com/mickgeek/yii2-actionbar

Customizable bar with the drop-down list for manipulation selected GridView items and control buttons.

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 widget grid dropdown bulk actions

15/07 2014

1.0.0

1.0.0.0 https://github.com/mickgeek/yii2-actionbar

Customizable bar with the drop-down list for manipulation selected GridView items and control buttons.

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 widget grid dropdown bulk actions