Blame view

common/components/developeruz/db_rbac/views/access/permission.php 2.47 KB
14a09168   Alex Savenko   init commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  <?php

  namespace developeruz\db_rbac\views\access;

  

  use Yii;

  use yii\data\ArrayDataProvider;

  use yii\grid\GridView;

  use yii\grid\DataColumn;

  use yii\helpers\Url;

  use yii\helpers\Html;

  

  $this->title = Yii::t('db_rbac', 'Правила доступа');

  $this->params['breadcrumbs'][] = $this->title;

  ?>

  <div class="news-index">

  

      <h1><?= Html::encode($this->title) ?></h1>

  

      <p>

          <?= Html::a(Yii::t('db_rbac', 'Добавить новое правило'), ['add-permission'], ['class' => 'btn btn-success']) ?>

      </p>

  <?php

  $dataProvider = new ArrayDataProvider([

        'allModels' => Yii::$app->authManager->getPermissions(),

        'sort' => [

            'attributes' => ['name', 'description'],

        ],

        'pagination' => [

            'pageSize' => 10,

        ],

   ]);

  ?>

  

  <?=GridView::widget([

      'dataProvider' => $dataProvider,

      'columns' => [

          ['class' => 'yii\grid\SerialColumn'],

          [

              'class'     => DataColumn::className(),

              'attribute' => 'name',

              'label'     => Yii::t('db_rbac', 'Правило')

          ],

          [

              'class'     => DataColumn::className(),

              'attribute' => 'description',

              'label'     => Yii::t('db_rbac', 'Описание')

          ],

          ['class' => 'yii\grid\ActionColumn',

              'template' => '{update} {delete}',

              'buttons' =>

                  [

                      'update' => function ($url, $model) {

                                  return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Url::toRoute(['update-permission', 'name' => $model->name]), [

                                          'title' => Yii::t('yii', 'Update'),

                                          'data-pjax' => '0',

                                      ]); },

                      'delete' => function ($url, $model) {

                                  return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute(['delete-permission','name' => $model->name]), [

                                          'title' => Yii::t('yii', 'Delete'),

                                          'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),

                                          'data-method' => 'post',

                                          'data-pjax' => '0',

                                      ]);

                          }

                  ]

          ],

          ]

      ]);

  ?>

  </div>