diff --git a/src/main/webapp/WEB-INF/jsp/include/tail.jsp b/src/main/webapp/WEB-INF/jsp/include/tail.jsp index 129609e7..128b972f 100644 --- a/src/main/webapp/WEB-INF/jsp/include/tail.jsp +++ b/src/main/webapp/WEB-INF/jsp/include/tail.jsp @@ -11,6 +11,7 @@ <%-- --%> <%--? Config: Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file. --> @@ -24,11 +25,9 @@ - - - + @@ -48,9 +47,9 @@ - + diff --git a/src/main/webapp/resources/js/base/menu-support-fims.js b/src/main/webapp/resources/js/base/menu-support-fims.js index 2d968833..fbe87305 100644 --- a/src/main/webapp/resources/js/base/menu-support-fims.js +++ b/src/main/webapp/resources/js/base/menu-support-fims.js @@ -7,13 +7,47 @@ class FimsMenuSupport extends MenuSupport { this._menuItem = ''; } + setMenuInfo(menus) { + + let setParent = menu => { + let children = menu.children || []; + if (children.length < 1) return; + + children.forEach(child => { + child.parent = menu; + setParent(child); + }); + }; + menus.forEach(menu => setParent(menu)); + this._menus = menus; + + let menuItemTag = menu => { + let tag = this._menuItem + .replace(/{menuID}/gi, menu.id) + .replace(/{menuName}/gi, menu.name) + .replace(/{url}/gi, !menu.url ? "javascript:void(0);" : wctx.url(menu.url)) + .replace(/{imageConf}/gi, !menu.imageConf ? "bx bx-layout" : menu.imageConf); + let parent = menu.children && menu.children.length > 0; + tag = tag.replace(/{toggle}/gi, !parent ? "" : " menu-toggle"); + if (!parent) + return tag.replace(/{menuSub}/gi, ""); + + let children = menu.children.map(child => menuItemTag(child)).join("\n\t") + return tag.replace(/{menuSub}/gi, this._menuSub.replace(/{children}/gi, children)); + } + let tags = (menus || []).map(menu => menuItemTag(menu)); + document.querySelector("#menus").innerHTML = tags.join(""); + + return this._init(); + } + }