Skip to content

Commit

Permalink
gridview
Browse files Browse the repository at this point in the history
  • Loading branch information
cui-liang committed Aug 13, 2017
1 parent 93538bd commit b565dcb
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 128 deletions.
2 changes: 0 additions & 2 deletions backend/assets/AppAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class AppAsset extends AssetBundle
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yiichina\adminlte\AdminlteAsset',
//'yiichina\icheck\ICheckAsset',
//'yiichina\icheck\Select2Asset',
'yiichina\icons\IconAsset',
];
}
19 changes: 0 additions & 19 deletions backend/assets/CheckAsset.php

This file was deleted.

19 changes: 0 additions & 19 deletions backend/assets/SelectAsset.php

This file was deleted.

1 change: 1 addition & 0 deletions backend/controllers/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function actionUpdate($id)
$model = $this->findModel($id);

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('app', 'Operation success.'));
return $this->redirect(['index']);
} else {
return $this->render('update', [
Expand Down
6 changes: 1 addition & 5 deletions backend/views/group/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'parent_id')->dropDownList($model->parentList) ?>

<?= $form->field($model, 'name')->textInput() ?>

<?= $form->field($model, 'description')->textInput() ?>

<?= $form->field($model, 'status')->inline()->radioList($model->statusList) ?>
<?= $form->field($model, 'node_ids')->textInput() ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
Expand Down
16 changes: 8 additions & 8 deletions backend/views/group/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/* @var $searchModel common\models\NodeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$mainTitle = '栏目管理';
$subTitle = '栏目列表';
$mainTitle = '编辑组管理';
$subTitle = '编辑组列表';
$this->title = $subTitle . ' - ' . $mainTitle . ' - ' . Yii::$app->name;
$breadcrumbs[] = ['label' => $mainTitle, 'url' => ['index']];
$breadcrumbs[] = $subTitle;
Expand All @@ -33,7 +33,7 @@
['label' => '禁用', 'url' => ['disable']],
['label' => '启用', 'url' => ['enable']],
],
'button' => Html::a(Icon::show('plus', 'fa') . '新建栏目', ['create'], ['class' => 'btn btn-sm btn-flat btn-success']),
'button' => Html::a(Icon::show('plus', 'fa') . '新建编辑组', ['create'], ['class' => 'btn btn-sm btn-flat btn-success']),
'columns' => [
[
'class' => 'yii\grid\CheckboxColumn',
Expand All @@ -44,16 +44,16 @@
'options' => ['width' => 60],
],
[
'attribute' => 'parent_id',
'attribute' => 'name',
'options' => ['width' => 60],
],
'name',
'description',
'status',
[
'attribute' => 'nodes',
],
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'options' => ['width' => 65],
'options' => ['width' => 70],
],
],
]); ?>
Expand Down
8 changes: 6 additions & 2 deletions backend/views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
use yiichina\adminlte\Nav;
use yiichina\adminlte\MainHeader;
use yiichina\adminlte\SideBar;
use yiichina\adminlte\Alert;
use yiichina\icons\Icon;
use yii\widgets\Breadcrumbs;
use yii\widgets\Menu;
use yii\widgets\Spaceless;
use common\models\Node;

AppAsset::register($this);
Expand All @@ -28,7 +30,7 @@
</head>
<body class="hold-transition skin-blue sidebar-mini">
<?php $this->beginBody() ?>

<?php Spaceless::begin(); ?>
<div class="wrapper">
<?php
MainHeader::begin([
Expand Down Expand Up @@ -245,7 +247,8 @@
]) ?>
</section>
<section class="content">
<?php echo $content;?>
<?= Alert::widget() ?>
<?= $content ?>
</section>
</div>

Expand Down Expand Up @@ -446,6 +449,7 @@
<div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<?php Spaceless::end(); ?>
<?php $this->endBody() ?>
</body>
</html>
Expand Down
7 changes: 4 additions & 3 deletions backend/views/node/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yiichina\icheck\ICheck;

/* @var $this yii\web\View */
/* @var $model common\models\Node */
Expand All @@ -18,12 +19,12 @@

<?= $form->field($model, 'description')->textInput() ?>

<?= $form->field($model, 'type')->inline()->radioList($model->typeList) ?>
<?= $form->field($model, 'type')->inline()->widget(ICheck::className(), ['type' => ICheck::TYPE_RADIO_LIST, 'items' => $model->typeList]) ?>

<?= $form->field($model, 'status')->inline()->radioList($model->statusList) ?>
<?= $form->field($model, 'status')->inline()->widget(ICheck::className(), ['type' => ICheck::TYPE_RADIO_LIST, 'items' => $model->statusList]) ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
</div>

<?php ActiveForm::end(); ?>
Expand Down
4 changes: 2 additions & 2 deletions backend/views/node/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use common\models\Node;
use yiichina\icheck\ICheck;

/* @var $this yii\web\View */
/* @var $model common\models\NodeSearch */
Expand All @@ -15,7 +15,7 @@
'action' => ['index'],
'method' => 'get',
]); ?>

<?= ICheck::widget(['type' => ICheck::TYPE_RADIO_LIST, 'color' => ICheck::COLOR_GREEN, 'model' => $model, 'attribute' => 'status', 'items' => ['a' => 'b']]) ?>
<div class="row">
<div class="col-xs-3">
<?= $form->field($model, 'parent_id', ['template' => '{input}', 'inputOptions' => ['class' => 'form-control input-sm']])->dropDownList($model->parentList, ['prompt' => '请选择父栏目']) ?>
Expand Down
2 changes: 1 addition & 1 deletion backend/views/node/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'options' => ['width' => 65],
'options' => ['width' => 80],
],
],
]); ?>
Expand Down
2 changes: 1 addition & 1 deletion backend/views/post/_article.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<?= $form->field($post, 'status')->textInput() ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
</div>

<?php ActiveForm::end(); ?>
Expand Down
8 changes: 3 additions & 5 deletions backend/views/sensitive/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'parent_id')->dropDownList($model->parentList) ?>
<?= $form->field($model, 'node_id')->dropDownList($model->nodeList) ?>

<?= $form->field($model, 'name')->textInput() ?>

<?= $form->field($model, 'description')->textInput() ?>
<?= $form->field($model, 'words')->textInput() ?>

<?= $form->field($model, 'status')->inline()->radioList($model->statusList) ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success btn-flat' : 'btn btn-primary btn-flat']) ?>
</div>

<?php ActiveForm::end(); ?>
Expand Down
14 changes: 8 additions & 6 deletions backend/views/sensitive/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@
'options' => ['width' => 60],
],
[
'attribute' => 'parent_id',
'options' => ['width' => 60],
'attribute' => 'node_id',
'options' => ['width' => 100],
],
'words',
[
'attribute' => 'status',
'options' => ['width' => 100],
],
'name',
'description',
'status',
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'options' => ['width' => 65],
'options' => ['width' => 70],
],
],
]); ?>
Expand Down
4 changes: 3 additions & 1 deletion backend/views/site/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\widgets\Spaceless;
use backend\assets\AppAsset;

$this->title = 'Login';
Expand All @@ -26,7 +27,7 @@
</head>
<body class="hold-transition login-page">
<?php $this->beginBody() ?>

<?php Spaceless::begin(); ?>
<div class="login-box">
<div class="login-logo"><b>Yii CMS</b> 后台管理系统</div>
<!-- /.login-logo -->
Expand All @@ -51,6 +52,7 @@
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<?php Spaceless::end(); ?>
<?php $this->endBody() ?>
</body>
</html>
Expand Down
19 changes: 17 additions & 2 deletions backend/views/user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@
'options' => ['width' => 150],
'format' => ['date', 'php:Y-m-d H:i:s'],
],
'status',
[
'attribute' => 'roles',
'options' => ['width' => 100],
'value' => function($data) {
return $data->rolesLabel;
},
'format' => 'raw',
],
[
'attribute' => 'status',
'options' => ['width' => 100],
'value' => function($data) {
return $data->statusLabel;
},
'format' => 'raw',
],
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'options' => ['width' => 100],
'options' => ['width' => 70],
],
],
]); ?>
Expand Down
2 changes: 2 additions & 0 deletions backend/web/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.btn-search.active .fa-search-plus:before { content: "\f010"; }
.search { display: none; background: #f4f4f4; margin-bottom: 10px; padding: 10px 10px 0 10px; }
.search .form-group { margin-bottom: 10px; }

.grid-view tr td:last-child a { margin: 0 2px; }
13 changes: 13 additions & 0 deletions backend/widgets/GridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use yii\bootstrap\ButtonDropdown;
use yii\helpers\Html;
use yiichina\icons\Icon;
use yiichina\icheck\ICheckAsset;

use Yii;

Expand All @@ -25,6 +26,18 @@ class GridView extends \yii\grid\GridView
public function init()
{
parent::init();
$view = $this->getView();
$asset = ICheckAsset::register($view);
$view->registerCssFile($asset->baseUrl . '/skins/minimal/blue.css');
$view->registerJs("$('input[type=\"checkbox\"]').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass: 'iradio_minimal-blue',
});
$('input[name=\"selection_all\"]').on('ifToggled', function (event) {
var chkToggle;
$(this).is(':checked') ? chkToggle = \"check\" : chkToggle = \"uncheck\";
$('input[name=\"selection[]\"]').iCheck(chkToggle);
});");
$this->pager['hideOnSinglePage'] = false;
}

Expand Down
17 changes: 17 additions & 0 deletions common/models/Sensitive.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace common\models;

use Yii;
use yii\helpers\ArrayHelper;

/**
* This is the model class for table "sensitive".
Expand All @@ -13,6 +14,9 @@
*/
class Sensitive extends \yii\db\ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -43,4 +47,17 @@ public function attributeLabels()
'words' => Yii::t('app', 'Words'),
];
}

public function getNodeList()
{
return ArrayHelper::map(Node::find()->all(), 'id', 'name');
}

public function getStatusList()
{
return [
self::STATUS_ACTIVE => '正常',
self::STATUS_INACTIVE => '禁用',
];
}
}
Loading

0 comments on commit b565dcb

Please sign in to comment.