Commit 49d65e08 authored by john's avatar john

3010

parent 330cee17
...@@ -3,4 +3,9 @@ ...@@ -3,4 +3,9 @@
} }
.faq_sec img { .faq_sec img {
max-width: 100%; max-width: 100%;
}
.faq_sec p img ,
.faq_sec li img {
margin-top: 20px;
margin-bottom: 20px
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ class DocumentationListAdminController extends AdminController ...@@ -26,6 +26,7 @@ class DocumentationListAdminController extends AdminController
'View' => 'Просмотр модуля', 'View' => 'Просмотр модуля',
'Delete' => '', 'Delete' => '',
'Createcontroller' => 'Создание контроллера', 'Createcontroller' => 'Создание контроллера',
'Sort' => 'Соктировка списка',
'Deletecontroller' => '', 'Deletecontroller' => '',
'Updatecontroller' => '', 'Updatecontroller' => '',
]; ];
...@@ -65,6 +66,59 @@ class DocumentationListAdminController extends AdminController ...@@ -65,6 +66,59 @@ class DocumentationListAdminController extends AdminController
]); ]);
} }
/**
* Lists all DocList models.
* @return mixed
*/
public function actionSort($id = 0)
{
$items = yii::$app->request->post('items');
if ($items) {
$items = \yii\helpers\Json::decode($items, true);
$newOrder = [];
$models = [];
$transaction = Yii::$app->db->beginTransaction();
try {
$success = true;
$newOrder = [];
$models = [];
foreach ($items as $old => $new) {
$models[$new] = $this->findModel($new);
$newOrder[$old] = $models[$new]->position;
}
foreach ($newOrder as $modelId => $orderValue) {
$models[$modelId]->position = $orderValue;
if (!$models[$modelId]->save()) {
$success = false;
}
}
if ($success) {
$transaction->commit();
} else {
$transaction->rollBack();
}
} catch (\Exception $e) {
$transaction->rollBack();
throw $e;
}
return;
}
$searchModel = new SearchDocList();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, 2000000);
$dataProvider->query->andWhere(['=', 'parent_id', $id]);
\yii::$app->controller->page_title = \yii::t('documentation', 'Соктировка списка');
\yii::$app->controller->breadcrumbs = [
\yii::t('documentation', 'Соктировка списка'),
];
return $this->render('sort', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/** /**
* Displays a single DocList model. * Displays a single DocList model.
* @param integer $id * @param integer $id
...@@ -132,8 +186,10 @@ class DocumentationListAdminController extends AdminController ...@@ -132,8 +186,10 @@ class DocumentationListAdminController extends AdminController
$transaction = Yii::$app->db->beginTransaction(); $transaction = Yii::$app->db->beginTransaction();
try { try {
$model->parent_id = (int) $model->parent_id; $model->parent_id = (int) $model->parent_id;
if ($model->isNewRecord) if ($model->isNewRecord) {
$model->position = DocList::find()->where(['=', 'parent_id', (int) $model->parent_id])->count(); $last = DocList::find()->where(['=', 'parent_id', (int) $model->parent_id])->orderBy(['position' => SORT_DESC])->one();
$model->position = $last ? $last->position + 1 : 0;
}
if ($model->save()) { if ($model->save()) {
$transaction->commit(); $transaction->commit();
return $this->redirect(\yii\helpers\Url::toRoute(['manage'])); return $this->redirect(\yii\helpers\Url::toRoute(['manage']));
......
...@@ -41,7 +41,7 @@ class SearchDocList extends DocList ...@@ -41,7 +41,7 @@ class SearchDocList extends DocList
* *
* @return ActiveDataProvider * @return ActiveDataProvider
*/ */
public function search($params) public function search($params, $pagesize = 20)
{ {
$idList = array_keys($this->getParentList($this, 0, 0, true)); $idList = array_keys($this->getParentList($this, 0, 0, true));
$idListInt = [-1]; $idListInt = [-1];
...@@ -55,6 +55,9 @@ class SearchDocList extends DocList ...@@ -55,6 +55,9 @@ class SearchDocList extends DocList
$query->orderBy([new \yii\db\Expression('FIELD (`doc_list`.`id`, ' . implode(',', $idListInt) . ')')]); $query->orderBy([new \yii\db\Expression('FIELD (`doc_list`.`id`, ' . implode(',', $idListInt) . ')')]);
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
'pagination' => [
'pageSize' => $pagesize,
],
'sort' => [ 'sort' => [
'attributes' => [ 'attributes' => [
'id', 'id',
...@@ -69,10 +72,10 @@ class SearchDocList extends DocList ...@@ -69,10 +72,10 @@ class SearchDocList extends DocList
]); ]);
$this->load($params); $this->load($params);
if (!$this->validate()) { if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails // uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1'); $query->where('0=1');
return $dataProvider; return $dataProvider;
} }
......
...@@ -45,7 +45,9 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all(); ...@@ -45,7 +45,9 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all();
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?= $form->field($model, 'parent_id')->dropDownList($model->getParentList($model), ['class' => 'form-control', 'prompt'=>'Выберите родительский раздел']) ?> <?= (yii::$app->request->get('position')) ? $form->field($model, 'position')->textInput(['class' => 'form-control']) : ''; ?>
<?= $form->field($model, 'parent_id')->dropDownList($model->getParentList($model), ['class' => 'form-control', 'prompt' => 'Выберите родительский раздел']) ?>
<?= <?=
$form->field($model, 'active', [ $form->field($model, 'active', [
'template' => '{input}<a href="#" class="btn btn-xs btn-success m-l-5 disabled">Пункт меню скрыт от пользователя / Пункт меню виднен для пользователю</a>' 'template' => '{input}<a href="#" class="btn btn-xs btn-success m-l-5 disabled">Пункт меню скрыт от пользователя / Пункт меню виднен для пользователю</a>'
......
...@@ -56,6 +56,12 @@ $parentList = $searchModel->getParentList($searchModel, 0, 0, true); ...@@ -56,6 +56,12 @@ $parentList = $searchModel->getParentList($searchModel, 0, 0, true);
/* 'url:url', */ /* 'url:url', */
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{sort} {view} {update} {delete}',
'buttons' => [
'sort' => function($url, $model, $key) {
return Html::a('<i class="fa fa-sort fa-lg"></i>', ['/documentation/documentation-list-admin/sort', 'id' => $model->parent_id], ["title" => "Сортировать", 'data-toggle' => "tooltip", "data-pjax" => "0"]);
},
],
'headerOptions' => [ 'headerOptions' => [
'style' => 'width: 150px;' 'style' => 'width: 150px;'
] ]
......
<?php
use yii\helpers\Html;
use himiklab\sortablegrid\SortableGridView
/* @var $this yii\web\View */
/* @var $searchModel common\modules\documentation\models\SearchCoCategory */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<?=
SortableGridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'header' => '<span class="glyphicon glyphicon-align-justify"></span>',
// 'label' => '<span class="glyphicon glyphicon-align-justify"></span>',
'attribute' => 'id',
'format' => 'raw',
'value' => function() {
return '<i class="fa fa-sort fa-lg"></i>';
}
],
[
'header' => $searchModel->getAttributeLabel('id'),
'attribute' => 'id',
],
[
'header' => $searchModel->getAttributeLabel('position'),
'attribute' => 'position',
],
[
'header' => $searchModel->getAttributeLabel('name'),
'attribute' => 'name',
'format' => 'raw',
'value' => function($model) {
return'<p style="white-space: nowrap;">' . $model->lang->name . '</p>';
}
],
[
'header' => $searchModel->getAttributeLabel('parent_id'),
'attribute' => 'parent_id',
'value' => function($model) {
return $model->parent ? $model->parent->lang->name : null;
}
],
[
'header' => $searchModel->getAttributeLabel('active'),
'attribute' => 'active',
'value' => function($model) {
$list = ['0' => 'Пункт меню скрыт от пользователя ', '1' => 'Пункт меню виднен для пользователю'];
return $list[$model->active];
}
],
],
]);
?>
<style>
.table thead tr th:nth-child(1) ,
.table tbody tr td:nth-child(1) {
width: 0.1px;
padding: 10px 2px;
text-align: center;
}
</style>
\ No newline at end of file
...@@ -18,10 +18,9 @@ $this->registerMetaTag(['property' => 'og:type', 'content' => 'article']); ...@@ -18,10 +18,9 @@ $this->registerMetaTag(['property' => 'og:type', 'content' => 'article']);
$this->registerMetaTag(['property' => 'og:title', 'content' => $modelContent->name]); $this->registerMetaTag(['property' => 'og:title', 'content' => $modelContent->name]);
$this->registerMetaTag(['property' => 'og:image', 'content' => 'https://task-on.com/images/taskon.png']); $this->registerMetaTag(['property' => 'og:image', 'content' => 'https://task-on.com/images/taskon.png']);
$this->registerMetaTag(['property' => 'og:description', 'content' => 'Разработка высоконагруженных сервисов, интернет порталов, корпоративных порталов.']); $this->registerMetaTag(['property' => 'og:description', 'content' => 'Разработка высоконагруженных сервисов, интернет порталов, корпоративных порталов.']);
$this->registerMetaTag(['property' => 'og:url', 'content' => Url::current([],true)]); $this->registerMetaTag(['property' => 'og:url', 'content' => Url::current([], true)]);
//$this->registerMetaTag(['property' => 'og:url', 'content' => Url::base(true)]); //$this->registerMetaTag(['property' => 'og:url', 'content' => Url::base(true)]);
$this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Проект']); $this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Проект']);
?> ?>
...@@ -36,9 +35,9 @@ $this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Пр ...@@ -36,9 +35,9 @@ $this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Пр
<div class="col-sm-12"> <div class="col-sm-12">
<ul> <ul>
<li class="active"> <li class="active">
<a href="faq.html"> <a href="/faq">
<span class="icon_info_2"> <span class="icon_info_2">
</span>Документация </a> </span>Руководство пользователя </a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -50,7 +49,10 @@ $this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Пр ...@@ -50,7 +49,10 @@ $this->registerMetaTag(['property' => 'og:site_name', 'content' => 'Арт Пр
<div class="col-sm-12"> <div class="col-sm-12">
<div class="way"> <div class="way">
<a href="/">Главная</a> <a href="/">Главная</a>
<span>|</span> Документация <span>|</span>
<a href="/faq/">Руководство пользователя</a>
<span>|</span>
<a href="/yii-dokumentaciya/">Документаци для разраотчиков</a>
<span>|</span> <?php echo $modelContent->name ?><br> <br> <span>|</span> <?php echo $modelContent->name ?><br> <br>
</div> </div>
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment