You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.4 KiB

7 years ago
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use kartik\select2\Select2;
use kartik\form\ActiveForm;
/* @var $this yii\web\View */
/* @var $model \yii\rbac\Role */
/* @var $roles \yii\rbac\Role[] */
/* @var $permissions \yii\rbac\Permission[] */
/* @var $rolesSelected array */
/* @var $permissionsSelected array */
/* @var $itemsForm \backend\forms\rbac\RbacUpdateChildren */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Roles'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="users-rbac-role-view">
<p>
<?= Html::a(Yii::t('user', 'Roles'), ['index'], ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box box-default">
<div class="box-body">
<?= DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'name',
'label' => Yii::t('user', 'Role Name'),
],
[
'attribute' => 'description',
'label' => Yii::t('user', 'Role Description'),
],
[
'attribute' => 'ruleName',
'label' => Yii::t('user', 'Rule Name'),
],
],
]) ?>
</div>
</div>
<?php if ($model->name !== 'admin'): ?>
<h4><?= Yii::t('user', 'Contains roles') ?></h4>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($itemsForm, 'roles')->widget(
Select2::classname(), [
'name' => 'childrenRoles',
'data' => $roles,
'size' => Select2::SMALL,
'options' => ['placeholder' => Yii::t('user', 'Select role...'), 'multiple' => true],
'pluginOptions' => [
'allowClear' => true
],
])->label(false);
?>
<h4><?= Yii::t('user', 'Permissions') ?></h4>
<?= $form->field($itemsForm, 'permissions')->widget(
Select2::classname(), [
'name' => 'childrenPermissions',
'data' => $permissions,
'size' => Select2::SMALL,
'options' => ['placeholder' => Yii::t('user', 'Select permission...'), 'multiple' => true],
'pluginOptions' => [
'allowClear' => true
],
])->label(false);
?>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php else: ?>
<div class="callout callout-warning">
<?= Yii::t('user', 'Administrator has full access rules') ?>
</div>
<?php endif; ?>
</div>