Skip to content

Commit a143945

Browse files
author
igor-chepurnoi
committed
create route asset bundle
1 parent a35cc08 commit a143945

File tree

8 files changed

+28
-45
lines changed

8 files changed

+28
-45
lines changed

RbacAsset.php

-18
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,4 @@ class RbacAsset extends AssetBundle
3333
public $depends = [
3434
'yii\web\YiiAsset',
3535
];
36-
37-
/**
38-
* @var bool whether RbacAsset will be register only `rbac-route.js` without `js/rbac.js`
39-
*/
40-
public $registerOnlyRouteScript = false;
41-
42-
/**
43-
* @inheritdoc
44-
*/
45-
public function init()
46-
{
47-
if ($this->registerOnlyRouteScript) {
48-
$this->js = [
49-
'js/rbac-route.js',
50-
];
51-
}
52-
parent::init();
53-
}
5436
}

views/assignment/view.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
use yii\helpers\Html;
44
use yii\helpers\Json;
5+
use yii2mod\rbac\RbacAsset;
6+
7+
RbacAsset::register($this);
58

69
/* @var $this yii\web\View */
710
/* @var $model \yii2mod\rbac\models\AssignmentModel */
@@ -25,4 +28,4 @@
2528
'removeUrl' => ['remove', 'id' => $model->userId],
2629
]); ?>
2730

28-
</div>
31+
</div>

views/item/_form.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
use yii\helpers\Html;
44
use yii\widgets\ActiveForm;
55

6-
/*
7-
* @var $this yii\web\View
8-
* @var $model yii2mod\rbac\models\AuthItemModel
9-
*/
6+
/* @var $this yii\web\View */
7+
/* @var $model yii2mod\rbac\models\AuthItemModel */
108
?>
11-
129
<div class="auth-item-form">
1310

1411
<?php $form = ActiveForm::begin(); ?>
@@ -34,4 +31,4 @@
3431
</div>
3532

3633
<?php ActiveForm::end(); ?>
37-
</div>
34+
</div>

views/item/view.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use yii\helpers\Html;
44
use yii\helpers\Json;
55
use yii\widgets\DetailView;
6+
use yii2mod\rbac\RbacAsset;
7+
8+
RbacAsset::register($this);
69

710
/* @var $this yii\web\View */
811
/* @var $model \yii2mod\rbac\models\AuthItemModel */
@@ -44,4 +47,4 @@
4447
'assignUrl' => ['assign', 'id' => $model->name],
4548
'removeUrl' => ['remove', 'id' => $model->name],
4649
]); ?>
47-
</div>
50+
</div>

views/layouts/_sidebar.php

-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<?php
22

3-
use yii2mod\rbac\RbacAsset;
4-
53
/* @var $this \yii\web\View */
64

7-
Yii::$container->set(RbacAsset::className(), ['registerOnlyRouteScript' => isset($registerOnlyRouteScript) ? true : false]);
8-
RbacAsset::register($this);
9-
105
$this->params['sidebar'] = [
116
[
127
'label' => Yii::t('yii2mod.rbac', 'Assignments'),

views/route/index.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
use yii\helpers\Html;
44
use yii\helpers\Json;
5+
use yii2mod\rbac\RbacRouteAsset;
6+
7+
RbacRouteAsset::register($this);
58

69
/* @var $this yii\web\View */
7-
/* @var $routes [] */
10+
/* @var $routes array */
811

912
$this->title = Yii::t('yii2mod.rbac', 'Routes');
1013
$this->params['breadcrumbs'][] = $this->title;
11-
$this->render('/layouts/_sidebar', [
12-
'registerOnlyRouteScript' => true,
13-
]);
14+
$this->render('/layouts/_sidebar');
1415
?>
15-
<h1><?php echo Html::encode($this->title); ?></h1>
16+
<h1><?php echo Html::encode($this->title); ?></h1>
1617
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Refresh'), ['refresh'], [
1718
'class' => 'btn btn-primary',
1819
'id' => 'btn-refresh',
@@ -23,4 +24,4 @@
2324
]),
2425
'assignUrl' => ['assign'],
2526
'removeUrl' => ['remove'],
26-
]); ?>
27+
]); ?>

views/rule/_form.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
<?php echo $form->field($model, 'className')->textInput(); ?>
1818

1919
<div class="form-group">
20-
<?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'), [
21-
'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary', ]); ?>
20+
<?php echo Html::submitButton(
21+
$model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'),
22+
[
23+
'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary',
24+
]
25+
); ?>
2226
</div>
2327

2428
<?php ActiveForm::end(); ?>
25-
</div>
29+
</div>

views/rule/view.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
use yii\helpers\Html;
44
use yii\widgets\DetailView;
55

6-
/*
7-
* @var yii\web\View $this
8-
* @var \yii2mod\rbac\models\BizRuleModel $model
9-
*/
6+
/* @var $this yii\web\View */
7+
/* @var $model \yii2mod\rbac\models\BizRuleModel */
108

119
$this->title = Yii::t('yii2mod.rbac', 'Rule : {0}', $model->name);
1210
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Rules'), 'url' => ['index']];
@@ -34,4 +32,4 @@
3432
],
3533
]); ?>
3634

37-
</div>
35+
</div>

0 commit comments

Comments
 (0)