From 0bd2fca4963e7839cc5e2d58050167e3a8f4b722 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 5 Sep 2023 15:17:28 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EC=BD=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/WEB-INF/jsp/include/tail.jsp | 7 ++-- .../resources/js/base/menu-support-fims.js | 36 ++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) 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(); + } + }