From acdba43c8bc8244f59e32e450f0dd106bb397037 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 9 Dec 2022 16:43:36 +0200 Subject: [PATCH] [Connect Admin | Trunk & Library | angular-14]: Allow curators with profile to be invisible in the Gateway | Dynamically align custom menu. 1. CuratorInfo.ts: In Curator class added visible: boolean = true; 2. personal-info.module.ts: Imported MatSlideToggleModule. 3. personal-info.component.ts: Added slider to set curator profile to visible or invisible (default to visible). 4. menu.ts: In Menu class added field "featuredAlignment: MenuAlignment;" | Added enum MenuAlignment. 5. menu.component: Updated title "Menu settings" | Added "Menu Alignment" setting, to set if custom menu will be left, center or right alligned | Added notification when menu visibility changes. 6. help-content.service.ts: Added "alignMenu()" method to align custom menu dynamically. --- dashboard/menu/menu.component.html | 28 +++++++++++++++++++++++++--- dashboard/menu/menu.component.ts | 30 +++++++++++++++++++++--------- services/help-content.service.ts | 5 +++++ sharedComponents/menu.ts | 3 +++ utils/entities/CuratorInfo.ts | 1 + 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/dashboard/menu/menu.component.html b/dashboard/menu/menu.component.html index 2a1f847c..7b966ee4 100644 --- a/dashboard/menu/menu.component.html +++ b/dashboard/menu/menu.component.html @@ -159,19 +159,41 @@
-
Menu settings
+
Menu visibility
+ +
Menu alignment
+
+
+ +
+
+ +
+
+ +
+
{ + NotificationHandler.rise("Menu has been successfully toggled to be "+(status?"visible":"hidden")+""); + }, error => { this.handleError("System error toggling menu", error); }) ); } + public alignMenu(alignment: string) { + this.subscriptions.push( + this._helpContentService.alignMenu(MenuAlignment[alignment], this.portal).subscribe(() => { + this.featuredAlignment = alignment; + this._clearCacheService.clearCache("Menu aligned"); + this._clearCacheService.purgeBrowserCache("Menu aligned", this.portal); + NotificationHandler.rise("Menu has been successfully "+alignment.toLowerCase()+" aligned"); + }, error => { + this.handleError("System error aligning menu to the "+alignment.toLowerCase(), error); + }) + ); + } + // public newPageWindow() { // this.newPageWindowOpen = !this.newPageWindowOpen; // this.pageForm = this._fb.group({ @@ -465,11 +481,7 @@ export class MenuComponent implements OnInit { // this._helpContentService.savePage(this.pageForm.value, this.properties.adminToolsAPIURL).subscribe( // page => { // this.allPages.push({value: page.route, label: page.name}); - // UIkit.notification('Page ' + page.name + ' has been successfully created', { - // status: 'success', - // timeout: 6000, - // pos: 'bottom-right' - // }); + // NotificationHandler.rise('Page ' + page.name + ' has been successfully created'); // this.newPageWindowOpen = !this.newPageWindowOpen; // this.menuItemForm.get('route').setValue(page.route); // this.menuItemForm.get('route').markAsDirty(); diff --git a/services/help-content.service.ts b/services/help-content.service.ts index b952a9ec..27865e6d 100644 --- a/services/help-content.service.ts +++ b/services/help-content.service.ts @@ -349,6 +349,11 @@ export class HelpContentService { return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/toggle?status=" + status + "&featured=" + isFeatured, {}, CustomOptions.getAuthOptionsWithBody()) .pipe(catchError(this.handleError)); } + + alignMenu(alignment: string, portalPid: string) { + return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/align?alignment=" + alignment, {}, CustomOptions.getAuthOptionsWithBody()) + .pipe(catchError(this.handleError)); + } // unused diff --git a/sharedComponents/menu.ts b/sharedComponents/menu.ts index 000f05a5..fc186356 100644 --- a/sharedComponents/menu.ts +++ b/sharedComponents/menu.ts @@ -76,6 +76,7 @@ export class Menu { portalPid: string; isFeaturedMenuEnabled: boolean; isMenuEnabled: boolean; + featuredAlignment: MenuAlignment; featuredMenuItems: MenuItemExtended[] = []; menuItems: MenuItemExtended[] = []; } @@ -83,3 +84,5 @@ export class Menu { export class SideMenuItem extends MenuItem { ukIcon: string = ''; } + +export enum MenuAlignment {LEFT="LEFT", CENTER="CENTER", RIGHT="RIGHT"} \ No newline at end of file diff --git a/utils/entities/CuratorInfo.ts b/utils/entities/CuratorInfo.ts index bffc50db..06e8af39 100644 --- a/utils/entities/CuratorInfo.ts +++ b/utils/entities/CuratorInfo.ts @@ -6,6 +6,7 @@ export class Curator { affiliations: Affiliation[]; photo: string; bio: string; + visible: boolean = true; } export class Affiliation {