diff options
author | 2018-01-15 14:31:42 +0200 | |
---|---|---|
committer | 2018-01-16 16:58:47 +0000 | |
commit | 5197c8b7b3cf7576f1198e4b59a7d6484e793107 (patch) | |
tree | 55e938e420d863fac9f1c92901f4e7c2e34787c4 /catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts | |
parent | fd19ae43d9f057f9ce51d48f95ef3f5f60173f22 (diff) |
Designer-view component for top-nav
Create a designer-view component for opening a designer view from the top-nav
Updated the API to return the designers as a list and not as an object
Created a designer-frame component that will get a designer url to open in the dedicated position
Change-Id: Ic42f7695277e88aacdeaa74d4d0f95b49ce44999
Issue-ID: SDC-884
Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts b/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts index f48aa4801f..846b84c69f 100644 --- a/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts +++ b/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts @@ -24,6 +24,7 @@ import {MenuItemGroup, MenuItem} from "app/utils"; import {UserService} from "../../../services/user.service"; import {SdcConfigToken, ISdcConfig} from "../../../config/sdc-config.config"; import {TranslateService} from "../../../shared/translator/translate.service"; +import {DesignersConfiguration, Designer} from "app/models"; declare const window:any; @@ -62,10 +63,20 @@ export class TopNavComponent { let result = -1; //set result to current state - this.topLvlMenu.menuItems.forEach((item:MenuItem, index:number)=> { + this.topLvlMenu.menuItems.every((item:MenuItem, index:number)=> { if (item.state === this.$state.current.name) { - result = index; + if (this.$state.current.name === 'designers') { + const designerIdx = _.findIndex(DesignersConfiguration.designers, (designer: Designer) => designer.designerStateUrl === this.$state.params.path); + if (designerIdx !== -1) { + result = index + designerIdx; + return false; + } + } else { + result = index; + return false; + } } + return true; }); //if it's a different state , checking previous state param @@ -109,6 +120,10 @@ export class TopNavComponent { tmpArray.push(new MenuItem(hostedApp.navTitle, null, hostedApp.defaultState, "goToState", null, null)); } }); + + _.each(DesignersConfiguration.designers, (designer: Designer) => { + tmpArray.push(new MenuItem(designer.displayName, null, "designers", "goToState", {path: designer.designerStateUrl}, null)); + }) } this.topLvlMenu = new MenuItemGroup(0, tmpArray, true); @@ -124,9 +139,9 @@ export class TopNavComponent { } } - goToState(state:string, params:Array<any>):Promise<boolean> { + goToState(state:string, params:any):Promise<boolean> { return new Promise((resolve, reject) => { - this.$state.go(state, params && params.length > 0 ? [0] : undefined); + this.$state.go(state, params || undefined); resolve(true); }); } |