finish menu items for non-admins
This commit is contained in:
parent
5bbbc4e708
commit
e81b3bdc72
|
@ -9,7 +9,7 @@
|
|||
<h1 class="uk-h4 uk-margin-remove">{{name?name:'Super Admin'}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<admin-tabs tab="entity" [portal]="portal"></admin-tabs>
|
||||
<admin-tabs tab="entity" [portal]="portal" [type]="type"></admin-tabs>
|
||||
<ul *ngIf="!isPortalAdministrator" class="uk-subnav uk-subnav-pill uk-margin-medium-top">
|
||||
<li [class.uk-active]="filterForm.get('status').value === 'all'"><a
|
||||
(click)="filterForm.get('status').setValue('all')"><span
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div page-content (stickyEmitter)="stickyPageHeader = $event">
|
||||
<div page-content>
|
||||
<div header>
|
||||
<div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
|
||||
<div class="uk-flex uk-flex-middle uk-margin-top info">
|
||||
<ng-container *ngIf="showLogo">
|
||||
<img [src]="entity | logoUrl" class="uk-margin-right uk-blend-multiply">
|
||||
</ng-container>
|
||||
|
@ -13,85 +13,27 @@
|
|||
<admin-tabs tab="menu" [portal]="portal" [type]="type"></admin-tabs>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div header>
|
||||
<admin-tabs tab="menu" [portal]="portal"></admin-tabs>
|
||||
<div *ngIf="!showLoading" class="uk-grid" uk-grid>
|
||||
<div class="uk-width-1-1">
|
||||
<ul *ngIf="!isPortalAdministrator" class="uk-subnav uk-subnav-pill uk-flex uk-flex-middle">
|
||||
<li *ngFor="let item of rootMenuItems; let i=index" [class.uk-active]="activeRootMenuId==item['_id']"
|
||||
class="uk-visible-toggle uk-position-relative uk-padding-remove-horizontal">
|
||||
<span>
|
||||
<a (click)="changeActiveRootMenuItem(item)">
|
||||
<span class="title">{{item.title}}</span>
|
||||
</a>
|
||||
<span class="uk-invisible-hover uk-position-center-right">
|
||||
<a class="uk-link-reset">
|
||||
<icon [flex]="true" name="more_vert"></icon>
|
||||
</a>
|
||||
<div class="uk-dropdown" uk-dropdown="mode: click; pos: bottom-right; offset: 20; delay-hide: 0; flip: false">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li (click)="editMenuItem(item, false)">
|
||||
<a>Edit</a>
|
||||
</li>
|
||||
<hr class="uk-nav-divider">
|
||||
<li (click)="confirmDeleteMenuItem(item._id, false)">
|
||||
<a>Delete</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
<li (click)="newMenuItem(false)" class="uk-visible-toggle">
|
||||
<span class="clickable">
|
||||
<span class="uk-icon-button small portal-icon-button">
|
||||
<icon name="add"></icon>
|
||||
</span>
|
||||
<span class="space" [class.uk-hidden-hover]="rootMenuItems.length != 0">
|
||||
Create new root menu
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="!activeRootMenu.isFeatured"
|
||||
class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid uk-margin-remove-top"
|
||||
uk-grid>
|
||||
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false"
|
||||
placeholder="Search menu item"
|
||||
[selected]="selectedKeyword" (closeEmitter)="onSearchClose()" (resetEmitter)="reset()"
|
||||
[bordered]="true" colorClass="uk-text-secondary"
|
||||
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
|
||||
<div>
|
||||
<a (click)="newMenuItem(true)" class="uk-flex uk-flex-middle uk-text-uppercase">
|
||||
<button class="large uk-icon-button uk-button-secondary">
|
||||
<icon name="add"></icon>
|
||||
</button>
|
||||
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">
|
||||
Add new menu item
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div inner>
|
||||
<div class="uk-flex uk-flex-between@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid
|
||||
[class]="isPortalAdministrator ? 'uk-flex-between@m':'uk-flex-right@m'">
|
||||
<div>
|
||||
<div input inputClass="border-bottom" type="select" [options]="menuTypes" [(value)]="selectedMenuType"
|
||||
*ngIf="isPortalAdministrator"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
|
||||
[disabled]="showLoading" [class.uk-disabled]="showLoading"
|
||||
(click)="newMenuItem()"
|
||||
uk-tooltip="title:<div>?</div>">
|
||||
<icon name="add" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">New Menu Item</span>
|
||||
</button>
|
||||
<div actions>
|
||||
<div class="uk-section-xsmall">
|
||||
<div class="uk-flex uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid
|
||||
[class]="isPortalAdministrator ? 'uk-flex-between@m':'uk-flex-right@m'">
|
||||
<div>
|
||||
<div input inputClass="border-bottom" type="select" [options]="menuTypes" [(value)]="selectedMenuType"
|
||||
*ngIf="isPortalAdministrator"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
|
||||
[disabled]="showLoading" [class.uk-disabled]="showLoading"
|
||||
(click)="newMenuItem()"
|
||||
uk-tooltip="title:<div><div class='uk-margin-small-bottom uk-text-bold'>Add new menu item</div><div>Creating a menu item for your customized navigation bar.</div><div>Menu items can be either linked to an existing page or to an external link.</div></div>">
|
||||
<icon name="add" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">New Menu Item</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div inner>
|
||||
<div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
|
||||
<div *ngIf="showLoading" class="uk-position-center">
|
||||
<loading></loading>
|
||||
|
@ -122,6 +64,9 @@
|
|||
<div>
|
||||
{{item.type == 'external' ? item.url : item.route}}
|
||||
</div>
|
||||
<div *ngIf="item.type == 'internal' && item.route && pageStatus != null && !pageStatus.get(item.route)" class="uk-text-small uk-text-warning uk-margin-small-top">
|
||||
This menu item is not visible because the page is disabled
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-flex uk-flex-middle uk-flex-center">
|
||||
<button class="uk-button uk-button-link uk-flex uk-flex-middle uk-margin-medium-right" (click)="editMenuItem(i, item, false)">
|
||||
|
@ -141,14 +86,14 @@
|
|||
(click)="moveElement(i)">
|
||||
<div class="uk-flex uk-flex-middle">
|
||||
<icon name="north" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">One up</span>
|
||||
<span class="uk-margin-xsmall-left">Up</span>
|
||||
</div>
|
||||
</a>
|
||||
<a *ngIf="i != (displayMenuItems.length - 1)" class="uk-link uk-link-text"
|
||||
(click)="moveElement(i, i + 1)">
|
||||
<div class="uk-flex uk-flex-middle">
|
||||
<icon name="south" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">One down</span>
|
||||
<span class="uk-margin-xsmall-left">Down</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -196,13 +141,13 @@
|
|||
<a *ngIf="j != 0" class="uk-link uk-link-text uk-margin-right">
|
||||
<div class="uk-flex uk-flex-middle">
|
||||
<icon name="north" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">One up</span>
|
||||
<span class="uk-margin-xsmall-left">Up</span>
|
||||
</div>
|
||||
</a>
|
||||
<a *ngIf="j != (item.items.length - 1)" class="uk-link uk-link-text">
|
||||
<div class="uk-flex uk-flex-middle">
|
||||
<icon name="south" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">One down</span>
|
||||
<span class="uk-margin-xsmall-left">Down</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -212,64 +157,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <ul *ngIf='activeRootMenuId' class="uk-list submenu-items">
|
||||
<li *ngFor="let child of childrenMenuItems" class="uk-card uk-card-default uk-margin-bottom">
|
||||
<div class="uk-grid uk-grid-divider uk-padding" uk-grid>
|
||||
<div class="uk-width-4-5">
|
||||
<div class="uk-grid uk-flex uk-flex-middle">
|
||||
<div class="uk-width-expand uk-margin-medium-bottom">
|
||||
{{child.title}}
|
||||
</div>
|
||||
<div *ngIf="child.url && child.type == 'external'" class="uk-grid uk-width-1-1 uk-margin-left">
|
||||
<span class="title uk-padding-remove">URL: </span><a href="{{child.url}}" target="_blank"
|
||||
class="uk-padding-remove uk-margin-left">{{child.url}}</a>
|
||||
</div>
|
||||
<div *ngIf="child.route && child.type == 'internal'" class="uk-grid uk-width-1-1 uk-margin-left">
|
||||
<span class="title uk-padding-remove">Route: </span><span
|
||||
class="uk-padding-remove uk-margin-left">{{child.route}}</span>
|
||||
</div>
|
||||
<div *ngIf="(menuRouteStatus != null && !menuRouteStatus.get(child._id) && child.type == 'internal')" class="uk-grid uk-width-1-1 uk-margin-left">
|
||||
<span class="uk-padding-remove uk-text-warning">The item is not used either because the required page does not exist or it is disabled</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-1-5">
|
||||
<div class="uk-flex uk-flex-center uk-flex-column uk-height-1-1">
|
||||
<div class="uk-flex uk-flex-center">
|
||||
<div class="actions">
|
||||
<button class="uk-button uk-button-secondary uk-margin-top uk-flex uk-flex-middle"
|
||||
(click)="editMenuItem(child, true)">
|
||||
<icon name="edit" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left"> Edit</span>
|
||||
</button>
|
||||
<button class="uk-button uk-button-danger uk-margin-top uk-flex uk-flex-middle"
|
||||
(click)="confirmDeleteMenuItem(child._id, true)">
|
||||
<icon name="delete" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left"> Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul> -->
|
||||
|
||||
<!-- TODO: new error conditions -->
|
||||
<!-- <div *ngIf="childrenMenuItems.length == 0 && !activeRootMenu.isFeatured"
|
||||
<div *ngIf="displayMenuItems && displayMenuItems.length == 0"
|
||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||
<div>No menu items found</div>
|
||||
</div>
|
||||
<div *ngIf="activeRootMenu.isFeatured"
|
||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||
<div>Featured menu items can't have any sub menu items</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<modal-alert #editModal (alertOutput)="menuItemSaveConfirmed($event)"
|
||||
[okDisabled]="menuItemForm && (menuItemForm.invalid || !menuItemForm.dirty)" classTitle="uk-background-primary uk-light">
|
||||
[okDisabled]="menuItemForm && (menuItemForm.invalid || !menuItemForm.dirty)" classTitle="uk-background-primary uk-light">
|
||||
<form *ngIf="menuItemForm" [formGroup]="menuItemForm" class="uk grid uk-child-width-1-1" uk-grid>
|
||||
<div input [formInput]="menuItemForm.get('title')" type="text"
|
||||
placeholder="Name"></div>
|
||||
|
@ -289,32 +186,14 @@
|
|||
type="autocomplete" label="Page" placeholder="Search all pages" [options]="allPages"
|
||||
[showOptionsOnEmpty]="false" class="uk-margin-bottom">
|
||||
</div>
|
||||
<div *ngIf="(menuRouteStatus != null && !menuRouteStatus.get(menuItemForm.get('_id').value) && !menuItemForm.get('route').dirty)" class="uk-text-center">
|
||||
<span class="uk-text-warning">The item is not used either because the required page does not exist or it is disabled</span>
|
||||
<div *ngIf="pageStatus != null && !pageStatus.get(menuItemForm.get('route').value) && menuItemForm.get('route').dirty" class="uk-text-center">
|
||||
<span class="uk-text-warning">The item is not used because the required page is disabled</span>
|
||||
</div>
|
||||
<!-- <div class="uk-text-center uk-margin-top">Or <a (click)="newPageWindow()">create a new one</a></div>
|
||||
<div *ngIf="newPageWindowOpen" class="uk-card uk-card-default uk-card-body uk-margin-top">
|
||||
<div>
|
||||
<button (click)="newPageWindow()" class="uk-close uk-icon uk-float-right" uk-close></button>
|
||||
<h6 class="uk-text-bold uk-margin-remove-top">Create New Page</h6>
|
||||
</div>
|
||||
<form *ngIf="pageForm" [formGroup]="pageForm" class="uk grid uk-child-width-1-1" uk-grid>
|
||||
<div input [formInput]="pageForm.get('name')" type="text" label="Name"
|
||||
placeholder="Name"></div>
|
||||
<div input [formInput]="pageForm.get('route')" type="text"
|
||||
placeholder="Route"></div>
|
||||
<div class="uk-flex uk-flex-right">
|
||||
<button [disabled]="!(pageForm.get('name').value && pageForm.get('route').value)"
|
||||
class="uk-button uk-button-secondary outlined" (click)="createPage()">Create Page
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="uk-flex" *ngIf="isPortalAdministrator">
|
||||
<div class="uk-form-label uk-margin-small-right">Featured</div>
|
||||
<mat-slide-toggle [formControl]="menuItemForm.get('isFeatured')"
|
||||
uk-tooltip="title:<div class='uk-width-large'><div class='uk-text-bold '>Enable this to show your custom menu item in the community-specific navigation bar.</div><div class=' uk-margin-top'>If disabled, your custom menu item will appear in the default navigation bar.</div><div class=' uk-margin-top'>*Note that featured menu items can't have any children menu items(as a dropdown).</div></div>">
|
||||
uk-tooltip="title:<div class='uk-width-large'><div class='uk-text-bold '>Enable this to show your custom menu item in the community-specific navigation bar.</div><div class=' uk-margin-top'>If disabled, your custom menu item will appear in the default navigation bar.</div><div class=' uk-margin-top'>*Note that featured menu items can't have any children menu items(as a dropdown).</div></div>">
|
||||
</mat-slide-toggle>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Component, ElementRef, OnInit, ViewChild, Input} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {HelpContentService} from '../../services/help-content.service';
|
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {Portal} from '../../utils/entities/adminTool/portal';
|
||||
|
@ -13,7 +13,6 @@ import {Title} from "@angular/platform-browser";
|
|||
import {AlertModal} from '../../utils/modal/alert';
|
||||
import {MenuItem} from '../../sharedComponents/menu';
|
||||
import {SearchInputComponent} from '../../sharedComponents/search-input/search-input.component';
|
||||
import {Page} from '../../utils/entities/adminTool/page';
|
||||
import {Option} from '../../sharedComponents/input/input.component';
|
||||
import {CommunityInfo} from '../../connect/community/communityInfo';
|
||||
import {Stakeholder} from '../../monitor/entities/stakeholder';
|
||||
|
@ -22,13 +21,7 @@ import {CommunityService} from '../../connect/community/community.service';
|
|||
import {ClearCacheService} from '../../services/clear-cache.service';
|
||||
import {TransitionGroupComponent} from '../../utils/transition-group/transition-group.component';
|
||||
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
export class MenuItemExtended extends MenuItem {
|
||||
isOpen: boolean = false;
|
||||
parentItemId: string;
|
||||
}
|
||||
import {NotificationHandler} from '../../utils/notification-handler';
|
||||
|
||||
@Component({
|
||||
selector: 'menuSelector',
|
||||
|
@ -42,12 +35,9 @@ export class MenuComponent implements OnInit {
|
|||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
@ViewChild("elements") elements: TransitionGroupComponent;
|
||||
|
||||
public activeRootMenuId: string;
|
||||
public activeRootMenu: MenuItem;
|
||||
public childrenMenuItems: MenuItem[] = [];
|
||||
|
||||
private index: number;
|
||||
public elementIndex: number;
|
||||
|
||||
public activeRootMenuId: string;
|
||||
|
||||
public menuItemForm: FormGroup;
|
||||
public pageForm: FormGroup;
|
||||
|
@ -60,7 +50,7 @@ export class MenuComponent implements OnInit {
|
|||
public normalMenuItems = [];
|
||||
public featuredMenuItems = [];
|
||||
public allPages = [];
|
||||
public menuRouteStatus: Map<string,boolean> = null;
|
||||
public pageStatus: Map<string,boolean> = null;
|
||||
|
||||
public selectedMenuItem: string;
|
||||
public isChild: boolean = false;
|
||||
|
@ -72,7 +62,6 @@ export class MenuComponent implements OnInit {
|
|||
public showLogo: boolean = true;
|
||||
public type: string;
|
||||
|
||||
// public newPageWindowOpen: boolean = false;
|
||||
public showLoading = true;
|
||||
public isPortalAdministrator = null;
|
||||
public filterForm: FormGroup;
|
||||
|
@ -84,17 +73,12 @@ export class MenuComponent implements OnInit {
|
|||
{label: 'No Action', value: 'noAction'}
|
||||
]
|
||||
|
||||
public keyword: string = '';
|
||||
public selectedKeyword: string = '';
|
||||
private searchText: string = '';
|
||||
|
||||
public properties: EnvProperties = properties;
|
||||
private subscriptions: any[] = [];
|
||||
private typeSub: Subscription = null;
|
||||
public stickyPageHeader: boolean = false;
|
||||
|
||||
constructor(private element: ElementRef, private route: ActivatedRoute,
|
||||
private _router: Router, private title: Title,
|
||||
constructor(private route: ActivatedRoute,
|
||||
private title: Title,
|
||||
private _helpContentService: HelpContentService,
|
||||
private userManagementService: UserManagementService, private _fb: FormBuilder,
|
||||
private stakeholderService: StakeholderService,
|
||||
|
@ -103,13 +87,6 @@ export class MenuComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.filterForm = this._fb.group({
|
||||
keyword: [''],
|
||||
});
|
||||
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
||||
this.searchText = value.toLowerCase();
|
||||
// this.applyFilters();
|
||||
}));
|
||||
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();
|
||||
|
@ -167,26 +144,12 @@ export class MenuComponent implements OnInit {
|
|||
data => {
|
||||
this.featuredMenuItems = data['featuredMenuItems'];
|
||||
this.normalMenuItems = data['menuItems'];
|
||||
// console.log(this.normalMenuItems);
|
||||
// console.log(this.featuredMenuItems);
|
||||
// this.rootMenuItems = data;
|
||||
// this.rootMenuItems.forEach(item => {
|
||||
// if(item.isFeatured) {
|
||||
// this.featuredMenuItems.push(item);
|
||||
// } else {
|
||||
// this.normalMenuItems.push(item);
|
||||
// }
|
||||
// });
|
||||
// if(data && data.length > 0) {
|
||||
// this.changeActiveRootMenuItem(data[0]);
|
||||
// }
|
||||
this.getPages();
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError("Server error fetching menu items", error)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
getTypeOptions(isFeatured: boolean = false) {
|
||||
|
@ -201,38 +164,16 @@ export class MenuComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
// getActiveRootItem(id: string): MenuItem {
|
||||
// return this.rootMenuItems.find(element => element['_id'] == id);
|
||||
// }
|
||||
|
||||
// changeActiveRootMenuItem(item: MenuItem) {
|
||||
// this.activeRootMenuId = item['_id'];
|
||||
// this.activeRootMenu = item;
|
||||
// this.childrenMenuItems = item.items;
|
||||
// this.applyFilters();
|
||||
// }
|
||||
|
||||
getPages() {
|
||||
this.subscriptions.push(
|
||||
this._helpContentService.getCommunityPagesByType(this.portal, '', this.properties.adminToolsAPIURL).subscribe(
|
||||
data => {
|
||||
let pages = data;
|
||||
this.allPages = [];
|
||||
this.menuRouteStatus = new Map();
|
||||
this.pageStatus = 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 + (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);
|
||||
}
|
||||
}
|
||||
})
|
||||
this.pageStatus.set(pages[i].route, pages[i].isEnabled);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -241,49 +182,6 @@ export class MenuComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
// public newPageWindow() {
|
||||
// this.newPageWindowOpen = !this.newPageWindowOpen;
|
||||
// this.pageForm = this._fb.group({
|
||||
// _id: this._fb.control(null),
|
||||
// route: this._fb.control('', [Validators.required, StringUtils.validRoute(this.allPages, 'value')]),
|
||||
// name: this._fb.control('', Validators.required),
|
||||
// isEnabled: this._fb.control(true),
|
||||
// portalType: this._fb.control(this.properties.adminToolsPortalType, Validators.required),
|
||||
// portalPid: this._fb.control(this.portal),
|
||||
// top: this._fb.control(true),
|
||||
// bottom: this._fb.control(false),
|
||||
// left: this._fb.control(false),
|
||||
// right: this._fb.control(false),
|
||||
// type: this._fb.control('html', Validators.required),
|
||||
// entities: this._fb.control([''])
|
||||
// });
|
||||
// }
|
||||
|
||||
// public createPage() {
|
||||
// if(!this.pageForm.value.route.startsWith('/')) {
|
||||
// this.pageForm.value.route = '/'.concat(this.pageForm.value.route);
|
||||
// }
|
||||
// this.showLoading = true;
|
||||
// this.subscriptions.push(
|
||||
// this._helpContentService.savePage(<Page>this.pageForm.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
// page => {
|
||||
// this.allPages.push({value: page.route, label: page.name});
|
||||
// UIkit.notification('Page <b>' + page.name + '</b> has been <b>successfully created</b>', {
|
||||
// status: 'success',
|
||||
// timeout: 6000,
|
||||
// pos: 'bottom-right'
|
||||
// });
|
||||
// this.newPageWindowOpen = !this.newPageWindowOpen;
|
||||
// this.menuItemForm.get('route').setValue(page.route);
|
||||
// this.menuItemForm.get('route').markAsDirty();
|
||||
// this.showLoading = false;
|
||||
// this._clearCacheService.clearCache("Page saved");
|
||||
// },
|
||||
// error => this.handleError('System error creating page', error)
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
addValidatorForUrlOrRoute() {
|
||||
this.destroyTypeSubscription();
|
||||
this.typeSub = this.menuItemForm.get('type').valueChanges.subscribe(value => {
|
||||
|
@ -329,11 +227,6 @@ export class MenuComponent implements OnInit {
|
|||
});
|
||||
this.isChild = isChild;
|
||||
this.index = index;
|
||||
// if(this.isChild) {
|
||||
// this.index = this.getActiveRootItem(this.activeRootMenuId).items.findIndex(value => value._id === menuItem['_id']);
|
||||
// } else {
|
||||
// this.index = this.rootMenuItems.findIndex(value => value._id === menuItem['_id']);
|
||||
// }
|
||||
this.addValidatorForUrlOrRoute();
|
||||
this.menuItemsModalOpen('Edit Menu Item', 'Save Changes');
|
||||
}
|
||||
|
@ -357,11 +250,7 @@ export class MenuComponent implements OnInit {
|
|||
this._helpContentService.deleteMenuItem(this.selectedMenuItem, this.portal).subscribe(
|
||||
_ => {
|
||||
this.deleteMenuItemFromArray(this.selectedMenuItem, this.isChild);
|
||||
UIkit.notification('Menu item have been <b>successfully deleted</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise("Menu item have been <b>successfully deleted</b>");
|
||||
this.showLoading = false;
|
||||
this._clearCacheService.clearCache("Menu item deleted");
|
||||
},
|
||||
|
@ -371,8 +260,6 @@ export class MenuComponent implements OnInit {
|
|||
}
|
||||
|
||||
private deleteMenuItemFromArray(id: string, isChild: boolean = false) {
|
||||
console.log('isChild', isChild);
|
||||
console.log(this.selectedMenuType);
|
||||
if(isChild) {
|
||||
// let i = this.getActiveRootItem(this.activeRootMenuId).items.findIndex(_ => _._id == id);
|
||||
// this.getActiveRootItem(this.activeRootMenuId).items.splice(i, 1);
|
||||
|
@ -380,20 +267,11 @@ export class MenuComponent implements OnInit {
|
|||
if(this.selectedMenuType == 'customMenu') {
|
||||
let i = this.featuredMenuItems.findIndex(_ => _._id == id);
|
||||
this.featuredMenuItems.splice(i, 1);
|
||||
console.log(i);
|
||||
console.log(id);
|
||||
} else {
|
||||
let i = this.normalMenuItems.findIndex(_ => _._id == id);
|
||||
this.normalMenuItems.splice(i, 1);
|
||||
}
|
||||
// let i = this.rootMenuItems.findIndex(_ => _._id == id);
|
||||
// this.rootMenuItems.splice(i, 1);
|
||||
// this.changeActiveRootMenuItem(this.rootMenuItems[0]);
|
||||
}
|
||||
// if(this.menuRouteStatus != null) {
|
||||
// this.menuRouteStatus.delete(id);
|
||||
// }
|
||||
// this.applyFilters();
|
||||
}
|
||||
|
||||
private menuItemsModalOpen(title: string, yesBtn: string) {
|
||||
|
@ -412,11 +290,7 @@ export class MenuComponent implements OnInit {
|
|||
this._helpContentService.saveMenuItem(<MenuItem>this.menuItemForm.value, this.portal).subscribe(
|
||||
menuItem => {
|
||||
this.menuItemSavedSuccessfully(menuItem, true);
|
||||
UIkit.notification('Menu item <b>' + menuItem.title + '</b> has been <b>successfully created</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise('Menu item <b>' + menuItem.title + '</b> has been <b>successfully created</b>');
|
||||
this._clearCacheService.clearCache("Menu item saved");
|
||||
},
|
||||
error => this.handleError("System error creating menu item", error)
|
||||
|
@ -427,11 +301,7 @@ export class MenuComponent implements OnInit {
|
|||
this._helpContentService.updateMenuItem(<MenuItem>this.menuItemForm.value, this.portal).subscribe(
|
||||
menuItem => {
|
||||
this.menuItemSavedSuccessfully(menuItem, false);
|
||||
UIkit.notification('Menu item <b>' + menuItem.title + '</b> has been <b>successfully updated</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise('Menu item <b>' + menuItem.title + '</b> has been <b>successfully updated</b>');
|
||||
this._clearCacheService.clearCache("Menu item updated");
|
||||
},
|
||||
error => this.handleError("System error updating menu item", error)
|
||||
|
@ -450,7 +320,6 @@ export class MenuComponent implements OnInit {
|
|||
} else {
|
||||
this.normalMenuItems.push(menuItem);
|
||||
}
|
||||
// this.rootMenuItems.push(menuItem);
|
||||
}
|
||||
} else {
|
||||
if(menuItem['parentItemId']) {
|
||||
|
@ -461,42 +330,17 @@ export class MenuComponent implements OnInit {
|
|||
} else {
|
||||
this.normalMenuItems[this.index] = menuItem;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
handleError(message: string, error) {
|
||||
UIkit.notification(message, {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
console.log('Server responded: ' + error);
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
// public applyFilters() {
|
||||
// this.childrenMenuItems = this.activeRootMenu.items.filter(item => item.title.toLowerCase().includes(this.searchText) || (item.url||'').toLowerCase().includes(this.searchText) || (item.route||'').toLowerCase().includes(this.searchText));
|
||||
// }
|
||||
|
||||
public onSearchClose() {
|
||||
this.selectedKeyword = this.filterForm.get('keyword').value;
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.selectedKeyword = null;
|
||||
this.searchInputComponent.reset();
|
||||
}
|
||||
|
||||
public toggleMenuItem(menuItem) {
|
||||
menuItem.isOpen = !menuItem.isOpen;
|
||||
}
|
||||
|
@ -508,15 +352,23 @@ export class MenuComponent implements OnInit {
|
|||
public moveElement(index: number, newIndex: number = index -1) {
|
||||
this.elements.init();
|
||||
if(this.selectedMenuType == 'customMenu') {
|
||||
HelperFunctions.swap(this.featuredMenuItems, index, newIndex);
|
||||
this._helpContentService.reorderMenuItems(this.featuredMenuItems, this.portal).subscribe(() => {
|
||||
let temp = HelperFunctions.copy(this.featuredMenuItems);
|
||||
HelperFunctions.swap(temp, index, newIndex);
|
||||
this._helpContentService.reorderMenuItems(temp, this.portal).subscribe(() => {
|
||||
HelperFunctions.swap(this.featuredMenuItems, index, newIndex);
|
||||
if(this.elementIndex === index) {
|
||||
this.elementIndex = newIndex;
|
||||
}
|
||||
})
|
||||
this._clearCacheService.clearCache("Menu items reordered");
|
||||
}, error => {
|
||||
this.handleError("System error reordering menu items", error);
|
||||
});
|
||||
} else {
|
||||
HelperFunctions.swap(this.normalMenuItems, index, newIndex);
|
||||
let temp = HelperFunctions.copy(this.normalMenuItems);
|
||||
HelperFunctions.swap(temp, index, newIndex);
|
||||
this._helpContentService.reorderMenuItems(temp, this.portal).subscribe(() => {
|
||||
HelperFunctions.swap(this.normalMenuItems, index, newIndex);
|
||||
this._clearCacheService.clearCache("Menu items reordered");
|
||||
}, error => {
|
||||
this.handleError("System error reordering menu items", error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,7 @@ import {StatisticsDisplay, StatisticsSummary} from '../connect/statistics/statis
|
|||
import {CustomOptions} from './servicesUtils/customOptions.class';
|
||||
import {catchError, map} from "rxjs/operators";
|
||||
import {properties} from "../../../environments/environment";
|
||||
import {MenuItem} from '../sharedComponents/menu';
|
||||
import {MenuItemExtended} from '../dashboard/menu/menu.component';
|
||||
import {MenuItem, MenuItemExtended} from '../sharedComponents/menu';
|
||||
|
||||
@Injectable()
|
||||
export class HelpContentService {
|
||||
|
|
|
@ -3,7 +3,6 @@ export interface Icon {
|
|||
svg?: string,
|
||||
class?: string
|
||||
}
|
||||
|
||||
export class MenuItem {
|
||||
_id: string = ""; // for root menu in order to close the dropdown when clicked
|
||||
title: string = "";
|
||||
|
@ -68,6 +67,10 @@ export class MenuItem {
|
|||
|
||||
|
||||
}
|
||||
export class MenuItemExtended extends MenuItem {
|
||||
isOpen: boolean = false;
|
||||
parentItemId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
|
|
Loading…
Reference in New Issue