Skip to content

Commit

Permalink
chore(demo): implement json_menu_nested component (dashboard) (#592)
Browse files Browse the repository at this point in the history
Co-authored-by: David mattei <[email protected]>
  • Loading branch information
theus77 and Davidmattei authored Sep 4, 2023
1 parent f3bc244 commit fab9b20
Show file tree
Hide file tree
Showing 39 changed files with 481 additions and 432 deletions.
36 changes: 28 additions & 8 deletions EMS/core-bundle/assets/js/component/jsonMenuNestedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default class JsonMenuNestedComponent {

this.#loadParentIds = json.load_parent_ids;
this.#tree.innerHTML = json.tree;
this._sortables();
this.#element.dispatchEvent(new CustomEvent('jmn-load', {detail: {
jnm: this,
data: json,
elements: this._sortables(),
}}));
this.loading(false);
});
}
Expand All @@ -41,7 +45,15 @@ export default class JsonMenuNestedComponent {
return this._post(`/item/${itemId}/add`, { 'position': position, 'add': add });
}
itemDelete(nodeId) {
return this._post(`/item/${nodeId}/delete`);
const promise = this._post(`/item/${nodeId}/delete`);
const self = this;
promise.then(() => {
self.#element.dispatchEvent(new CustomEvent('jmn-delete', {detail: {
jnm: self,
nodeId: nodeId,
}}));
})
return promise;
}
loading(flag) {
const element = this.#element.querySelector('.jmn-node-loading');
Expand All @@ -61,13 +73,13 @@ export default class JsonMenuNestedComponent {
}, true);
}
_onClickButtonAdd(element, itemId) {
this._ajaxModal(element, `/item/${itemId}/modal-add/${element.dataset.add}`);
this._ajaxModal(element, `/item/${itemId}/modal-add/${element.dataset.add}`, 'jmn-add');
}
_onClickButtonEdit(element, itemId) {
this._ajaxModal(element, `/item/${itemId}/modal-edit`);
this._ajaxModal(element, `/item/${itemId}/modal-edit`, 'jmn-edit');
}
_onClickButtonView(element, itemId) {
this._ajaxModal(element, `/item/${itemId}/modal-view`);
this._ajaxModal(element, `/item/${itemId}/modal-view`, 'jmn-view');
}
_onClickButtonDelete(nodeId) {
this.itemDelete(nodeId).then(() => { this.load(); });
Expand Down Expand Up @@ -126,9 +138,11 @@ export default class JsonMenuNestedComponent {
onEnd: (event) => { return this._onMoveEnd(event) },
}

this.#element.querySelectorAll('.jmn-sortable').forEach((element) => {
const sortables = this.#element.querySelectorAll('.jmn-sortable');
sortables.forEach((element) => {
this.#sortableLists[element.id] = Sortable.create(element, options);
});
return sortables;
}
_onMove(event) {
const dragged = event.dragged;
Expand Down Expand Up @@ -173,7 +187,7 @@ export default class JsonMenuNestedComponent {
});
}
}
_ajaxModal(element, path) {
_ajaxModal(element, path, eventType) {
let activeItemId = null;
const modalSize = element.dataset.modalSize ?? this.modalSize;

Expand All @@ -186,6 +200,12 @@ export default class JsonMenuNestedComponent {
if (!json.hasOwnProperty('success') || !json.success) return;
if (json.hasOwnProperty('load')) this.#loadParentIds.push(json.load);
if (json.hasOwnProperty('item')) activeItemId = json.item;

this.#element.dispatchEvent(new CustomEvent(eventType, {detail: {
jnm: this,
data: json,
activeItemId: activeItemId,
}}));
});
ajaxModal.modal.addEventListener('ajax-modal-close', handlerClose)
}
Expand All @@ -206,4 +226,4 @@ export default class JsonMenuNestedComponent {
});
return response.json();
}
}
}
10 changes: 10 additions & 0 deletions EMS/core-bundle/src/Common/DocumentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace EMS\CoreBundle\Common;

use EMS\CommonBundle\Common\EMSLink;
use EMS\CoreBundle\Entity\Environment;
use EMS\CoreBundle\Entity\Revision;

final class DocumentInfo
Expand Down Expand Up @@ -34,6 +35,15 @@ public function getRevision(string $environmentName): ?Revision
return null;
}

public function getDefaultEnvironment(): ?Environment
{
foreach ($this->revisions as $revision) {
return $revision->giveContentType()->giveEnvironment();
}

return null;
}

public function isAligned(string $environmentName): bool
{
if (null === $revision = $this->getRevision($environmentName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public function itemModalAdd(Request $request, JsonMenuNestedConfig $config, str
return JsonResponse::fromJsonString(AjaxModalResponse::success([
'load' => $parent->isRoot() ? null : $itemId,
'item' => $item->getId(),
'type' => $item->getType(),
'label' => $item->getLabel(),
'object' => $item->getObject(),
]));
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions EMS/core-bundle/src/Resources/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@
"yellow.js": "bundles/emscore/js/yellow.31d6cfe0d16ae931b73c.js",
"yellow-light.css": "bundles/emscore/css/yellow-light.d49e5306580cfb1f6833.css",
"yellow-light.js": "bundles/emscore/js/yellow-light.31d6cfe0d16ae931b73c.js",
"app.css": "bundles/emscore/css/app.3e49baf94ce3b41e340b.css",
"app.js": "bundles/emscore/js/app.b9ea62394cebc260ee85.js",
"edit-revision.css": "bundles/emscore/css/edit-revision.3e49baf94ce3b41e340b.css",
"edit-revision.js": "bundles/emscore/js/edit-revision.aff5a5c5c2f5017edcb9.js",
"managed-alias.css": "bundles/emscore/css/managed-alias.7fe49fddb44c36a8b987.css",
"managed-alias.js": "bundles/emscore/js/managed-alias.d700108e45621051b2de.js",
"user-profile.css": "bundles/emscore/css/user-profile.7fe49fddb44c36a8b987.css",
"user-profile.js": "bundles/emscore/js/user-profile.d7b5e5a28726bfea1890.js",
"template.css": "bundles/emscore/css/template.7fe49fddb44c36a8b987.css",
"template.js": "bundles/emscore/js/template.411436677bfe781165ea.js",
"hierarchical.css": "bundles/emscore/css/hierarchical.7fe49fddb44c36a8b987.css",
"hierarchical.js": "bundles/emscore/js/hierarchical.31a76e957afac9e6ca3d.js",
"calendar.css": "bundles/emscore/css/calendar.7fe49fddb44c36a8b987.css",
"calendar.js": "bundles/emscore/js/calendar.e9bd8836991b40e63c76.js",
"criteria-view.css": "bundles/emscore/css/criteria-view.7fe49fddb44c36a8b987.css",
"criteria-view.js": "bundles/emscore/js/criteria-view.0a1e0b1774895edf43fc.js",
"criteria-table.css": "bundles/emscore/css/criteria-table.7fe49fddb44c36a8b987.css",
"criteria-table.js": "bundles/emscore/js/criteria-table.08c9d619235e7aa7075e.js",
"i18n.css": "bundles/emscore/css/i18n.7fe49fddb44c36a8b987.css",
"i18n.js": "bundles/emscore/js/i18n.f477df7c755949571be5.js",
"app.css": "bundles/emscore/css/app.cef1c7a4846dc5fa76ef.css",
"app.js": "bundles/emscore/js/app.33cdd205a727ed31bb2c.js",
"edit-revision.css": "bundles/emscore/css/edit-revision.cef1c7a4846dc5fa76ef.css",
"edit-revision.js": "bundles/emscore/js/edit-revision.9d4716a841833cc97bca.js",
"managed-alias.css": "bundles/emscore/css/managed-alias.428711ce4389ebccc0d3.css",
"managed-alias.js": "bundles/emscore/js/managed-alias.0d67087b71f0c8d3c73d.js",
"user-profile.css": "bundles/emscore/css/user-profile.428711ce4389ebccc0d3.css",
"user-profile.js": "bundles/emscore/js/user-profile.402dcb62ea40f5078d5b.js",
"template.css": "bundles/emscore/css/template.428711ce4389ebccc0d3.css",
"template.js": "bundles/emscore/js/template.96f1ad71eafd2fe04bd2.js",
"hierarchical.css": "bundles/emscore/css/hierarchical.428711ce4389ebccc0d3.css",
"hierarchical.js": "bundles/emscore/js/hierarchical.94a9817bd200a16e66e7.js",
"calendar.css": "bundles/emscore/css/calendar.428711ce4389ebccc0d3.css",
"calendar.js": "bundles/emscore/js/calendar.4a43e7bdc157a62ac7e5.js",
"criteria-view.css": "bundles/emscore/css/criteria-view.428711ce4389ebccc0d3.css",
"criteria-view.js": "bundles/emscore/js/criteria-view.d72a1d59f34e6082dbf1.js",
"criteria-table.css": "bundles/emscore/css/criteria-table.428711ce4389ebccc0d3.css",
"criteria-table.js": "bundles/emscore/js/criteria-table.54ea5f9e8258d70e309a.js",
"i18n.css": "bundles/emscore/css/i18n.428711ce4389ebccc0d3.css",
"i18n.js": "bundles/emscore/js/i18n.7b2c650eaad152a754c5.js",
"dashboard-browser.css": "bundles/emscore/css/dashboard-browser.0ca4a46888d56dc2418f.css",
"dashboard-browser.js": "bundles/emscore/js/dashboard-browser.b827d809f0a027d92b63.js",
"js/ace/worker-xquery.js": "bundles/emscore/js/ace/worker-xquery.js",
Expand Down Expand Up @@ -611,10 +611,10 @@
"js/cke-plugins/adv_link/lang/hi.js": "bundles/emscore/js/cke-plugins/adv_link/lang/hi.js",
"js/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js": "bundles/emscore/js/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js",
"js/ace/theme-tomorrow.js": "bundles/emscore/js/ace/theme-tomorrow.js",
"js/cke-plugins/imagebrowser/README.rst": "bundles/emscore/js/cke-plugins/imagebrowser/README.rst",
"js/ckeditor/skins/kama/images/sprites_ie6.png": "bundles/emscore/js/ckeditor/skins/kama/images/sprites_ie6.png",
"js/ace/theme-twilight.js": "bundles/emscore/js/ace/theme-twilight.js",
"js/ckeditor/styles.js": "bundles/emscore/js/ckeditor/styles.js",
"js/cke-plugins/imagebrowser/README.rst": "bundles/emscore/js/cke-plugins/imagebrowser/README.rst",
"js/ace/mode-lucene.js": "bundles/emscore/js/ace/mode-lucene.js",
"js/ace/theme-merbivore_soft.js": "bundles/emscore/js/ace/theme-merbivore_soft.js",
"js/ace/theme-clouds_midnight.js": "bundles/emscore/js/ace/theme-clouds_midnight.js",
Expand Down Expand Up @@ -648,6 +648,7 @@
"js/ace/mode-ada.js": "bundles/emscore/js/ace/mode-ada.js",
"js/ace/theme-idle_fingers.js": "bundles/emscore/js/ace/theme-idle_fingers.js",
"js/ckeditor/plugins/colorbutton/lang/ka.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/ka.js",
"js/cke-plugins/adv_link/README.md": "bundles/emscore/js/cke-plugins/adv_link/README.md",
"js/ace/theme-merbivore.js": "bundles/emscore/js/ace/theme-merbivore.js",
"js/ace/theme-dawn.js": "bundles/emscore/js/ace/theme-dawn.js",
"js/ace/snippets/sqlserver.js": "bundles/emscore/js/ace/snippets/sqlserver.js",
Expand All @@ -658,7 +659,6 @@
"js/ckeditor/plugins/colorbutton/lang/uk.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/uk.js",
"js/ckeditor/skins/moono/images/hidpi/refresh.png": "bundles/emscore/js/ckeditor/skins/moono/images/hidpi/refresh.png",
"js/ckeditor/plugins/codesnippet/lib/highlight/styles/googlecode.css": "bundles/emscore/js/ckeditor/plugins/codesnippet/lib/highlight/styles/googlecode.css",
"js/cke-plugins/adv_link/README.md": "bundles/emscore/js/cke-plugins/adv_link/README.md",
"js/cke-plugins/adv_link/lang/bg.js": "bundles/emscore/js/cke-plugins/adv_link/lang/bg.js",
"js/ckeditor/plugins/showblocks/plugin.js": "bundles/emscore/js/ckeditor/plugins/showblocks/plugin.js",
"js/ace/mode-toml.js": "bundles/emscore/js/ace/mode-toml.js",
Expand Down Expand Up @@ -869,14 +869,14 @@
"js/ckeditor/plugins/colorbutton/lang/fi.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/fi.js",
"js/cke-plugins/adv_link/lang/zh-cn.js": "bundles/emscore/js/cke-plugins/adv_link/lang/zh-cn.js",
"js/ckeditor/plugins/colorbutton/lang/ko.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/ko.js",
"js/cke-plugins/imagebrowser/LICENSE.txt": "bundles/emscore/js/cke-plugins/imagebrowser/LICENSE.txt",
"js/ckeditor/plugins/colorbutton/lang/tr.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/tr.js",
"js/cke-plugins/adv_link/lang/zh.js": "bundles/emscore/js/cke-plugins/adv_link/lang/zh.js",
"js/ckeditor/plugins/about/dialogs/about.js": "bundles/emscore/js/ckeditor/plugins/about/dialogs/about.js",
"js/ckeditor/plugins/codesnippet/lib/highlight/LICENSE": "bundles/emscore/js/ckeditor/plugins/codesnippet/lib/highlight/LICENSE",
"js/ckeditor/plugins/colorbutton/lang/et.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/et.js",
"js/ckeditor/plugins/colorbutton/lang/lv.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/lv.js",
"js/ckeditor/plugins/colorbutton/lang/mn.js": "bundles/emscore/js/ckeditor/plugins/colorbutton/lang/mn.js",
"js/cke-plugins/imagebrowser/LICENSE.txt": "bundles/emscore/js/cke-plugins/imagebrowser/LICENSE.txt",
"js/ace/ext-themelist.js": "bundles/emscore/js/ace/ext-themelist.js",
"js/ckeditor/plugins/liststyle/plugin.js": "bundles/emscore/js/ckeditor/plugins/liststyle/plugin.js",
"js/ckeditor/plugins/scayt/LICENSE.md": "bundles/emscore/js/ckeditor/plugins/scayt/LICENSE.md",
Expand Down Expand Up @@ -1129,6 +1129,7 @@
"js/ckeditor/plugins/forms/icons/hidpi/checkbox.png": "bundles/emscore/js/ckeditor/plugins/forms/icons/hidpi/checkbox.png",
"js/ckeditor/plugins/sourcedialog/icons/hidpi/sourcedialog-rtl.png": "bundles/emscore/js/ckeditor/plugins/sourcedialog/icons/hidpi/sourcedialog-rtl.png",
"js/ckeditor/plugins/docprops/icons/hidpi/docprops.png": "bundles/emscore/js/ckeditor/plugins/docprops/icons/hidpi/docprops.png",
"js/cke-plugins/imagebrowser/browser/browser.css": "bundles/emscore/js/cke-plugins/imagebrowser/browser/browser.css",
"js/ckeditor/plugins/codesnippet/dialogs/codesnippet.js": "bundles/emscore/js/ckeditor/plugins/codesnippet/dialogs/codesnippet.js",
"js/ace/ext-linking.js": "bundles/emscore/js/ace/ext-linking.js",
"js/ckeditor/plugins/smiley/images/kiss.png": "bundles/emscore/js/ckeditor/plugins/smiley/images/kiss.png",
Expand All @@ -1144,7 +1145,6 @@
"js/ckeditor/plugins/wsc/lang/bg.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/bg.js",
"js/ckeditor/plugins/embedbase/dialogs/embedbase.js": "bundles/emscore/js/ckeditor/plugins/embedbase/dialogs/embedbase.js",
"js/ckeditor/plugins/uicolor/icons/uicolor.png": "bundles/emscore/js/ckeditor/plugins/uicolor/icons/uicolor.png",
"js/cke-plugins/imagebrowser/browser/browser.css": "bundles/emscore/js/cke-plugins/imagebrowser/browser/browser.css",
"js/ckeditor/plugins/bidi/icons/hidpi/bidirtl.png": "bundles/emscore/js/ckeditor/plugins/bidi/icons/hidpi/bidirtl.png",
"js/ckeditor/plugins/balloontoolbar/skins/kama/balloontoolbar.css": "bundles/emscore/js/ckeditor/plugins/balloontoolbar/skins/kama/balloontoolbar.css",
"js/ckeditor/plugins/wsc/lang/fr.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/fr.js",
Expand Down Expand Up @@ -1258,6 +1258,7 @@
"js/cke-plugins/div/lang/gu.js": "bundles/emscore/js/cke-plugins/div/lang/gu.js",
"js/ckeditor/plugins/div/lang/gu.js": "bundles/emscore/js/ckeditor/plugins/div/lang/gu.js",
"js/ckeditor/plugins/selectall/icons/selectall.png": "bundles/emscore/js/ckeditor/plugins/selectall/icons/selectall.png",
"js/cke-plugins/imagebrowser/browser/browser.html": "bundles/emscore/js/cke-plugins/imagebrowser/browser/browser.html",
"js/ckeditor/plugins/wsc/lang/nb.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/nb.js",
"js/ckeditor/plugins/wsc/lang/no.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/no.js",
"js/ckeditor/plugins/liststyle/lang/bg.js": "bundles/emscore/js/ckeditor/plugins/liststyle/lang/bg.js",
Expand All @@ -1277,7 +1278,6 @@
"js/ckeditor/plugins/wsc/lang/bs.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/bs.js",
"js/ckeditor/plugins/wsc/lang/en.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/en.js",
"js/ckeditor/plugins/wsc/lang/mk.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/mk.js",
"js/cke-plugins/imagebrowser/browser/browser.html": "bundles/emscore/js/cke-plugins/imagebrowser/browser/browser.html",
"js/ckeditor/plugins/smiley/images/thumbs_down.gif": "bundles/emscore/js/ckeditor/plugins/smiley/images/thumbs_down.gif",
"js/ckeditor/plugins/smiley/images/thumbs_up.gif": "bundles/emscore/js/ckeditor/plugins/smiley/images/thumbs_up.gif",
"js/ckeditor/plugins/wsc/lang/zh.js": "bundles/emscore/js/ckeditor/plugins/wsc/lang/zh.js",
Expand Down
2 changes: 1 addition & 1 deletion demo/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project namespace (defaults to the current folder name if not set)
COMPOSE_PROJECT_NAME=elasticms_demo

EMS_VERSION=5.8
EMS_VERSION=5.9
INSTANCE_ID='ems_promo_v2_'
EMS_BACKEND_URL=http://local.ems-demo-admin:9000
EMS_ADMIN_URL=http://local.ems-demo-admin.localhost
Expand Down
Loading

0 comments on commit fab9b20

Please sign in to comment.