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.

116 lines
3.8 KiB

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