Skip to content

Commit b4cfae8

Browse files
ClementBouvierNfreddidierRTE
authored andcommitted
Add the possibility to access custom opfab screen in menu (#7880)
Signed-off-by: ClementBouvierN <[email protected]>
1 parent 5360b4b commit b4cfae8

File tree

8 files changed

+69
-7
lines changed

8 files changed

+69
-7
lines changed

config/docker/ui-config/ui-menu.json

+12-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
"id": "menu2",
3636
"label": "title.multi",
3737
"entries": [
38+
{
39+
"customMenuId": "uid_test_0",
40+
"customScreenId": "testId",
41+
"label": "entry.custom"
42+
},
3843
{
3944
"customMenuId": "uid_test_1",
4045
"url": "https://opfab.github.io/",
@@ -144,7 +149,8 @@
144149
"entry1": "First menu entry",
145150
"entry2": "Second menu entry",
146151
"entry3": "External application",
147-
"admin": "Admin menu entry"
152+
"admin": "Admin menu entry",
153+
"custom": "Custom screen"
148154
}
149155
}
150156
},
@@ -161,7 +167,9 @@
161167
"entry1": "Premier élément",
162168
"entry2": "Deuxième élément",
163169
"entry3": "Application externe",
164-
"admin": "Menu admin élément"
170+
"admin": "Menu admin élément",
171+
"custom": "Écran personnalisé"
172+
165173
}
166174
}
167175
},
@@ -178,7 +186,8 @@
178186
"entry1": "Eerste menu-item",
179187
"entry2": "Tweede menu-item",
180188
"entry3": "TExterne applicatie",
181-
"admin": "Admin menu-item"
189+
"admin": "Admin menu-item",
190+
"custom": "Aangepast scherm"
182191
}
183192
}
184193
}

src/docs/asciidoc/deployment/configuration/web-ui_configuration.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The line customized in the nginx configuration file must end with à semicolon (
3737
[[ui_properties]]
3838
== UI properties
3939

40-
The properties lie in the `web-ui.json`.The following table describes their meaning and how to use them. An example file can be found in the config/docker directory.
40+
The properties lie in the `web-ui.json`. The following table describes their meaning and how to use them. An example file can be found in the config/docker directory.
4141

4242
|===
4343
|name|default|mandatory?|Description

src/docs/asciidoc/reference_doc/ui_customization.adoc

+34
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,40 @@ Named `opfab_theme`, this parameter has a value corresponding to the current the
295295
`http://mysite.com/index.htm?opfab_theme=NIGHT`. Switching theme will trigger reload of open iframes.
296296

297297

298+
=== Custom screen menus
299+
300+
It is possible to add menus linked to custom screens of the application. See custom screen definition link:./single_page_doc.html#card_list_custom_screen[here]. To set up such a menu, it's important to give it a customMenuId and a customScreenId. See example below :
301+
302+
.Example
303+
[source, json]
304+
----
305+
{
306+
"navigationBar": [
307+
{
308+
"opfabCoreMenuId": "feed"
309+
},
310+
{
311+
"id": "menu1",
312+
"entries": [
313+
{
314+
"customMenuId": "uid_test_0",
315+
"customScreenId": "testId",
316+
"label": "entry.custom"
317+
},
318+
{
319+
"customMenuId": "uid_test_1",
320+
"url": "https://opfab.github.io/",
321+
"label": "entry.single",
322+
"linkType": "BOTH"
323+
}
324+
]
325+
}
326+
],
327+
[...]
328+
}
329+
----
330+
331+
[[card_list_custom_screen]]
298332
== Card List Custom Screen
299333

300334
You can define a custom screen containing a search header and a list of cards.

ui/main/src/app/services/config/model/MenuEntry.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class MenuEntry {
1616
constructor(
1717
public readonly id: string,
1818
public readonly customMenuId: string,
19+
public readonly customScreenId: string,
1920
public readonly opfabCoreMenuId: string,
2021
public readonly label: string,
2122
public readonly url: string,

ui/main/src/app/services/navigation/NavigationService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export enum PageType {
1515
UNKNOWN,
1616
FEED,
1717
ARCHIVE,
18-
THIRPARTY,
18+
THIRDPARTY,
1919
SETTING,
2020
ABOUT,
2121
CALENDAR,
@@ -31,7 +31,7 @@ export class NavigationService {
3131
private static readonly pageConf = new Map([
3232
['feed', PageType.FEED],
3333
['archives', PageType.ARCHIVE],
34-
['businessconfigparty', PageType.THIRPARTY],
34+
['businessconfigparty', PageType.THIRDPARTY],
3535
['setting', PageType.SETTING],
3636
['about', PageType.ABOUT],
3737
['calendar', PageType.CALENDAR],

ui/main/src/app/views/navbar/navbarMenu.view.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ export class NavbarMenuView {
102102

103103
private setMenuElementProperties(navbarMenuElement: NavbarMenuElement, menuElementConfig: any): void {
104104
navbarMenuElement.dropdownMenu = [];
105-
navbarMenuElement.id = menuElementConfig.opfabCoreMenuId || menuElementConfig.customMenuId;
105+
navbarMenuElement.id =
106+
menuElementConfig.opfabCoreMenuId || menuElementConfig.customScreenId || menuElementConfig.customMenuId;
106107
navbarMenuElement.isCoreMenu = !!menuElementConfig.opfabCoreMenuId;
108+
navbarMenuElement.isCustomScreen = !!menuElementConfig.customScreenId;
107109
navbarMenuElement.label = this.getTranslation(menuElementConfig);
108110
navbarMenuElement.url = menuElementConfig.url;
109111
navbarMenuElement.linkType = menuElementConfig.linkType;
@@ -186,6 +188,10 @@ export class NavbarMenuView {
186188
}
187189

188190
public onMenuClick(navbarMenuElement: NavbarMenuElement, isClickOnNewTabIcon = false): void {
191+
if (navbarMenuElement.isCustomScreen) {
192+
NavigationService.navigateTo('customscreen/' + navbarMenuElement.id);
193+
return;
194+
}
189195
if (navbarMenuElement.isCoreMenu) {
190196
if (navbarMenuElement.id === 'nightdaymode') {
191197
if (GlobalStyleService.getStyle() === GlobalStyleService.DAY) {

ui/main/src/app/views/navbar/navbarMenu_OnMenuClick.view.spec.ts

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ describe('NavbarMenuView - OnMenuClick', () => {
5454
expect(applicationRouterMock.urlCalled).toEqual('businessconfigparty/customMenu1/');
5555
});
5656

57+
it('open custom screen if menu item contains custom screen id ', async () => {
58+
clickOnMenu({
59+
menuId: 'customMenu1',
60+
isCustomScreen: true,
61+
isCoreMenu: false
62+
});
63+
expect(applicationRouterMock.urlCalled).toEqual('customscreen/customMenu1');
64+
});
65+
5766
it('set route for custom application with double encoding if id contains a #', async () => {
5867
clickOnMenu({
5968
menuId: 'custom#Menu1',
@@ -206,6 +215,7 @@ describe('NavbarMenuView - OnMenuClick', () => {
206215
function clickOnMenu({
207216
menuId = 'MyMenuId',
208217
isCoreMenu = false,
218+
isCustomScreen = false,
209219
linkType = MenuEntryLinkType.IFRAME,
210220
url = '',
211221
openInNewTab = false
@@ -215,6 +225,7 @@ describe('NavbarMenuView - OnMenuClick', () => {
215225
const navbarMenuElement = new NavbarMenuElement();
216226
navbarMenuElement.id = menuId;
217227
navbarMenuElement.isCoreMenu = isCoreMenu;
228+
navbarMenuElement.isCustomScreen = isCustomScreen;
218229
navbarMenuElement.linkType = linkType;
219230
navbarMenuElement.url = url;
220231
navbarMenuView.onMenuClick(navbarMenuElement, openInNewTab);

ui/main/src/app/views/navbar/navbarPage.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class NavbarMenuElement {
3737
id: string;
3838
url: string;
3939
label: string;
40+
isCustomScreen: boolean;
4041
linkType: MenuEntryLinkType;
4142
dropdownMenu: NavbarMenuElement[];
4243
}

0 commit comments

Comments
 (0)