Skip to content

Commit

Permalink
Merge composer/master
Browse files Browse the repository at this point in the history
Conflicts:
	views/item/_form.php
  • Loading branch information
mdmunir committed Apr 14, 2016
2 parents c626319 + 947fd17 commit b2167b7
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 67 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
# phpstorm project files
.idea

# netbeans project files
nbproject
/nbproject/private/

# zend studio for eclipse project files
.buildpath
.project
.settings

# windows thumbnail cache
Thumbs.db

# composer vendor dir
/vendor

# composer itself is not needed
composer.phar

# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml
14 changes: 12 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class Module extends \yii\base\Module
*/
private $_normalizeMenus;

/**
* @var string Default url for breadcrumb
*/
public $defaultUrl;

/**
* @var string Default url label for breadcrumb
*/
public $defaultUrlLabel;

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -166,8 +176,8 @@ public function beforeAction($action)
$view = $action->controller->getView();

$view->params['breadcrumbs'][] = [
'label' => Yii::t('rbac-admin', 'Admin'),
'url' => ['/' . $this->uniqueId]
'label' => ($this->defaultUrlLabel ?: Yii::t('rbac-admin', 'Admin')),
'url' => ['/' . ($this->defaultUrl ?: $this->uniqueId)]
];
return true;
}
Expand Down
11 changes: 6 additions & 5 deletions components/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function actionIndex()
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}

Expand Down Expand Up @@ -125,13 +125,13 @@ public function actionAssign($id)
$model = $this->findModel($id);
$success = $model->addChildren($items);
Yii::$app->getResponse()->format = 'json';

return array_merge($model->getItems(), ['success' => $success]);
}

/**
* Assign or remove items
* @param string $id
* @param string $action
* @return array
*/
public function actionRemove($id)
Expand All @@ -140,6 +140,7 @@ public function actionRemove($id)
$model = $this->findModel($id);
$success = $model->removeChildren($items);
Yii::$app->getResponse()->format = 'json';

return array_merge($model->getItems(), ['success' => $success]);
}

Expand All @@ -153,7 +154,7 @@ public function getViewPath()

/**
* Label use in view
* @return array
* @throws NotSupportedException
*/
public function labels()
{
Expand All @@ -174,7 +175,7 @@ public function getType()
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $id
* @return AuthItem the loaded model
* @throws HttpException if the model cannot be found
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
Expand Down
12 changes: 9 additions & 3 deletions messages/ru/rbac-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'Type' => 'Тип',
'Description' => 'Описание',
'Rule Name' => 'Имя правила',
'Data' => 'Дата',
'Data' => 'Данные',
'Update Role' => 'Обновить роль',
'Delete' => 'Удалить',
'Are you sure to delete this item?' => 'Вы действительно хотите удалить этот элемент?',
Expand All @@ -52,12 +52,11 @@
'Create Rule' => 'Создать правило',
'Rules' => 'Правила',
'Update Rule' => 'Обновить правило',
'Create Menu' => 'Обновить меню',
'Create Menu' => 'Создать меню',
'Menus' => 'Меню',
'Search' => 'Поиск',
'Reset' => 'Сбросить',
'Update Menu' => 'Обновить меню',
'Menus' => 'Меню', // m.b. dubplicate
'Order' => 'Порядок',
'Class Name' => 'Имя класса',
'Assignment' => 'Назначение',
Expand All @@ -66,4 +65,11 @@
'Menu' => 'Меню',
'Help' => 'Помощь',
'Application' => 'Приложение',
'Search for avaliable' => 'Поиск по доступным',
'Search for assigned' => 'Поиск по присвоенным',
'New route(s)' => 'Новый маршрут',
'Add' => 'Добавить',
'Assign' => 'Назначить',
'Remove' => 'Удалить',
' --select rule' => ' --выберите правило'
];
3 changes: 1 addition & 2 deletions models/AuthItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public function removeChildren($items)
}

/**
*
* @param string $id
* Get items
* @return array
*/
public function getItems()
Expand Down
18 changes: 10 additions & 8 deletions views/assignment/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
</div>
<div class="col-sm-1">
<br><br>
<?=
Html::a('&gt;&gt;' . $animateIcon, ['assign', 'id' => (string)$model->id], [
'class' => 'btn btn-success btn-assign', 'data-target' => 'avaliable'])
?><br>
<?=
Html::a('&lt;&lt;' . $animateIcon, ['revoke', 'id' => (string)$model->id], [
'class' => 'btn btn-danger btn-assign', 'data-target' => 'assigned'])
?>
<?= Html::a('&gt;&gt;' . $animateIcon, ['assign', 'id' => (string)$model->id], [
'class' => 'btn btn-success btn-assign',
'data-target' => 'avaliable',
'title' => Yii::t('rbac-admin', 'Assign')
]) ?><br><br>
<?= Html::a('&lt;&lt;' . $animateIcon, ['revoke', 'id' => (string)$model->id], [
'class' => 'btn btn-danger btn-assign',
'data-target' => 'assigned',
'title' => Yii::t('rbac-admin', 'Remove')
]) ?>
</div>
<div class="col-sm-5">
<input class="form-control search" data-target="assigned"
Expand Down
3 changes: 2 additions & 1 deletion views/item/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/* @var $form yii\widgets\ActiveForm */
/* @var $context mdm\admin\components\ItemController */

$labels = $this->context->labels();
$context = $this->context;
$labels = $context->labels();
$rules = Yii::$app->getAuthManager()->getRules();
unset($rules[RouteRule::RULE_NAME]);
$source = Json::htmlEncode(array_keys($rules));
Expand Down
3 changes: 2 additions & 1 deletion views/item/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/* @var $model mdm\admin\models\AuthItem */
/* @var $context mdm\admin\components\ItemController */

$labels = $this->context->labels();
$context = $this->context;
$labels = $context->labels();
$this->title = Yii::t('rbac-admin', 'Create ' . $labels['Item']);
$this->params['breadcrumbs'][] = ['label' => Yii::t('rbac-admin', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Expand Down
5 changes: 3 additions & 2 deletions views/item/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $searchModel mdm\admin\models\AuthItemSearch */
/* @var $searchModel mdm\admin\models\searchs\AuthItem */
/* @var $context mdm\admin\components\ItemController */

$labels = $this->context->labels();
$context = $this->context;
$labels = $context->labels();
$this->title = Yii::t('rbac-admin', $labels['Items']);
$this->params['breadcrumbs'][] = $this->title;

Expand Down
3 changes: 2 additions & 1 deletion views/item/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/* @var $model mdm\admin\models\AuthItem */
/* @var $context mdm\admin\components\ItemController */

$labels = $this->context->labels();
$context = $this->context;
$labels = $context->labels();
$this->title = Yii::t('rbac-admin', 'Update ' . $labels['Item']) . ': ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('rbac-admin', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]];
Expand Down
39 changes: 19 additions & 20 deletions views/item/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
/* @var $model mdm\admin\models\AuthItem */
/* @var $context mdm\admin\components\ItemController */

$labels = $this->context->labels();
$context = $this->context;
$labels = $context->labels();
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('rbac-admin', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

AnimateAsset::register($this);
YiiAsset::register($this);
$opts = Json::htmlEncode([
'items' => $model->getItems()
]);
'items' => $model->getItems()
]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
Expand All @@ -28,14 +29,12 @@
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('rbac-admin', 'Update'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']) ?>
<?php
echo Html::a(Yii::t('rbac-admin', 'Delete'), ['delete', 'id' => $model->name], [
<?= Html::a(Yii::t('rbac-admin', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('rbac-admin', 'Are you sure to delete this item?'),
'data-method' => 'post',
]);
?>
<?= Html::a(Yii::t('rbac-admin', 'Create New'), ['create'], ['class' => 'btn btn-success']) ?>
]); ?>
<?= Html::a(Yii::t('rbac-admin', 'Create'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<div class="row">
<div class="col-sm-11">
Expand All @@ -57,25 +56,25 @@
<div class="col-sm-5">
<input class="form-control search" data-target="avaliable"
placeholder="<?= Yii::t('rbac-admin', 'Search for avaliable') ?>">
<select multiple size="20" class="form-control list" data-target="avaliable">
</select>
<select multiple size="20" class="form-control list" data-target="avaliable"></select>
</div>
<div class="col-sm-1">
<br><br>
<?=
Html::a('&gt;&gt;' . $animateIcon, ['assign', 'id' => $model->name], [
'class' => 'btn btn-success btn-assign', 'data-target' => 'avaliable'])
?><br>
<?=
Html::a('&lt;&lt;' . $animateIcon, ['remove', 'id' => $model->name], [
'class' => 'btn btn-danger btn-assign', 'data-target' => 'assigned'])
?>
<?= Html::a('&gt;&gt;' . $animateIcon, ['assign', 'id' => $model->name], [
'class' => 'btn btn-success btn-assign',
'data-target' => 'avaliable',
'title' => Yii::t('rbac-admin', 'Assign')
]) ?><br><br>
<?= Html::a('&lt;&lt;' . $animateIcon, ['remove', 'id' => $model->name], [
'class' => 'btn btn-danger btn-assign',
'data-target' => 'assigned',
'title' => Yii::t('rbac-admin', 'Remove')
]) ?>
</div>
<div class="col-sm-5">
<input class="form-control search" data-target="assigned"
placeholder="<?= Yii::t('rbac-admin', 'Search for assigned') ?>">
<select multiple size="20" class="form-control list" data-target="assigned">
</select>
<select multiple size="20" class="form-control list" data-target="assigned"></select>
</div>
</div>
</div>
46 changes: 24 additions & 22 deletions views/route/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
use yii\web\YiiAsset;

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

$this->title = Yii::t('rbac-admin', 'Routes');
$this->params['breadcrumbs'][] = $this->title;

AnimateAsset::register($this);
YiiAsset::register($this);
$opts = Json::htmlEncode([
'routes' => $routes
]);
'routes' => $routes
]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
Expand All @@ -25,10 +27,10 @@
<input id="inp-route" type="text" class="form-control"
placeholder="<?= Yii::t('rbac-admin', 'New route(s)') ?>">
<span class="input-group-btn">
<?=
Html::a(Yii::t('rbac-admin', 'Add') . $animateIcon, ['create'], ['class' => 'btn btn-success',
'id' => 'btn-new'])
?>
<?= Html::a(Yii::t('rbac-admin', 'Add') . $animateIcon, ['create'], [
'class' => 'btn btn-success',
'id' => 'btn-new'
]) ?>
</span>
</div>
</div>
Expand All @@ -40,30 +42,30 @@
<input class="form-control search" data-target="avaliable"
placeholder="<?= Yii::t('rbac-admin', 'Search for avaliable') ?>">
<span class="input-group-btn">
<?=
Html::a('<span class="glyphicon glyphicon-refresh"></span>', ['refresh'], [
'class' => 'btn btn-default', 'id' => 'btn-refresh'])
?>
<?= Html::a('<span class="glyphicon glyphicon-refresh"></span>', ['refresh'], [
'class' => 'btn btn-default',
'id' => 'btn-refresh'
]) ?>
</span>
</div>
<select multiple size="20" class="form-control list" data-target="avaliable">
</select>
<select multiple size="20" class="form-control list" data-target="avaliable"></select>
</div>
<div class="col-sm-1">
<br><br>
<?=
Html::a('&gt;&gt;' . $animateIcon, ['assign'], [
'class' => 'btn btn-success btn-assign', 'data-target' => 'avaliable'])
?><br>
<?=
Html::a('&lt;&lt;' . $animateIcon, ['remove'], [
'class' => 'btn btn-danger btn-assign', 'data-target' => 'assigned'])
?>
<?= Html::a('&gt;&gt;' . $animateIcon, ['assign'], [
'class' => 'btn btn-success btn-assign',
'data-target' => 'avaliable',
'title' => Yii::t('rbac-admin', 'Assign')
]) ?><br><br>
<?= Html::a('&lt;&lt;' . $animateIcon, ['remove'], [
'class' => 'btn btn-danger btn-assign',
'data-target' => 'assigned',
'title' => Yii::t('rbac-admin', 'Remove')
]) ?>
</div>
<div class="col-sm-5">
<input class="form-control search" data-target="assigned"
placeholder="<?= Yii::t('rbac-admin', 'Search for assigned') ?>">
<select multiple size="20" class="form-control list" data-target="assigned">
</select>
<select multiple size="20" class="form-control list" data-target="assigned"></select>
</div>
</div>

0 comments on commit b2167b7

Please sign in to comment.