diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-04-18 23:05:01 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-04-18 23:25:22 +0200 |
commit | 7882f3ebdde0364314a45aa6dd8fbc4e766e8ea8 (patch) | |
tree | 116bc87613e88b6b14fdb21a9fc7463f76164ea7 /modules/luci-base | |
parent | 2dbd9ff2459dc2d1819ef890aafc5ca9f0d4e769 (diff) |
luci-base: ui.js: hide unsatisfied firstchild menu nodes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 625363811c..4219932b9a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -2944,6 +2944,27 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ { } }); + +function scrubMenu(node) { + var hasSatisfiedChild = false; + + if (L.isObject(node.children)) { + for (var k in node.children) { + var child = scrubMenu(node.children[k]); + + if (child.title) + hasSatisfiedChild = hasSatisfiedChild || child.satisfied; + } + } + + if (L.isObject(node.action) && + node.action.type == 'firstchild' && + hasSatisfiedChild == false) + node.satisfied = false; + + return node; +}; + /** * Handle menu. * @@ -2979,7 +3000,7 @@ var UIMenu = baseclass.singleton(/** @lends LuCI.ui.menu.prototype */ { if (!L.isObject(this.menu)) { this.menu = request.get(L.url('admin/menu')).then(L.bind(function(menu) { - this.menu = menu.json(); + this.menu = scrubMenu(menu.json()); session.setLocalData('menu', this.menu); return this.menu; |