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,15 +1,6 @@
<?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\user\models\UserSearch;
use Da\User\Search\UserSearch;
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
@ -26,82 +17,99 @@ $this->title = Yii::t('user', 'Manage users');
$this->params['breadcrumbs'][] = $this->title;
?>
<?= $this->render('/_alert', [
'module' => Yii::$app->getModule('user'),
]) ?>
<?= $this->render(
'/_alert',
[
'module' => Yii::$app->getModule('user'),
]
) ?>
<?= $this->render('/admin/_menu') ?>
<?php Pjax::begin() ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout' => "{items}\n{pager}",
'columns' => [
'username',
'email:email',
[
'attribute' => 'registration_ip',
'value' => function ($model) {
return $model->registration_ip == null
? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
: $model->registration_ip;
},
'format' => 'html',
],
[
'attribute' => 'created_at',
'value' => function ($model) {
if (extension_loaded('intl')) {
return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
} else {
return date('Y-m-d G:i:s', $model->created_at);
}
},
],
[
'header' => Yii::t('user', 'Confirmation'),
'value' => function ($model) {
if ($model->isConfirmed) {
return '<div class="text-center">
<?= GridView::widget(
[
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout' => "{items}\n{pager}",
'columns' => [
'username',
'email:email',
[
'attribute' => 'registration_ip',
'value' => function ($model) {
return $model->registration_ip == null
? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
: $model->registration_ip;
},
'format' => 'html',
],
[
'attribute' => 'created_at',
'value' => function ($model) {
if (extension_loaded('intl')) {
return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
} else {
return date('Y-m-d G:i:s', $model->created_at);
}
},
],
[
'header' => Yii::t('user', 'Confirmation'),
'value' => function ($model) {
if ($model->isConfirmed) {
return '<div class="text-center">
<span class="text-success">' . Yii::t('user', 'Confirmed') . '</span>
</div>';
} else {
return Html::a(Yii::t('user', 'Confirm'), ['confirm', '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 confirm this user?'),
]);
}
},
'format' => 'raw',
'visible' => Yii::$app->getModule('user')->enableConfirmation,
} else {
return Html::a(
Yii::t('user', 'Confirm'),
['confirm', '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 confirm this user?'),
]
);
}
},
'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() ?>