1 |
50586
|
argiro.kok
|
export class MenuItem {
|
2 |
55405
|
k.triantaf
|
id: string = ""; // for root menu in order to close the dropdown when clicked
|
3 |
|
|
title: string = "";
|
4 |
|
|
url: string = ""; // external url
|
5 |
|
|
route: string = ""; // internal url - using angular routing and components
|
6 |
|
|
needsAuthorization: boolean = false; // needs admin rights - mainly for user menu at this point
|
7 |
|
|
entitiesRequired: string[] = []; // openaire entities used in page "publication, dataset, organization, software, project, datasource"
|
8 |
|
|
routeRequired: string[] = []; // the routes that if aren't enable the menu item doesn't make sense
|
9 |
|
|
params: any = {};
|
10 |
57935
|
argiro.kok
|
markAsActive: boolean;
|
11 |
|
|
items: MenuItem[] = [];
|
12 |
|
|
icon: string;
|
13 |
|
|
open: boolean;
|
14 |
50586
|
argiro.kok
|
|
15 |
58836
|
argiro.kok
|
constructor(id: string, title: string, url: string, route: string, needsAuthorization: boolean, entitiesRequired: string[], routeRequired: string[], params, icon=null) {
|
16 |
55405
|
k.triantaf
|
this.id = id;
|
17 |
|
|
this.title = title;
|
18 |
|
|
this.url = url;
|
19 |
|
|
this.route = route;
|
20 |
|
|
this.needsAuthorization = needsAuthorization;
|
21 |
|
|
this.entitiesRequired = entitiesRequired;
|
22 |
|
|
this.routeRequired = routeRequired;
|
23 |
|
|
this.params = params;
|
24 |
56199
|
argiro.kok
|
this.markAsActive = true;
|
25 |
57935
|
argiro.kok
|
this.items = [];
|
26 |
58836
|
argiro.kok
|
this.icon = icon;
|
27 |
50586
|
argiro.kok
|
}
|
28 |
57935
|
argiro.kok
|
|
29 |
|
|
public setMarkAsActive(showActive: boolean) {
|
30 |
56199
|
argiro.kok
|
this.markAsActive = showActive;
|
31 |
|
|
}
|
32 |
55405
|
k.triantaf
|
|
33 |
57935
|
argiro.kok
|
public static isTheActiveMenu(menu: MenuItem, currentRoute: string): boolean {
|
34 |
|
|
if (!menu.markAsActive) {
|
35 |
|
|
return false;
|
36 |
|
|
}
|
37 |
|
|
if (currentRoute == menu.route) {
|
38 |
|
|
return true;
|
39 |
|
|
} else if (menu.items.length > 0) {
|
40 |
|
|
for (let menuItem of menu.items) {
|
41 |
|
|
if (menuItem.route == currentRoute) {
|
42 |
|
|
return true;
|
43 |
|
|
}
|
44 |
|
|
}
|
45 |
|
|
}
|
46 |
|
|
return false;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
|
50 |
55405
|
k.triantaf
|
}
|
51 |
|
|
|
52 |
|
|
export class RootMenuItem {
|
53 |
|
|
rootItem: MenuItem;
|
54 |
|
|
items: MenuItem[] = [];
|
55 |
57935
|
argiro.kok
|
|
56 |
|
|
public static isTheActiveRootMenu(menu: RootMenuItem, currentRoute: string): boolean {
|
57 |
|
|
if (!menu.rootItem.markAsActive) {
|
58 |
|
|
return false;
|
59 |
|
|
}
|
60 |
|
|
if (currentRoute == menu.rootItem.route) {
|
61 |
|
|
return true;
|
62 |
|
|
} else if (menu.items.length > 0) {
|
63 |
|
|
for (let menuItem of menu.items) {
|
64 |
|
|
let isActive = MenuItem.isTheActiveMenu(menuItem, currentRoute);
|
65 |
|
|
if (isActive) {
|
66 |
|
|
return true;
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
return false;
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
55405
|
k.triantaf
|
}
|
73 |
|
|
|
74 |
|
|
export class SideMenuItem {
|
75 |
|
|
rootItem: MenuItem;
|
76 |
|
|
items: RootMenuItem[] = [];
|
77 |
|
|
ukIcon: string = '';
|
78 |
|
|
}
|