From 49ad10bc085ff59b9fc99f33c36290dc66ac2a26 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 29 Jun 2022 17:32:48 +0200 Subject: [PATCH] Expose the identifier of a menu item --- ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts | 4 ++++ ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.ts | 3 +++ ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Provider.ts | 1 + .../js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js | 4 ++++ .../files/js/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.js | 2 ++ 5 files changed, 14 insertions(+) diff --git a/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts b/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts index 8a8e576e54..d7268e4964 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts @@ -20,6 +20,7 @@ function getSubMenuItems(subMenu: HTMLElement, menuItem: string): MenuItem[] { children, counter: 0, depth: 1, + identifier: false, title, }; }); @@ -39,6 +40,7 @@ function getMenuItems(category: HTMLOListElement): MenuItem[] { children, counter: 0, depth: 2, + identifier: false, link: link.href, title: link.textContent!, }; @@ -57,6 +59,7 @@ function getMenuItemActions(link: HTMLAnchorElement): MenuItem[] { children: [], counter: 0, depth: 2, + identifier: false, link: action.href, title: action.dataset.tooltip || action.title, }; @@ -79,6 +82,7 @@ export class AcpUiPageMenuMainBackend implements PageMenuMainProvider { children, counter: 0, depth: 0, + identifier: false, title, }; }, diff --git a/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.ts b/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.ts index 17043aab8a..3409ca7501 100644 --- a/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.ts +++ b/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.ts @@ -41,11 +41,14 @@ function normalizeMenuItem(menuItem: HTMLElement, depth: MenuItemDepth): MenuIte const active = menuItem.classList.contains("active"); + const identifier = anchor.parentElement!.dataset.identifier!; + return { active, children, counter, depth, + identifier, link, title, }; diff --git a/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Provider.ts b/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Provider.ts index 6ffdd83727..96b1535158 100644 --- a/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Provider.ts +++ b/ts/WoltLabSuite/Core/Ui/Page/Menu/Main/Provider.ts @@ -16,6 +16,7 @@ export type MenuItem = { children: MenuItem[]; counter: number; depth: MenuItemDepth; + identifier: string | false; link?: string; title: string; }; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js index 43ba1d4373..1fcc63ac03 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js @@ -20,6 +20,7 @@ define(["require", "exports"], function (require, exports) { children, counter: 0, depth: 1, + identifier: false, title, }; }); @@ -36,6 +37,7 @@ define(["require", "exports"], function (require, exports) { children, counter: 0, depth: 2, + identifier: false, link: link.href, title: link.textContent, }; @@ -52,6 +54,7 @@ define(["require", "exports"], function (require, exports) { children: [], counter: 0, depth: 2, + identifier: false, link: action.href, title: action.dataset.tooltip || action.title, }; @@ -70,6 +73,7 @@ define(["require", "exports"], function (require, exports) { children, counter: 0, depth: 0, + identifier: false, title, }; }); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.js index 913eedce4d..3ca79e3e7f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Main/Frontend.js @@ -36,11 +36,13 @@ define(["require", "exports"], function (require, exports) { link = anchor.href; } const active = menuItem.classList.contains("active"); + const identifier = anchor.parentElement.dataset.identifier; return { active, children, counter, depth, + identifier, link, title, }; -- 2.20.1