Skip to content

Commit

Permalink
Merge pull request #12 from yii2mod/create_route_asset_bundle
Browse files Browse the repository at this point in the history
create route asset bundle
  • Loading branch information
Igor Chepurnoy authored Dec 27, 2016
2 parents a35cc08 + a143945 commit e7547fa
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
18 changes: 0 additions & 18 deletions RbacAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,4 @@ class RbacAsset extends AssetBundle
public $depends = [
'yii\web\YiiAsset',
];

/**
* @var bool whether RbacAsset will be register only `rbac-route.js` without `js/rbac.js`
*/
public $registerOnlyRouteScript = false;

/**
* @inheritdoc
*/
public function init()
{
if ($this->registerOnlyRouteScript) {
$this->js = [
'js/rbac-route.js',
];
}
parent::init();
}
}
5 changes: 4 additions & 1 deletion views/assignment/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use yii\helpers\Html;
use yii\helpers\Json;
use yii2mod\rbac\RbacAsset;

RbacAsset::register($this);

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

</div>
</div>
9 changes: 3 additions & 6 deletions views/item/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/*
* @var $this yii\web\View
* @var $model yii2mod\rbac\models\AuthItemModel
*/
/* @var $this yii\web\View */
/* @var $model yii2mod\rbac\models\AuthItemModel */
?>

<div class="auth-item-form">

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

<?php ActiveForm::end(); ?>
</div>
</div>
5 changes: 4 additions & 1 deletion views/item/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\DetailView;
use yii2mod\rbac\RbacAsset;

RbacAsset::register($this);

/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\AuthItemModel */
Expand Down Expand Up @@ -44,4 +47,4 @@
'assignUrl' => ['assign', 'id' => $model->name],
'removeUrl' => ['remove', 'id' => $model->name],
]); ?>
</div>
</div>
5 changes: 0 additions & 5 deletions views/layouts/_sidebar.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<?php

use yii2mod\rbac\RbacAsset;

/* @var $this \yii\web\View */

Yii::$container->set(RbacAsset::className(), ['registerOnlyRouteScript' => isset($registerOnlyRouteScript) ? true : false]);
RbacAsset::register($this);

$this->params['sidebar'] = [
[
'label' => Yii::t('yii2mod.rbac', 'Assignments'),
Expand Down
13 changes: 7 additions & 6 deletions views/route/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

use yii\helpers\Html;
use yii\helpers\Json;
use yii2mod\rbac\RbacRouteAsset;

RbacRouteAsset::register($this);

/* @var $this yii\web\View */
/* @var $routes [] */
/* @var $routes array */

$this->title = Yii::t('yii2mod.rbac', 'Routes');
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar', [
'registerOnlyRouteScript' => true,
]);
$this->render('/layouts/_sidebar');
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Refresh'), ['refresh'], [
'class' => 'btn btn-primary',
'id' => 'btn-refresh',
Expand All @@ -23,4 +24,4 @@
]),
'assignUrl' => ['assign'],
'removeUrl' => ['remove'],
]); ?>
]); ?>
10 changes: 7 additions & 3 deletions views/rule/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
<?php echo $form->field($model, 'className')->textInput(); ?>

<div class="form-group">
<?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'), [
'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary', ]); ?>
<?php echo Html::submitButton(
$model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'),
[
'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary',
]
); ?>
</div>

<?php ActiveForm::end(); ?>
</div>
</div>
8 changes: 3 additions & 5 deletions views/rule/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
use yii\helpers\Html;
use yii\widgets\DetailView;

/*
* @var yii\web\View $this
* @var \yii2mod\rbac\models\BizRuleModel $model
*/
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */

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

</div>
</div>

0 comments on commit e7547fa

Please sign in to comment.