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 => {