|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by Error202
|
|
|
|
* Date: 11.07.2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var $this \yii\web\View
|
|
|
|
* @var $items array
|
|
|
|
* @var $menu \core\entities\menu\Menu
|
|
|
|
*/
|
|
|
|
|
|
|
|
use backend\components\menu\assets\MenuAsset;
|
|
|
|
use yii\helpers\Html;
|
|
|
|
use yii\helpers\Url;
|
|
|
|
use yii\web\JsExpression;
|
|
|
|
|
|
|
|
MenuAsset::register($this);
|
|
|
|
|
|
|
|
function menu_generate($items) {
|
|
|
|
$html = '<ol class="dd-list">';
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$html.=Yii::$app->getView()->render( '_item', [
|
|
|
|
'item' => $item,
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
return $html . '</ol>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$name_empty_error = Yii::t('menu', 'Name must be specified');
|
|
|
|
$item_save_url = Url::to(['menu/save-menu-item-data']);
|
|
|
|
$item_delete_url = Url::to(['menu/delete-menu-item']);
|
|
|
|
$confirm_delete_message = Yii::t('buttons', 'Are you sure you want to delete this item?');
|
|
|
|
$current_url = Url::to(['menu/index', 'id' => $menu->id]);
|
|
|
|
$js = <<<JS
|
|
|
|
$(".item-save-button").on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var id = $(this).data('id');
|
|
|
|
var name = $("#item-name-" + id).val();
|
|
|
|
var title = $("#item-title-attr-" + id).val();
|
|
|
|
var style = $("#item-style-" + id).val();
|
|
|
|
var css = $("#item-css-" + id).val();
|
|
|
|
var url = $("#item-url-" + id).val();
|
|
|
|
var target = $("#item-target-" + id).val();
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "{$item_save_url}",
|
|
|
|
data: { name: name, title: title, style: style, css: css, url: url, target: target, id: id }
|
|
|
|
})
|
|
|
|
.done(function( data ) {
|
|
|
|
if (data.result === 'success') {
|
|
|
|
document.location.href = '{$current_url}';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert('{$name_empty_error}');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".item-delete-button").on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (confirm('{$confirm_delete_message}')) {
|
|
|
|
var id = $(this).data('id');
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "{$item_delete_url}",
|
|
|
|
data: { id: id }
|
|
|
|
})
|
|
|
|
.done(function( data ) {
|
|
|
|
if (data.result === 'success') {
|
|
|
|
document.location.href = '{$current_url}';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
JS;
|
|
|
|
$this->registerJs($js, $this::POS_READY);
|
|
|
|
|
|
|
|
$url = Url::to(['/menu/save-menu-items']);
|
|
|
|
$redirect = Url::to(['menu/index', 'id' => $menu->id]);
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="dd" id="nestable3">
|
|
|
|
<?= menu_generate($items) ?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
<div class="dd" id="nestable2">
|
|
|
|
<ol class="dd-list">
|
|
|
|
|
|
|
|
<li class="dd-item dd3-item" data-id="13">
|
|
|
|
<div class="dd3-content">
|
|
|
|
<div class="panel-group" id="accordion">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<div class="dd-handle dd3-handle"> </div>
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Item 13
|
|
|
|
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse1" class="panel-collapse collapse">
|
|
|
|
<div class="panel-body">
|
|
|
|
Content Panel
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li class="dd-item dd3-item" data-id="14">
|
|
|
|
<div class="dd3-content">
|
|
|
|
<div class="panel-group" id="accordion">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<div class="dd-handle dd3-handle"> </div>
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Item 14
|
|
|
|
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse2" class="panel-collapse collapse">
|
|
|
|
<div class="panel-body">
|
|
|
|
Content Panel
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li class="dd-item dd3-item" data-id="15">
|
|
|
|
<div class="dd3-content">
|
|
|
|
<div class="panel-group" id="accordion">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<div class="dd-handle dd3-handle"> </div>
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Item 15
|
|
|
|
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse3" class="panel-collapse collapse">
|
|
|
|
<div class="panel-body">
|
|
|
|
Content Panel
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ol class="dd-list">
|
|
|
|
<li class="dd-item dd3-item" data-id="16">
|
|
|
|
<div class="dd3-content">
|
|
|
|
<div class="panel-group" id="accordion">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<div class="dd-handle dd3-handle"> </div>
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse4">Item 16
|
|
|
|
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse4" class="panel-collapse collapse">
|
|
|
|
<div class="panel-body">
|
|
|
|
Content Panel
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div style="clear: both;"></div>
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<button class="btn btn-primary" id="serialize">Serialize</button>
|
|
|
|
<hr>
|
|
|
|
<textarea class="form-control" id="output"></textarea>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
<textarea class="form-control" id="output2"></textarea>
|
|
|
|
-->
|
|
|
|
|
|
|
|
<div style="clear: both;"></div>
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<?= Html::button(Yii::t('buttons', 'Save'), [
|
|
|
|
'class' => 'btn btn-success pull-right',
|
|
|
|
'onclick' => new JsExpression('sendTree('.$menu->id.', "'.$url.'", "'.$redirect.'")'),
|
|
|
|
]) ?>
|