added RBAC
This commit is contained in:
41
lib/User/resources/views/role/_form.php
Normal file
41
lib/User/resources/views/role/_form.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var $this yii\web\View
|
||||
* @var $model \Da\User\Model\Role
|
||||
*/
|
||||
use Da\User\Helper\AuthHelper;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
$unassignedItems = Yii::$container->get(AuthHelper::class)->getUnassignedItems($model);
|
||||
?>
|
||||
|
||||
<?php $form = ActiveForm::begin(
|
||||
[
|
||||
'enableClientValidation' => false,
|
||||
'enableAjaxValidation' => true,
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<?= $form->field($model, 'description') ?>
|
||||
|
||||
<?= $form->field($model, 'rule') ?>
|
||||
|
||||
<?= $form->field($model, 'children')->widget(
|
||||
Select2::className(),
|
||||
[
|
||||
'data' => $unassignedItems,
|
||||
'options' => [
|
||||
'id' => 'children',
|
||||
'multiple' => true
|
||||
],
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= Html::submitButton(Yii::t('user', 'Save'), ['class' => 'btn btn-success btn-block']) ?>
|
||||
|
||||
<?php ActiveForm::end() ?>
|
||||
24
lib/User/resources/views/role/create.php
Normal file
24
lib/User/resources/views/role/create.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var $model \Da\User\Model\Role
|
||||
* @var $this yii\web\View
|
||||
* @var $unassignedItems string[]
|
||||
*/
|
||||
|
||||
$this->title = Yii::t('user', 'Create new role');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
?>
|
||||
|
||||
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
|
||||
|
||||
<?= $this->render(
|
||||
'_form',
|
||||
[
|
||||
'model' => $model,
|
||||
'unassignedItems' => $unassignedItems
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?php $this->endContent() ?>
|
||||
61
lib/User/resources/views/role/index.php
Normal file
61
lib/User/resources/views/role/index.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
use yii\grid\ActionColumn;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* @var $dataProvider array
|
||||
* @var $searchModel \Da\User\Search\RoleSearch
|
||||
* @var $this yii\web\View
|
||||
*/
|
||||
|
||||
|
||||
$this->title = Yii::t('user', 'Roles');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
?>
|
||||
|
||||
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
|
||||
|
||||
<?= GridView::widget(
|
||||
[
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'layout' => "{items}\n{pager}",
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' => 'name',
|
||||
'header' => Yii::t('user', 'Name'),
|
||||
'options' => [
|
||||
'style' => 'width: 20%'
|
||||
],
|
||||
],
|
||||
[
|
||||
'attribute' => 'description',
|
||||
'header' => Yii::t('user', 'Description'),
|
||||
'options' => [
|
||||
'style' => 'width: 55%'
|
||||
],
|
||||
],
|
||||
[
|
||||
'attribute' => 'rule_name',
|
||||
'header' => Yii::t('user', 'Rule name'),
|
||||
'options' => [
|
||||
'style' => 'width: 20%'
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => ActionColumn::className(),
|
||||
'template' => '{update} {delete}',
|
||||
'urlCreator' => function ($action, $model) {
|
||||
return Url::to(['/user/role/' . $action, 'name' => $model['name']]);
|
||||
},
|
||||
'options' => [
|
||||
'style' => 'width: 5%'
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?php $this->endContent() ?>
|
||||
24
lib/User/resources/views/role/update.php
Normal file
24
lib/User/resources/views/role/update.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var $model \Da\User\Model\Role
|
||||
* @var $this yii\web\View
|
||||
* @var $unassignedItems string[]
|
||||
*/
|
||||
|
||||
$this->title = Yii::t('user', 'Update role');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
?>
|
||||
|
||||
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
|
||||
|
||||
<?= $this->render(
|
||||
'_form',
|
||||
[
|
||||
'model' => $model,
|
||||
'unassignedItems' => $unassignedItems
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?php $this->endContent() ?>
|
||||
Reference in New Issue
Block a user