Пример #1
0
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var gromver\platform\backend\modules\menu\models\MenuItemSearch $searchModel
 */
$this->title = Yii::t('gromver.platform', 'Select Menu Item');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

	<?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '50px', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model, $index, $widget) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return $model->getStatusLabel();
}, 'filter' => \gromver\platform\common\models\MenuItem::statusLabels()], ['value' => function ($model) {
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::emitDataJs(['id' => $model->id, 'description' => Yii::t('gromver.platform', 'Menu Item: {title}', ['title' => $model->title]), 'link' => Yii::$app->urlManagerFrontend->createUrl($model->viewLink), 'value' => $model->id . ':' . $model->alias])]);
}, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
Пример #2
0
?>

    <?php 
echo GridView::widget(['id' => 'table-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], ['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '80px', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return \gromver\platform\backend\widgets\Translator::widget(['model' => $model]);
}, 'format' => 'raw', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'menu_type_id', 'width' => '100px', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return $model->menuType->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\MenuType::find()->all(), 'id', 'title')], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path);
}, 'format' => 'html'], 'link', ['attribute' => 'status', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return Html::beginTag('div', ['class' => 'btn-group']) . Html::a('<i class="glyphicon glyphicon-star"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_MAIN_PAGE]), ['class' => 'btn btn-xs' . ($model::STATUS_MAIN_PAGE == $model->status ? ' btn-success active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::a('<i class="glyphicon glyphicon-ok-circle"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_PUBLISHED]), ['class' => 'btn btn-xs' . ($model::STATUS_PUBLISHED == $model->status ? ' btn-primary active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::a('<i class="glyphicon glyphicon-remove-circle"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_UNPUBLISHED]), ['class' => 'btn btn-xs' . ($model::STATUS_UNPUBLISHED == $model->status ? ' btn-default active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::endTag('div');
}, 'filter' => \gromver\platform\common\models\MenuItem::statusLabels(), 'width' => '90px', 'format' => 'raw'], ['attribute' => 'ordering', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return Html::input('text', 'order', $model->ordering, ['class' => 'form-control']);
}, 'format' => 'raw', 'width' => '50px'], ['class' => 'kartik\\grid\\ActionColumn', 'deleteOptions' => ['data-method' => 'delete']]], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . ' </h3>', 'type' => 'info', 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('gromver.platform', 'Add'), ['create', 'menu_type_id' => $searchModel->menu_type_id], ['class' => 'btn btn-success', 'data-pjax' => '0']), 'after' => Html::a('<i class="glyphicon glyphicon-sort-by-attributes"></i> ' . Yii::t('gromver.platform', 'Ordering'), ['ordering'], ['class' => 'btn btn-default', 'data-pjax' => '0', 'onclick' => 'processOrdering(this); return false']) . ' ' . Html::a('<i class="glyphicon glyphicon-trash"></i> ' . Yii::t('gromver.platform', 'Delete'), ['bulk-delete'], ['class' => 'btn btn-danger', 'data-pjax' => '0', 'onclick' => 'processAction(this); return false']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), ['index'], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>

<script>
    function processOrdering(el) {
        var $el = $(el),
            $grid = $('#table-grid'),
            selection = $grid.yiiGridView('getSelectedRows'),
            data = {}
        if(!selection.length) {
            alert(<?php