Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
eluhr committed Dec 19, 2018
1 parent 897dd44 commit ee24d56
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
3 changes: 2 additions & 1 deletion assets/PagesBackendAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class PagesBackendAsset extends AssetBundle
'less/backend.less',
];
public $js = [
'js/page-route-items.js'
'js/page-route-items.js',
'js/page-select.js'
];
public $depends = [
'rmrevin\yii\fontawesome\AssetBundle',
Expand Down
2 changes: 1 addition & 1 deletion assets/js/page-route-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $(function () {
schema: JSON.parse(schema),
theme: "bootstrap3",
ajax: true,
// disable_collapse: true,
disable_collapse: true,
// disable_edit_json: true,
// disable_properties: true
});
Expand Down
13 changes: 13 additions & 0 deletions assets/js/page-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(function () {

$(document).on("click",".kv-tree li[data-key]", function (e) {
e.stopPropagation();
var pageId = $(this).data("key");
var searchParams = new URLSearchParams(window.location.search);
searchParams.set("pageId", pageId);
var newUrl = window.location.origin + window.location.pathname + "?" + searchParams.toString();

history.pushState({}, null, newUrl);
});

});
9 changes: 7 additions & 2 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class DefaultController extends Controller
/**
* @return mixed
*/
public function actionIndex()
public function actionIndex($pageId = null)
{
if (!$this->module->getLocalizedRootNode()) {
$localicedRootNode = $this->module->getLocalizedRootNode();
if (!$localicedRootNode) {
$language = mb_strtolower(\Yii::$app->language);
$rootNodePrefix = Tree::ROOT_NODE_PREFIX;

Expand All @@ -53,6 +54,10 @@ class="btn btn-warning">Create root-node for <b>{$language}</b></a>

$this->getView()->registerJs($js, View::POS_LOAD);
\Yii::$app->session->addFlash('warning', $msg);
} else {
if (!empty($pageId)) {
Yii::$app->session->set('kvNodeId', $pageId);
}
}

/**
Expand Down
13 changes: 12 additions & 1 deletion helpers/PageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public static function routeToSchema($route)
return $controller->jsonFromAction($route);
}
}
return '{}';
return static::defaultJsonSchema();
}

public static function defaultJsonSchema()
{
return <<<JSON
{
"title": "Request Params",
"type": "object"
}
JSON;

}
}
9 changes: 5 additions & 4 deletions traits/RequestParamActionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
namespace dmstr\modules\pages\traits;


use dmstr\modules\pages\helpers\PageHelper;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use ReflectionParameter;
use yii\helpers\ArrayHelper;
use yii\helpers\Inflector;

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ public function jsonFromAction($route)
return $this->generateJson($actionRefl->getParameters(), $actionId);

} catch (ReflectionException $e) {
return '{}';
return PageHelper::defaultJsonSchema();
}
}

Expand All @@ -110,7 +110,7 @@ private function generateJson($parameters, $actionId)
{

$properties = [];
$requiredFields =[];
$requiredFields = [];
$debug = [];
foreach ($parameters as $parameter) {
// get name
Expand Down Expand Up @@ -232,7 +232,8 @@ private function generateJson($parameters, $actionId)

}

protected function jsonListFromArray($array) {
protected function jsonListFromArray($array)
{
return '"' . implode('","', $array) . '"';
}

Expand Down
5 changes: 3 additions & 2 deletions views/treeview/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
echo Html::hiddenInput(Html::getInputName($node, $keyAttribute), $node->id);
echo Html::hiddenInput('treeNodeModify', $node->isNewRecord);
echo Html::hiddenInput('parentKey', $parentKey);
echo Html::hiddenInput('currUrl', $currUrl);
echo Html::hiddenInput('currUrl', Url::to(['/pages', 'pageId' => $node->id]));
echo Html::hiddenInput('modelClass', $modelClass);
echo Html::hiddenInput('softDelete', $softDelete);
?>
Expand Down Expand Up @@ -121,6 +121,7 @@
<?= $nodeUrl ?>
<br/>
<span class="label label-default"><?= $node->getNameId() ?></span>
<span class="label label-default"><?= $node->id ?></span>
</p>


Expand Down Expand Up @@ -252,7 +253,7 @@
'clientOptions' => [
'theme' => 'bootstrap3',
'ajax' => true,
// 'disable_collapse' => true,
'disable_collapse' => true,
// 'disable_edit_json' => true,
// 'disable_properties' => true
]
Expand Down

0 comments on commit ee24d56

Please sign in to comment.