adminizer 4.6.0-build.206 → 4.6.0-build.207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helpers/menuHelper.d.ts +3 -6
- package/helpers/menuHelper.js +32 -19
- package/interfaces/adminpanelConfig.d.ts +13 -1
- package/package.json +1 -1
package/helpers/menuHelper.d.ts
CHANGED
|
@@ -10,13 +10,10 @@ export type MenuItem = {
|
|
|
10
10
|
title: string;
|
|
11
11
|
id: string;
|
|
12
12
|
type?: 'blank' | 'self';
|
|
13
|
-
actions: HrefConfig[];
|
|
14
|
-
icon: string;
|
|
15
|
-
accessRightsToken: string;
|
|
13
|
+
actions: HrefConfig[] | null;
|
|
14
|
+
icon: string | null;
|
|
15
|
+
accessRightsToken: string | null;
|
|
16
16
|
entityName?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Section grouping for navbar items (side navigation)
|
|
19
|
-
*/
|
|
20
17
|
section?: string;
|
|
21
18
|
};
|
|
22
19
|
export declare class MenuHelper {
|
package/helpers/menuHelper.js
CHANGED
|
@@ -52,7 +52,7 @@ export class MenuHelper {
|
|
|
52
52
|
hasInlineActions(modelConfig, action) {
|
|
53
53
|
action = action ?? 'list';
|
|
54
54
|
const config = modelConfig[action];
|
|
55
|
-
if (typeof config !== "object" || config === null || !('actions' in config) || !config.actions
|
|
55
|
+
if (typeof config !== "object" || config === null || !('actions' in config) || !config.actions?.inline) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
const actions = config.actions.inline;
|
|
@@ -71,7 +71,7 @@ export class MenuHelper {
|
|
|
71
71
|
return [];
|
|
72
72
|
}
|
|
73
73
|
const config = modelConfig[action];
|
|
74
|
-
if (typeof config === "object" && config !== null && 'actions' in config && config.actions
|
|
74
|
+
if (typeof config === "object" && config !== null && 'actions' in config && config.actions?.global) {
|
|
75
75
|
return config.actions.global;
|
|
76
76
|
}
|
|
77
77
|
return [];
|
|
@@ -89,7 +89,7 @@ export class MenuHelper {
|
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
const config = modelConfig[action];
|
|
92
|
-
if (typeof config === "object" && config !== null && 'actions' in config && config.actions
|
|
92
|
+
if (typeof config === "object" && config !== null && 'actions' in config && config.actions?.inline) {
|
|
93
93
|
return config.actions.inline;
|
|
94
94
|
}
|
|
95
95
|
return [];
|
|
@@ -101,23 +101,22 @@ export class MenuHelper {
|
|
|
101
101
|
*/
|
|
102
102
|
getMenuItems(user) {
|
|
103
103
|
let menus = [];
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
104
|
+
const staticLinks = this.config.navbar?.additionalLinks ?? [];
|
|
105
|
+
staticLinks.forEach(function (additionalLink) {
|
|
106
|
+
if (!additionalLink.link || !additionalLink.title || additionalLink.disabled) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
menus.push({
|
|
110
|
+
link: additionalLink.link,
|
|
111
|
+
title: additionalLink.title,
|
|
112
|
+
type: additionalLink.type,
|
|
113
|
+
id: additionalLink.id || additionalLink.title.replace(" ", "_"),
|
|
114
|
+
actions: additionalLink.subItems || null,
|
|
115
|
+
icon: additionalLink.icon || null,
|
|
116
|
+
accessRightsToken: additionalLink.accessRightsToken || null,
|
|
117
|
+
section: additionalLink.section || 'Platform',
|
|
119
118
|
});
|
|
120
|
-
}
|
|
119
|
+
});
|
|
121
120
|
if (this.config.models) {
|
|
122
121
|
const _this = this;
|
|
123
122
|
Object.entries(this.config.models).forEach(function ([key, val]) {
|
|
@@ -150,6 +149,20 @@ export class MenuHelper {
|
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
}
|
|
152
|
+
const { handleAdditionalLinks, sectionHandlers } = this.config.navbar ?? {};
|
|
153
|
+
if (handleAdditionalLinks) {
|
|
154
|
+
menus = handleAdditionalLinks(user, menus);
|
|
155
|
+
}
|
|
156
|
+
if (sectionHandlers) {
|
|
157
|
+
const sections = Object.keys(sectionHandlers);
|
|
158
|
+
sections.forEach(section => {
|
|
159
|
+
const handler = sectionHandlers[section];
|
|
160
|
+
const sectionLinks = menus.filter(m => m.section === section);
|
|
161
|
+
const otherLinks = menus.filter(m => m.section !== section);
|
|
162
|
+
const handled = handler(user, sectionLinks);
|
|
163
|
+
menus = [...otherLinks, ...handled];
|
|
164
|
+
});
|
|
165
|
+
}
|
|
153
166
|
return menus;
|
|
154
167
|
}
|
|
155
168
|
}
|
|
@@ -78,7 +78,19 @@ export interface AdminpanelConfig {
|
|
|
78
78
|
/**
|
|
79
79
|
* will be created at the bottom of the sidenav panel
|
|
80
80
|
* */
|
|
81
|
-
additionalLinks
|
|
81
|
+
additionalLinks?: HrefConfig[];
|
|
82
|
+
/**
|
|
83
|
+
* Optional callback to filter or transform all navbar links after models have been processed.
|
|
84
|
+
* Receives all links (static + model-generated) and the current user; returns the final array.
|
|
85
|
+
*/
|
|
86
|
+
handleAdditionalLinks?: (user: UserAP, allLinks: HrefConfig[]) => HrefConfig[];
|
|
87
|
+
/**
|
|
88
|
+
* Per-section handlers, applied after all links (static + model-generated) are collected.
|
|
89
|
+
* Each key is a section name; the handler receives links belonging to that section.
|
|
90
|
+
*/
|
|
91
|
+
sectionHandlers?: {
|
|
92
|
+
[section: string]: (user: UserAP, links: HrefConfig[]) => HrefConfig[];
|
|
93
|
+
};
|
|
82
94
|
};
|
|
83
95
|
/**
|
|
84
96
|
* Policies that will be executed before going to every page
|