From 54217649b88bcc2a833c794fc988d95b9b5abde4 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Mon, 9 Sep 2024 11:20:43 +0900 Subject: [PATCH] =?UTF-8?q?Dataset.findData()=20=EC=B6=94=EA=B0=80,=20Menu?= =?UTF-8?q?Support=20onclick=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/resources/js/base/dataset.js | 12 ++++++++++++ src/main/webapp/resources/js/base/menu-support.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/base/dataset.js b/src/main/webapp/resources/js/base/dataset.js index 9d04161..0a11e1b 100644 --- a/src/main/webapp/resources/js/base/dataset.js +++ b/src/main/webapp/resources/js/base/dataset.js @@ -896,6 +896,14 @@ class Dataset { } return result; } + + findData(filter, option) { + let found = this._items.filter(item => filter(item)); + if ("item" == option) + return found; + + return found.map(item => item.data); + } /**Returns whether the Dataset is dirty. * A Dataset is dirty if it has user data that is either added, modified, or removed. @@ -1582,6 +1590,10 @@ class DatasetControl { getDataset(option) { return this.dataset.getDataset(option); } + + findData(filter, option) { + return this.dataset.findData(filter, option); + } setData(obj, option = {}) { this.setPaging(obj, option); diff --git a/src/main/webapp/resources/js/base/menu-support.js b/src/main/webapp/resources/js/base/menu-support.js index caebaa1..465b582 100644 --- a/src/main/webapp/resources/js/base/menu-support.js +++ b/src/main/webapp/resources/js/base/menu-support.js @@ -9,7 +9,7 @@ class MenuSupport { this._selector = ifEmpty(conf.selector, "#menus"); this._containerSelector = ifEmpty(conf.containerSelector, "#layout-menu"); this._container = document.querySelector(this._containerSelector); - let onclick = conf.onclick || (menu => 'onclick="openMenu(\'{url}\')" '.replace(/{url}/gi, wctx.url(menu.url))); + let onclick = conf.onclick || (menu => 'onclick="openMenu(\'{url}\')" '.replace(/{url}/gi, menu.url)); this._onclick = (menu => menu && menu.url ? onclick(menu) : ""); this._horizontal = this._container && this._container.classList.contains('menu-horizontal');