From 00db2024b87d2e8c1f5c64380f0102d1136b39cf Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 13 Jan 2022 16:47:33 +0200 Subject: [PATCH 1/2] fixing type autocomplete --- .../ISVocabularies.service.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/utils/staticAutoComplete/ISVocabularies.service.ts b/utils/staticAutoComplete/ISVocabularies.service.ts index bae49d72..98581d05 100644 --- a/utils/staticAutoComplete/ISVocabularies.service.ts +++ b/utils/staticAutoComplete/ISVocabularies.service.ts @@ -50,8 +50,7 @@ export class ISVocabulariesService { } else if (field == "type" && (entity == "software" || entity == "other")) { return of([]); } else if (field == "type" && entity == "result" ) { - //return Observable.zip(this.getVocabularyFromService("dnet:publication_resource.json", properties),this.getVocabularyFromService("dnet:dataCite_resource.json", properties)); - return zip(from(this.getVocabularyFromServiceAsync("dnet:publication_resource.json", properties)),from(this.getVocabularyFromServiceAsync("dnet:dataCite_resource.json", properties))); + return zip(this.getVocabularyFromService("dnet:publication_resource.json", properties),this.getVocabularyFromService("dnet:dataCite_resource.json", properties)); } else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other" || entity == "result")) { // file= "accessMode.json"; // return this.getVocabularyFromFile(file); @@ -64,24 +63,24 @@ export class ISVocabulariesService { vocabulary = "dnet:datasource_typologies.json"; //return this.getVocabularyFromService(vocabulary, properties); return from(this.getVocabularyFromServiceAsync(vocabulary, properties)); - + } else if (field == "compatibility" && (entity == "dataprovider")) { // file = "dataProviderCompatibility.json"; // return this.getVocabularyFromFile(file); vocabulary = "dnet:datasourceCompatibilityLevel.json"; //return this.getVocabularyFromService(vocabulary, properties); return from(this.getVocabularyFromServiceAsync(vocabulary, properties)); - + } else if (field == "country") { // file = "countries.json"; // return this.getVocabularyFromFile(file); vocabulary = "dnet:countries.json"; //return this.getVocabularyFromService(vocabulary, properties); return from(this.getVocabularyFromServiceAsync(vocabulary, properties)); - + } return null; - + } async getVocabularyFromServiceAsync(vocabularyName: string, properties: EnvProperties): Promise { @@ -112,9 +111,9 @@ export class ISVocabulariesService { .pipe(map(res => res['terms'])) .pipe(map(res => this.parse(res, vocabularyName))) .pipe(catchError(this.handleError)); - + } - + parse(data: any, vocabularyName: string): AutoCompleteValue[] { var array: AutoCompleteValue[] = [] for (var i = 0; i < data.length; i++) { @@ -126,9 +125,9 @@ export class ISVocabulariesService { value.label = data[i].englishName; array.push(value); } - + return array; - + } getProvenanceActionVocabulary(properties: EnvProperties): Observable { From 3228c67a14ecaf0a0434871f1aabf728ac923d31 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Fri, 14 Jan 2022 15:55:24 +0200 Subject: [PATCH 2/2] add warnings for disabled pages/routes on the menu items - dev only --- dashboard/menu/menu.component.html | 8 ++++- dashboard/menu/menu.component.ts | 35 ++++++++++++++++----- dashboard/page/pages.component.ts | 7 ++--- sharedComponents/navigationBar.component.ts | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/dashboard/menu/menu.component.html b/dashboard/menu/menu.component.html index f7d949f5..fbc71e1e 100644 --- a/dashboard/menu/menu.component.html +++ b/dashboard/menu/menu.component.html @@ -80,6 +80,9 @@ Route: {{child.route}} +
+ The item is not used either because the required page does not exist or it is disabled +
@@ -125,8 +128,11 @@
Select one of the pages
+ [showOptionsOnEmpty]="false" class="uk-margin-bottom">
+
+ The item is not used either because the required page does not exist or it is disabled +
diff --git a/dashboard/menu/menu.component.ts b/dashboard/menu/menu.component.ts index 412189c7..cdedb37e 100644 --- a/dashboard/menu/menu.component.ts +++ b/dashboard/menu/menu.component.ts @@ -43,6 +43,7 @@ export class MenuComponent implements OnInit { public pageForm: FormGroup; public rootMenuItems = []; public allPages = []; + public menuRouteStatus: Map = null; public selectedMenuItem: string; public isChild: boolean = false; @@ -86,6 +87,7 @@ export class MenuComponent implements OnInit { })); this.userManagementService.getUserInfo().subscribe(user => { this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; + this.getMenuItems(); if (this.route.snapshot.data.portal) { this.title.setTitle(StringUtils.capitalize(this.portal) + ' | Menu'); } else if (this.route.snapshot.params[this.route.snapshot.data.param]) { @@ -95,9 +97,6 @@ export class MenuComponent implements OnInit { } this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal; }); - this.showLoading = false; - this.getMenuItems(); - this.getPages(); } ngOnDestroy(): void { @@ -125,8 +124,9 @@ export class MenuComponent implements OnInit { if(data && data.length > 0) { this.changeActiveRootMenuItem(data[0]); } + this.getPages(); + this.showLoading = false; }, - // err => console.error("Server error fetching menu items: ", err) error => this.handleError("Server error fetching menu items", error) ) ); @@ -145,7 +145,7 @@ export class MenuComponent implements OnInit { } changeActiveRootMenuItem(item: MenuItem) { - this.activeRootMenuId = item['_id'] + this.activeRootMenuId = item['_id']; this.activeRootMenu = item; this.childrenMenuItems = item.items; this.applyFilters(); @@ -153,13 +153,25 @@ export class MenuComponent implements OnInit { getPages() { this.subscriptions.push( - this._helpContentService.getAllPages(this.properties.adminToolsAPIURL,this.portal).subscribe( + this._helpContentService.getCommunityPagesByType(this.portal, '', this.properties.adminToolsAPIURL).subscribe( data => { let pages = data; this.allPages = []; + this.menuRouteStatus = new Map(); for(let i = 0; i < pages.length; i++) { if(pages[i] && pages[i].name && pages[i].route) { - this.allPages.push({value: pages[i].route, label: pages[i].name}); + this.allPages.push({value: pages[i].route, label: pages[i].name + (pages[i].isEnabled ? '' : ' [disabled]'), isEnabled: pages[i].isEnabled}); + this.rootMenuItems.forEach(parent => { + if(parent.route == pages[i].route) { + this.menuRouteStatus.set(parent._id, pages[i].isEnabled); + } + if(parent.items) { + const found = parent.items.find(child => child.route == pages[i].route); + if(found) { + this.menuRouteStatus.set(found._id, pages[i].isEnabled); + } + } + }) } } }, @@ -303,6 +315,9 @@ export class MenuComponent implements OnInit { this.rootMenuItems.splice(i, 1); this.changeActiveRootMenuItem(this.rootMenuItems[0]); } + if(this.menuRouteStatus != null) { + this.menuRouteStatus.delete(id); + } this.applyFilters(); } @@ -363,6 +378,12 @@ export class MenuComponent implements OnInit { this.rootMenuItems[this.index] = menuItem; } } + if(this.menuRouteStatus != null) { + const found = this.allPages.find(page => page.route == menuItem.route); + if(found) { + this.menuRouteStatus.set(menuItem._id, found.isEnabled); + } + } this.applyFilters(); this.showLoading = false; } diff --git a/dashboard/page/pages.component.ts b/dashboard/page/pages.component.ts index 59785e37..118f4a85 100644 --- a/dashboard/page/pages.component.ts +++ b/dashboard/page/pages.component.ts @@ -118,7 +118,6 @@ export class PagesComponent implements OnInit { if (this.portal) { this.getPageHelpContentsCounts(this.portal); } - } ngOnDestroy(): void { @@ -242,7 +241,7 @@ export class PagesComponent implements OnInit { this.index = this.pages.findIndex(value => value._id === page._id); this.pageForm = this._fb.group({ _id: this._fb.control(page._id), - route: this._fb.control(page.route, [Validators.required, StringUtils.validRoute(this.pages, 'route', page.route)]), + route: this._fb.control(page.route, Validators.required), name: this._fb.control(page.name, Validators.required), isEnabled: this._fb.control(page.isEnabled), portalType: this._fb.control(page.portalType, Validators.required), @@ -268,7 +267,7 @@ export class PagesComponent implements OnInit { this.entitiesCtrl = this._fb.array([]); this.pageForm = this._fb.group({ _id: this._fb.control(null), - route: this._fb.control('', [Validators.required, StringUtils.validRoute(this.pages, 'route')]), + route: this._fb.control('', Validators.required), name: this._fb.control('', Validators.required), isEnabled: this._fb.control(true), portalType: this._fb.control('', Validators.required), @@ -364,7 +363,7 @@ export class PagesComponent implements OnInit { if (error == null) { // this.formComponent.reset(); this.pageForm = this._fb.group({ - route: this._fb.control('', [Validators.required, StringUtils.validRoute(this.pages, 'route')]), + route: this._fb.control('', Validators.required), name: this._fb.control('', Validators.required), isEnabled: this._fb.control(true), portalType: this._fb.control('', Validators.required), diff --git a/sharedComponents/navigationBar.component.ts b/sharedComponents/navigationBar.component.ts index 2b357877..ee9fad61 100644 --- a/sharedComponents/navigationBar.component.ts +++ b/sharedComponents/navigationBar.component.ts @@ -103,7 +103,7 @@ export class NavigationBarComponent implements OnInit, OnDestroy { this.handleError('Error getting community information (e.g. pages,entities) for community with id: ' + this.communityId, error); })); } - if(this.portal != 'connect') { + if(this.portal != 'connect' && this.portal != 'connect-admin' && this.properties.adminToolsPortalType == 'community') { this.subs.push( this._helpContentService.getMenuItems(this.portal).subscribe( data => {