{ "version": 3, "sources": ["src/app/shared/layout/header/models/ez-menu-item-separator.ts", "src/app/shared/layout/header/models/ez-router-link-item.ts", "src/app/shared/layout/header/services/dynamic-menu-item.service.ts"], "sourcesContent": ["import { MenuItem } from \"primeng/api\";\n\nexport class EzMenuItemSeparator implements MenuItem {\n constructor(public separator: boolean = true) { }\n}", "import { MenuItem } from \"primeng/api\";\n\nexport class EzRouterLinkMenuItem implements MenuItem {\n constructor(public label?: string, public routerLink?: string, public queryParams?: { [k: string]: any; }) { }\n}\n", "import { Injectable, Type } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { EzStoreService } from '@ezuiaws/ez.ui.packages/ez-store';\n\nimport * as appRouter from '@src/app/state/router-state';\n\nimport { DynamicMenuItem } from '../models/dynamic-menu-item';\nimport { EzMenuItemSeparator } from '../models/ez-menu-item-separator';\nimport { EzRouterLinkMenuItem } from '../models/ez-router-link-item';\nimport { UserSettingsService } from '@app-core/auth/user-settings.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class DynamicMenuItemService {\n\n dynamicItems$: BehaviorSubject = new BehaviorSubject([]);\n\n private _selectedDynamicItem$: BehaviorSubject = new BehaviorSubject(null);\n selectedDynamicItem$: Observable = this._selectedDynamicItem$.asObservable();\n\n constructor(\n private storeHelper: EzStoreService,\n private userSettingsService: UserSettingsService\n ) {\n this.storeHelper.stateStreamSelector(appRouter.getRouterFeatureState)\n .pipe(map(route => route.state.url))\n .subscribe((url: string) => {\n const items: DynamicMenuItem[] = this.getPageDropItems(url);\n this.setMenuItems(items);\n });\n }\n\n addMenuItems(menuItems: DynamicMenuItem[]) {\n const dynamicItems: DynamicMenuItem[] = this.dynamicItems$.getValue();\n\n this.dynamicItems$.next([...dynamicItems, ...menuItems]);\n this.dynamicItems$.getValue().sort(function (a, b) {\n return a.level - b.level;\n });\n }\n\n setMenuItems(menuItems: DynamicMenuItem[]) {\n this.dynamicItems$.next(menuItems);\n }\n\n removeMenuItem(data: DynamicMenuItem) {\n const dynamicItems: DynamicMenuItem[] = this.dynamicItems$.getValue();\n\n dynamicItems.forEach((item, index) => {\n if (item.label == data.label) {\n dynamicItems.splice(index, 1);\n }\n });\n\n this.dynamicItems$.next(dynamicItems);\n }\n\n setDefaultMenuItems() {\n this.dynamicItems$.next(this.getDefaultItems());\n }\n\n private getPageDropItems(url: string): DynamicMenuItem[] {\n // get page specific items for global dropdown.\n let items: DynamicMenuItem[] = this.getDefaultItems();\n let pageItems: DynamicMenuItem[] = [];\n switch (url) {\n case '/clients':\n pageItems = this.getItemsForClientsPage();\n break;\n case '/attendance':\n pageItems = this.getItemsForAttendancePage();\n break;\n case '/locker-rooms':\n pageItems = this.getItemsForLockerRoomsPage();\n break;\n default:\n break;\n }\n // items = [...items, new EzMenuItemSeparator(), ...pageItems, new EzMenuItemSeparator(), ...this.getSubSectionItems()];\n items = [...items, new EzMenuItemSeparator(), ...pageItems];\n return items;\n }\n\n // all code to handle showing side modals works, should just need to un comment\n // to add a new item, implement dynamic menu item component model on the component you need to add and set the side modal id\n\n\n private getItemsForClientsPage() {\n const items = [\n // new EzSideModalMenuItem('Create Group', (event) => this.loadDynamicSideModalItem(NewGroupSideModal, event.item, 'new-group-modal-id')),\n // new EzSideModalMenuItem('Create Lockers', (event) => this.loadDynamicSideModalItem(AddLockerRoomComponent, event.item, 'add-locker-room-modal-id')),\n // new EzSideModalMenuItem('Create Membership Type', (event) => this.loadDynamicSideModalItem(MembershipTypeSideModal, event.item, 'create-membership-type-side-modal')),\n // new EzSideModalMenuItem('Create Membership', (event) => this.loadDynamicSideModalItem(MembershipPlanSideModalComponent, event.item, 'membership-plan-side-modal')),\n // new EzSideModalMenuItem('Sell Membership', (event) => this.loadDynamicSideModalItem(SellMembershipSideModal, event.item, 'sell-membership-side-modal')),\n new EzRouterLinkMenuItem('Locker Rooms', '/locker-rooms')\n ];\n return items;\n }\n\n private getItemsForAttendancePage() {\n const items = [\n // new EzSideModalMenuItem('Create Client', (event) => this.loadDynamicSideModalItem(CreateClientSideModalComponent, event.item, 'create-client-side-modal')),\n // new EzSideModalMenuItem('Create Membership Type', (event) => this.loadDynamicSideModalItem(MembershipTypeSideModal, event.item, 'create-membership-type-side-modal')),\n // new EzSideModalMenuItem('Create Membership', (event) => this.loadDynamicSideModalItem(MembershipPlanSideModalComponent, event.item, 'membership-plan-side-modal')),\n // new EzSideModalMenuItem('Sell Membership', (event) => this.loadDynamicSideModalItem(SellMembershipSideModal, event.item, 'sell-membership-side-modal')),\n // new EzRouterLinkMenuItem('Locker Rooms', '/locker-rooms')\n ];\n return items;\n }\n\n private getItemsForLockerRoomsPage() {\n const items = [\n // new EzSideModalMenuItem('Create Client', (event) => this.loadDynamicSideModalItem(CreateClientComponent, event.item)),\n // new EzSideModalMenuItem('Create Client', (event) => this.loadDynamicSideModalItem(CreateClientSideModalComponent, event.item, 'create-client-side-modal')),\n // new EzCommandMenuItem('Test Command item', () => alert('Test command dynamic menu item!')),\n // new EzSideModalMenuItem('Create Group', (event) => this.loadDynamicSideModalItem(NewGroupSideModal, event.item, 'new-group-modal-id')),\n // new EzRouterLinkMenuItem('Groups', '/groups/groups-list', { 'adjustHeight': true }),\n // new EzSideModalMenuItem('Sell Membership', (event) => this.loadDynamicSideModalItem(SellMembershipSideModal, event.item, 'sell-membership-side-modal')),\n // new EzSideModalMenuItem('Create Membership', (event) => this.loadDynamicSideModalItem(MembershipPlanSideModalComponent, event.item, 'membership-plan-side-modal'))\n ];\n return items;\n }\n\n getDefaultItems() {\n const items = [];\n if (this.userSettingsService.userHasPermission('EditClients')) {\n items.push(...[\n // new EzRouterLinkMenuItem('Tasks', '/reports/client-activity-items-report'),\n new EzRouterLinkMenuItem('All Un-Invoiced Items', '/admin/billing/un-invoiced-items', { 'preset': 'AllCart', 'adjustHeight': true }),\n new EzRouterLinkMenuItem('My Un-Invoiced Items', '/admin/billing/un-invoiced-items', { 'preset': 'MyCart', 'adjustHeight': true })\n ]);\n }\n\n return items;\n }\n\n getSubSectionItems() {\n const items = [\n // new EzCommandMenuItem('Test SubSection Item', () => alert('Test command dynamic menu item!'), 'dynamic-menu-item-secondary'),\n ];\n return items;\n }\n\n loadDynamicSideModalItem(component: Type, item: DynamicMenuItem, sideModalId?: string) {\n item.component = component;\n item.data = { modalId: sideModalId };\n this._selectedDynamicItem$.next(item);\n }\n}\n"], "mappings": "wLAEM,IAAOA,EAAP,KAA0B,CAC5BC,YAAmBC,EAAqB,GAAI,CAAzB,KAAAA,UAAAA,CAA6B,GCD9C,IAAOC,EAAP,KAA2B,CAC7BC,YAAmBC,EAAuBC,EAA4BC,EAAmC,CAAtF,KAAAF,MAAAA,EAAuB,KAAAC,WAAAA,EAA4B,KAAAC,YAAAA,CAAuC,GCajH,IAAaC,GAAsB,IAAA,CAA7B,IAAOA,EAAP,MAAOA,CAAsB,CAOjCC,YACUC,EACAC,EAAwC,CADxC,KAAAD,YAAAA,EACA,KAAAC,oBAAAA,EAPV,KAAAC,cAAoD,IAAIC,EAAmC,CAAA,CAAE,EAErF,KAAAC,sBAA0D,IAAID,EAAgB,IAAI,EAC1F,KAAAE,qBAAoD,KAAKD,sBAAsBE,aAAY,EAMzF,KAAKN,YAAYO,oBAA8BC,CAAqB,EACjEC,KAAKC,EAAIC,GAASA,EAAMC,MAAMC,GAAG,CAAC,EAClCC,UAAWD,GAAe,CACzB,IAAME,EAA2B,KAAKC,iBAAiBH,CAAG,EAC1D,KAAKI,aAAaF,CAAK,CACzB,CAAC,CACL,CAEAG,aAAaC,EAA4B,CACvC,IAAMC,EAAkC,KAAKlB,cAAcmB,SAAQ,EAEnE,KAAKnB,cAAcoB,KAAK,CAAC,GAAGF,EAAc,GAAGD,CAAS,CAAC,EACvD,KAAKjB,cAAcmB,SAAQ,EAAGE,KAAK,SAAUC,EAAGC,EAAC,CAC/C,OAAOD,EAAEE,MAAQD,EAAEC,KACrB,CAAC,CACH,CAEAT,aAAaE,EAA4B,CACvC,KAAKjB,cAAcoB,KAAKH,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,CAAW,EAClC,KAAK3C,sBAAsBkB,KAAKQ,CAAI,CACtC,yCAtIWhC,GAAsBmD,EAAAC,CAAA,EAAAD,EAAAE,CAAA,CAAA,CAAA,wBAAtBrD,EAAsBsD,QAAtBtD,EAAsBuD,UAAAC,WAFrB,MAAM,CAAA,EAEd,IAAOxD,EAAPyD,SAAOzD,CAAsB,GAAA", "names": ["EzMenuItemSeparator", "constructor", "separator", "EzRouterLinkMenuItem", "constructor", "label", "routerLink", "queryParams", "DynamicMenuItemService", "constructor", "storeHelper", "userSettingsService", "dynamicItems$", "BehaviorSubject", "_selectedDynamicItem$", "selectedDynamicItem$", "asObservable", "stateStreamSelector", "getRouterFeatureState", "pipe", "map", "route", "state", "url", "subscribe", "items", "getPageDropItems", "setMenuItems", "addMenuItems", "menuItems", "dynamicItems", "getValue", "next", "sort", "a", "b", "level", "removeMenuItem", "data", "forEach", "item", "index", "label", "splice", "setDefaultMenuItems", "getDefaultItems", "pageItems", "getItemsForClientsPage", "getItemsForAttendancePage", "getItemsForLockerRoomsPage", "EzMenuItemSeparator", "EzRouterLinkMenuItem", "userHasPermission", "push", "getSubSectionItems", "loadDynamicSideModalItem", "component", "sideModalId", "modalId", "\u0275\u0275inject", "EzStoreService", "UserSettingsService", "factory", "\u0275fac", "providedIn", "_DynamicMenuItemService"] }