fix admin views

This commit is contained in:
Antonio Ramirez
2016-12-10 21:42:16 +01:00
parent 0faf61f044
commit 005ab4f1b8
9 changed files with 294 additions and 332 deletions

View File

@ -1,36 +1,28 @@
<?php <?php
/*
* This file is part of the Dektrium project
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
/* /**
* @var yii\web\View $this * @var yii\web\View $this
* @var dektrium\user\models\User $user * @var \Da\User\Model\User $user
*/ */
?> ?>
<?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?>
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin(
'layout' => 'horizontal', [
'enableAjaxValidation' => true, 'layout' => 'horizontal',
'enableClientValidation' => false, 'enableAjaxValidation' => true,
'fieldConfig' => [ 'enableClientValidation' => false,
'horizontalCssClasses' => [ 'fieldConfig' => [
'wrapper' => 'col-sm-9', 'horizontalCssClasses' => [
'wrapper' => 'col-sm-9',
],
], ],
], ]
]); ?> ); ?>
<?= $this->render('_user', ['form' => $form, 'user' => $user]) ?> <?= $this->render('_user', ['form' => $form, 'user' => $user]) ?>

View File

@ -1,31 +1,24 @@
<?php <?php
/*
* This file is part of the Dektrium project
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use dektrium\rbac\widgets\Assignments; use dektrium\rbac\widgets\Assignments;
/** /**
* @var yii\web\View $this * @var yii\web\View $this
* @var dektrium\user\models\User $user * @var \Da\User\Model\User $user
*/ */
?> ?>
<?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?>
<?= yii\bootstrap\Alert::widget([ <?= yii\bootstrap\Alert::widget(
'options' => [ [
'class' => 'alert-info alert-dismissible', 'options' => [
], 'class' => 'alert-info alert-dismissible',
'body' => Yii::t('user', 'You can assign multiple roles or permissions to user by using the form below'), ],
]) ?> 'body' => Yii::t('user', 'You can assign multiple roles or permissions to user by using the form below'),
]
) ?>
<?= Assignments::widget(['userId' => $user->id]) ?> <?= Assignments::widget(['userId' => $user->id]) ?>

View File

@ -1,21 +1,12 @@
<?php <?php
/*
* This file is part of the Dektrium project
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
/** /**
* @var yii\web\View * @var yii\web\View $this
* @var dektrium\user\models\User * @var \Da\User\Model\User $user
*/ */
?> ?>
<?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?>
<table class="table"> <table class="table">
<tr> <tr>
@ -32,10 +23,10 @@
<td><strong><?= Yii::t('user', 'Confirmation status') ?>:</strong></td> <td><strong><?= Yii::t('user', 'Confirmation status') ?>:</strong></td>
<?php if ($user->isConfirmed): ?> <?php if ($user->isConfirmed): ?>
<td class="text-success"><?= Yii::t( <td class="text-success"><?= Yii::t(
'user', 'user',
'Confirmed at {0, date, MMMM dd, YYYY HH:mm}', 'Confirmed at {0, date, MMMM dd, YYYY HH:mm}',
[$user->confirmed_at] [$user->confirmed_at]
) ?></td> ) ?></td>
<?php else: ?> <?php else: ?>
<td class="text-danger"><?= Yii::t('user', 'Unconfirmed') ?></td> <td class="text-danger"><?= Yii::t('user', 'Unconfirmed') ?></td>
<?php endif ?> <?php endif ?>
@ -44,10 +35,10 @@
<td><strong><?= Yii::t('user', 'Block status') ?>:</strong></td> <td><strong><?= Yii::t('user', 'Block status') ?>:</strong></td>
<?php if ($user->isBlocked): ?> <?php if ($user->isBlocked): ?>
<td class="text-danger"><?= Yii::t( <td class="text-danger"><?= Yii::t(
'user', 'user',
'Blocked at {0, date, MMMM dd, YYYY HH:mm}', 'Blocked at {0, date, MMMM dd, YYYY HH:mm}',
[$user->blocked_at] [$user->blocked_at]
) ?> ) ?>
</td> </td>
<?php else: ?> <?php else: ?>
<td class="text-success"><?= Yii::t('user', 'Not blocked') ?></td> <td class="text-success"><?= Yii::t('user', 'Not blocked') ?></td>

View File

@ -1,56 +1,49 @@
<?php <?php
/*
* This file is part of the Dektrium project
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
?> ?>
<?= Nav::widget([ <?= Nav::widget(
'options' => [ [
'class' => 'nav-tabs', 'options' => [
'style' => 'margin-bottom: 15px', 'class' => 'nav-tabs',
], 'style' => 'margin-bottom: 15px',
'items' => [
[
'label' => Yii::t('user', 'Users'),
'url' => ['/user/admin/index'],
], ],
[ 'items' => [
'label' => Yii::t('user', 'Roles'), [
'url' => ['/rbac/role/index'], 'label' => Yii::t('user', 'Users'),
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']), 'url' => ['/user/admin/index'],
], ],
[ [
'label' => Yii::t('user', 'Permissions'), 'label' => Yii::t('user', 'Roles'),
'url' => ['/rbac/permission/index'], 'url' => ['/rbac/role/index'],
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']), 'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
], ],
[ [
'label' => Yii::t('user', 'Create'), 'label' => Yii::t('user', 'Permissions'),
'items' => [ 'url' => ['/rbac/permission/index'],
[ 'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
'label' => Yii::t('user', 'New user'), ],
'url' => ['/user/admin/create'], [
], 'label' => Yii::t('user', 'Create'),
[ 'items' => [
'label' => Yii::t('user', 'New role'), [
'url' => ['/rbac/role/create'], 'label' => Yii::t('user', 'New user'),
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']), 'url' => ['/user/admin/create'],
], ],
[ [
'label' => Yii::t('user', 'New permission'), 'label' => Yii::t('user', 'New role'),
'url' => ['/rbac/permission/create'], 'url' => ['/rbac/role/create'],
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']), 'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
],
[
'label' => Yii::t('user', 'New permission'),
'url' => ['/rbac/permission/create'],
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
],
], ],
], ],
], ],
], ]
]) ?> ) ?>

View File

@ -1,37 +1,30 @@
<?php <?php
/*
* This file is part of the Dektrium project
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\web\View $this * @var yii\web\View $this
* @var dektrium\user\models\User $user * @var \Da\User\Model\User $user
* @var dektrium\user\models\Profile $profile * @var \Da\User\Model\Profile $profile
*/ */
?> ?>
<?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?>
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin(
'layout' => 'horizontal', [
'enableAjaxValidation' => true, 'layout' => 'horizontal',
'enableClientValidation' => false, 'enableAjaxValidation' => true,
'fieldConfig' => [ 'enableClientValidation' => false,
'horizontalCssClasses' => [ 'fieldConfig' => [
'wrapper' => 'col-sm-9', 'horizontalCssClasses' => [
'wrapper' => 'col-sm-9',
],
], ],
], ]
]); ?> ); ?>
<?= $form->field($profile, 'name') ?> <?= $form->field($profile, 'name') ?>
<?= $form->field($profile, 'public_email') ?> <?= $form->field($profile, 'public_email') ?>

View File

@ -1,17 +1,7 @@
<?php <?php
/*
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
/** /**
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var dektrium\user\models\User $user * @var \Da\User\Model\User $user
*/ */
?> ?>

View File

@ -1,21 +1,12 @@
<?php <?php
/*
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\web\View $this * @var yii\web\View $this
* @var dektrium\user\models\User $user * @var \Da\User\Model\User $user
*/ */
$this->title = Yii::t('user', 'Create a user account'); $this->title = Yii::t('user', 'Create a user account');
@ -24,9 +15,12 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?= $this->render('/_alert', [ <?= $this->render(
'module' => Yii::$app->getModule('user'), '/_alert',
]) ?> [
'module' => Yii::$app->getModule('user'),
]
) ?>
<?= $this->render('_menu') ?> <?= $this->render('_menu') ?>
@ -34,22 +28,30 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="col-md-3"> <div class="col-md-3">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<?= Nav::widget([ <?= Nav::widget(
'options' => [ [
'class' => 'nav-pills nav-stacked', 'options' => [
], 'class' => 'nav-pills nav-stacked',
'items' => [ ],
['label' => Yii::t('user', 'Account details'), 'url' => ['/user/admin/create']], 'items' => [
['label' => Yii::t('user', 'Profile details'), 'options' => [ ['label' => Yii::t('user', 'Account details'), 'url' => ['/user/admin/create']],
'class' => 'disabled', [
'onclick' => 'return false;', 'label' => Yii::t('user', 'Profile details'),
]], 'options' => [
['label' => Yii::t('user', 'Information'), 'options' => [ 'class' => 'disabled',
'class' => 'disabled', 'onclick' => 'return false;',
'onclick' => 'return false;', ]
]], ],
], [
]) ?> 'label' => Yii::t('user', 'Information'),
'options' => [
'class' => 'disabled',
'onclick' => 'return false;',
]
],
],
]
) ?>
</div> </div>
</div> </div>
</div> </div>
@ -60,16 +62,18 @@ $this->params['breadcrumbs'][] = $this->title;
<?= Yii::t('user', 'Credentials will be sent to the user by email') ?>. <?= Yii::t('user', 'Credentials will be sent to the user by email') ?>.
<?= Yii::t('user', 'A password will be generated automatically if not provided') ?>. <?= Yii::t('user', 'A password will be generated automatically if not provided') ?>.
</div> </div>
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin(
'layout' => 'horizontal', [
'enableAjaxValidation' => true, 'layout' => 'horizontal',
'enableClientValidation' => false, 'enableAjaxValidation' => true,
'fieldConfig' => [ 'enableClientValidation' => false,
'horizontalCssClasses' => [ 'fieldConfig' => [
'wrapper' => 'col-sm-9', 'horizontalCssClasses' => [
'wrapper' => 'col-sm-9',
],
], ],
], ]
]); ?> ); ?>
<?= $this->render('_user', ['form' => $form, 'user' => $user]) ?> <?= $this->render('_user', ['form' => $form, 'user' => $user]) ?>

View File

@ -1,15 +1,6 @@
<?php <?php
/* use Da\User\Search\UserSearch;
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use dektrium\user\models\UserSearch;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Html; use yii\helpers\Html;
@ -26,82 +17,99 @@ $this->title = Yii::t('user', 'Manage users');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?= $this->render('/_alert', [ <?= $this->render(
'module' => Yii::$app->getModule('user'), '/_alert',
]) ?> [
'module' => Yii::$app->getModule('user'),
]
) ?>
<?= $this->render('/admin/_menu') ?> <?= $this->render('/admin/_menu') ?>
<?php Pjax::begin() ?> <?php Pjax::begin() ?>
<?= GridView::widget([ <?= GridView::widget(
'dataProvider' => $dataProvider, [
'filterModel' => $searchModel, 'dataProvider' => $dataProvider,
'layout' => "{items}\n{pager}", 'filterModel' => $searchModel,
'columns' => [ 'layout' => "{items}\n{pager}",
'username', 'columns' => [
'email:email', 'username',
[ 'email:email',
'attribute' => 'registration_ip', [
'value' => function ($model) { 'attribute' => 'registration_ip',
return $model->registration_ip == null 'value' => function ($model) {
? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>' return $model->registration_ip == null
: $model->registration_ip; ? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
}, : $model->registration_ip;
'format' => 'html', },
], 'format' => 'html',
[ ],
'attribute' => 'created_at', [
'value' => function ($model) { 'attribute' => 'created_at',
if (extension_loaded('intl')) { 'value' => function ($model) {
return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]); if (extension_loaded('intl')) {
} else { return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
return date('Y-m-d G:i:s', $model->created_at); } else {
} return date('Y-m-d G:i:s', $model->created_at);
}, }
], },
[ ],
'header' => Yii::t('user', 'Confirmation'), [
'value' => function ($model) { 'header' => Yii::t('user', 'Confirmation'),
if ($model->isConfirmed) { 'value' => function ($model) {
return '<div class="text-center"> if ($model->isConfirmed) {
return '<div class="text-center">
<span class="text-success">' . Yii::t('user', 'Confirmed') . '</span> <span class="text-success">' . Yii::t('user', 'Confirmed') . '</span>
</div>'; </div>';
} else { } else {
return Html::a(Yii::t('user', 'Confirm'), ['confirm', 'id' => $model->id], [ return Html::a(
'class' => 'btn btn-xs btn-success btn-block', Yii::t('user', 'Confirm'),
'data-method' => 'post', ['confirm', 'id' => $model->id],
'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'), [
]); 'class' => 'btn btn-xs btn-success btn-block',
} 'data-method' => 'post',
}, 'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
'format' => 'raw', ]
'visible' => Yii::$app->getModule('user')->enableConfirmation, );
}
},
'format' => 'raw',
'visible' => Yii::$app->getModule('user')->enableConfirmation,
],
[
'header' => Yii::t('user', 'Block status'),
'value' => function ($model) {
if ($model->isBlocked) {
return Html::a(
Yii::t('user', 'Unblock'),
['block', 'id' => $model->id],
[
'class' => 'btn btn-xs btn-success btn-block',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
]
);
} else {
return Html::a(
Yii::t('user', 'Block'),
['block', 'id' => $model->id],
[
'class' => 'btn btn-xs btn-danger btn-block',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
]
);
}
},
'format' => 'raw',
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
],
], ],
[ ]
'header' => Yii::t('user', 'Block status'), ); ?>
'value' => function ($model) {
if ($model->isBlocked) {
return Html::a(Yii::t('user', 'Unblock'), ['block', 'id' => $model->id], [
'class' => 'btn btn-xs btn-success btn-block',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
]);
} else {
return Html::a(Yii::t('user', 'Block'), ['block', 'id' => $model->id], [
'class' => 'btn btn-xs btn-danger btn-block',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
]);
}
},
'format' => 'raw',
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
],
],
]); ?>
<?php Pjax::end() ?> <?php Pjax::end() ?>

View File

@ -1,22 +1,13 @@
<?php <?php
/* use Da\User\Model\User;
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use dektrium\user\models\User;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\web\View; use yii\web\View;
/** /**
* @var View $this * @var View $this
* @var User $user * @var User $user
* @var string $content * @var string $content
*/ */
$this->title = Yii::t('user', 'Update user account'); $this->title = Yii::t('user', 'Update user account');
@ -25,9 +16,12 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?= $this->render('/_alert', [ <?= $this->render(
'module' => Yii::$app->getModule('user'), '/_alert',
]) ?> [
'module' => Yii::$app->getModule('user'),
]
) ?>
<?= $this->render('_menu') ?> <?= $this->render('_menu') ?>
@ -35,67 +29,71 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="col-md-3"> <div class="col-md-3">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<?= Nav::widget([ <?= Nav::widget(
'options' => [ [
'class' => 'nav-pills nav-stacked', 'options' => [
], 'class' => 'nav-pills nav-stacked',
'items' => [
[
'label' => Yii::t('user', 'Account details'),
'url' => ['/user/admin/update', 'id' => $user->id]
], ],
[ 'items' => [
'label' => Yii::t('user', 'Profile details'), [
'url' => ['/user/admin/update-profile', 'id' => $user->id] 'label' => Yii::t('user', 'Account details'),
], 'url' => ['/user/admin/update', 'id' => $user->id]
['label' => Yii::t('user', 'Information'), 'url' => ['/user/admin/info', 'id' => $user->id]], ],
[ [
'label' => Yii::t('user', 'Assignments'), 'label' => Yii::t('user', 'Profile details'),
'url' => ['/user/admin/assignments', 'id' => $user->id], 'url' => ['/user/admin/update-profile', 'id' => $user->id]
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']), ],
], [
'<hr>', 'label' => Yii::t('user', 'Information'),
[ 'url' => ['/user/admin/info', 'id' => $user->id]
'label' => Yii::t('user', 'Confirm'), ],
'url' => ['/user/admin/confirm', 'id' => $user->id], [
'visible' => !$user->isConfirmed, 'label' => Yii::t('user', 'Assignments'),
'linkOptions' => [ 'url' => ['/user/admin/assignments', 'id' => $user->id],
'class' => 'text-success', ],
'data-method' => 'post', '<hr>',
'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'), [
'label' => Yii::t('user', 'Confirm'),
'url' => ['/user/admin/confirm', 'id' => $user->id],
'visible' => !$user->isConfirmed,
'linkOptions' => [
'class' => 'text-success',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
],
],
[
'label' => Yii::t('user', 'Block'),
'url' => ['/user/admin/block', 'id' => $user->id],
'visible' => !$user->isBlocked,
'linkOptions' => [
'class' => 'text-danger',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
],
],
[
'label' => Yii::t('user', 'Unblock'),
'url' => ['/user/admin/block', 'id' => $user->id],
'visible' => $user->isBlocked,
'linkOptions' => [
'class' => 'text-success',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
],
],
[
'label' => Yii::t('user', 'Delete'),
'url' => ['/user/admin/delete', 'id' => $user->id],
'linkOptions' => [
'class' => 'text-danger',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to delete this user?'),
],
], ],
], ],
[ ]
'label' => Yii::t('user', 'Block'), ) ?>
'url' => ['/user/admin/block', 'id' => $user->id],
'visible' => !$user->isBlocked,
'linkOptions' => [
'class' => 'text-danger',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
],
],
[
'label' => Yii::t('user', 'Unblock'),
'url' => ['/user/admin/block', 'id' => $user->id],
'visible' => $user->isBlocked,
'linkOptions' => [
'class' => 'text-success',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
],
],
[
'label' => Yii::t('user', 'Delete'),
'url' => ['/user/admin/delete', 'id' => $user->id],
'linkOptions' => [
'class' => 'text-danger',
'data-method' => 'post',
'data-confirm' => Yii::t('user', 'Are you sure you want to delete this user?'),
],
],
],
]) ?>
</div> </div>
</div> </div>
</div> </div>