{"version":3,"sources":["src/app/core/components/ui-kit/data-display/items/data-item.directive.ts","src/app/core/components/ui-kit/data-display/data-display.component.ts","src/app/core/components/ui-kit/data-display/data-display.component.html"],"sourcesContent":["import { Directive, Input, OnChanges, TemplateRef } from '@angular/core';\nimport { Subject } from 'rxjs';\n\nexport interface GroupingKey {\n label: string;\n key: string;\n}\n\nexport interface GroupingValue {\n label: string;\n value: string;\n}\n\nexport interface Group {\n label: string;\n elements: VDataItemDirective[];\n}\n\n@Directive({\n selector: '[vDataItem]',\n})\nexport class VDataItemDirective implements OnChanges {\n constructor(public templateRef: TemplateRef) {}\n\n groupingKeys$ = new Subject>();\n\n @Input() groupingKeys: Record = {};\n\n ngOnChanges(): void {\n this.groupingKeys$.next(this.groupingKeys);\n }\n}\n","import {\n AfterViewInit,\n Component,\n ContentChildren,\n EventEmitter,\n Input,\n Output,\n QueryList,\n} from '@angular/core';\nimport { PopoverModule } from 'primeng/popover';\nimport { SkeletonModule } from 'primeng/skeleton';\nimport { SharedModule } from 'src/app/core/shared.module';\nimport { MenuItem } from 'src/app/services/menu/menuItem';\nimport { VButtonComponent } from '../buttons/button/button.component';\nimport { VIconButtonComponent } from '../buttons/icon-button/icon-button.component';\nimport { VMenuComponent } from '../menu/menu.component';\nimport { VPaginatorComponent } from '../paginator/paginator.component';\nimport {\n Group,\n GroupingKey,\n VDataItemDirective,\n} from './items/data-item.directive';\n\n@Component({\n selector: 'v-data-display',\n imports: [\n SharedModule,\n VIconButtonComponent,\n VButtonComponent,\n PopoverModule,\n VMenuComponent,\n VPaginatorComponent,\n SkeletonModule,\n ],\n templateUrl: './data-display.component.html',\n styleUrl: './data-display.component.scss',\n})\nexport class VDataDisplayComponent implements AfterViewInit {\n @ContentChildren(VDataItemDirective) elements!: QueryList;\n\n groupedElements: Record> = {};\n\n @Input() showToolbar = true;\n\n @Input() title?: string;\n @Input() titleClasses?: string;\n @Input() layout: 'list' | 'grid' = 'list';\n @Input() showLayoutSwitcher = true;\n private oldLayout?: string;\n\n @Input() gridColumns = 3;\n @Input() size: 'sm' | 'md' = 'md';\n @Input() isLoading = false;\n @Input() skeletonHeight = '6rem';\n\n currentGroupingKey?: GroupingKey;\n\n @Input() groupingKeys: GroupingKey[] = [];\n\n // paginator options\n @Input() showPaginator = false;\n @Input() paginatorRows = 10;\n @Input() paginatorPage = 1;\n @Input() paginatorTotalRecords = 0;\n @Input() paginatorRowsPerPageOptions = [10, 20, 30];\n @Output() paginatorPageChange = new EventEmitter();\n\n ngAfterViewInit(): void {\n this.elements.changes.subscribe(() => {\n this.buildGroups();\n });\n this.buildGroups();\n }\n\n buildGroups() {\n this.groupedElements = {};\n this.elements.forEach(element => {\n for (const [key, value] of Object.entries(element.groupingKeys)) {\n if (!this.groupedElements[key]) {\n this.groupedElements[key] = {};\n }\n\n if (!this.groupedElements[key][value.value]) {\n this.groupedElements[key][value.value] = {\n label: value.label,\n elements: [],\n };\n }\n\n this.groupedElements[key][value.value].elements.push(element);\n }\n\n element.groupingKeys$.subscribe(() => {\n this.buildGroups();\n });\n });\n\n // switch grid layout to list layout if there is only one element\n if (this.elements.length === 1 && this.layout === 'grid') {\n this.oldLayout = this.layout;\n this.layout = 'list';\n } else if (\n this.elements.length > 1 &&\n this.layout === 'list' &&\n this.oldLayout === 'grid'\n ) {\n this.layout = this.oldLayout;\n }\n }\n\n get items(): MenuItem[] {\n const items: MenuItem[] = [\n {\n label: 'All',\n onClicked: () => {\n this.currentGroupingKey = undefined;\n },\n },\n ];\n\n for (const key of this.groupingKeys) {\n items.push({\n label: key.label,\n onClicked: () => {\n this.currentGroupingKey = key;\n },\n });\n }\n\n return items;\n }\n\n // This is a getter that returns data items grouped by the current grouping key\n get groups(): Record {\n return this.groupedElements[this.currentGroupingKey!.key];\n }\n\n public setLayout(layout: 'list' | 'grid') {\n this.layout = layout;\n this.oldLayout = layout;\n }\n}\n","
\n @if(showToolbar) {\n
\n
\n @if (title) {\n

{{ title }}

\n }\n @if(showLayoutSwitcher) {\n @if (layout === 'list') {\n \n } @else {\n \n }\n }\n 0\"\n icon=\"pi pi-tag\"\n size=\"small\"\n variant=\"secondary\"\n [label]=\"currentGroupingKey?.label || 'All'\"\n (press)=\"groupingMenu.toggle($event)\">\n\n \n \n \n
\n
0\">\n \n
\n
\n}\n\n @if (elements.length === 0 && !isLoading) {\n
\n

No data available

\n
\n }\n\n @if (isLoading && elements.length === 0) {\n \n \n \n \n
\n } @else {\n
\n \n \n
\n\n \n @if (currentGroupingKey) {\n
\n \n {{ group.value.label }}\n \n \n @for (item of group.value.elements; track item) {\n \n }\n \n
\n } @else {\n \n @for (item of elements; track item) {\n \n }\n \n }\n \n \n }\n\n"],"names":["VDataItemDirective","constructor","templateRef","groupingKeys$","Subject","groupingKeys","ngOnChanges","next","ɵɵdirectiveInject","TemplateRef","selectors","inputs","features","ɵɵNgOnChangesFeature","ɵɵelementStart","ɵɵtext","ɵɵelementEnd","ɵɵproperty","ctx_r1","titleClasses","ɵɵadvance","ɵɵtextInterpolate","title","ɵɵlistener","ɵɵrestoreView","_r3","ɵɵnextContext","ɵɵresetView","setLayout","_r4","ɵɵtemplate","VDataDisplayComponent_Conditional_1_Conditional_4_Conditional_0_Template","VDataDisplayComponent_Conditional_1_Conditional_4_Conditional_1_Template","ɵɵconditional","layout","$event","_r5","groupingMenu_r6","ɵɵreference","toggle","currentGroupingKey","label","_r7","paginatorPageChange","emit","paginatorTotalRecords","paginatorRows","paginatorPage","paginatorRowsPerPageOptions","size","VDataDisplayComponent_Conditional_1_Conditional_3_Template","VDataDisplayComponent_Conditional_1_Conditional_4_Template","VDataDisplayComponent_Conditional_1_v_button_5_Template","_r1","hide","VDataDisplayComponent_Conditional_1_div_9_Template","showLayoutSwitcher","groupingKeys","length","toolbar_r8","items","showPaginator","ɵɵelement","ɵɵpureFunction2","_c0","gridColumns","join","skeletonHeight","ɵɵelementContainer","VDataDisplayComponent_Conditional_4_Conditional_3_div_0_For_5_ng_container_0_Template","item_r9","templateRef","ɵɵrepeaterCreate","VDataDisplayComponent_Conditional_4_Conditional_3_div_0_For_5_Template","ɵɵrepeaterTrackByIdentity","ɵɵpureFunction1","_c2","$first_r11","ɵɵtextInterpolate1","group_r10","value","ɵɵrepeater","elements","VDataDisplayComponent_Conditional_4_Conditional_3_div_0_Template","ɵɵpipeBind1","groups","VDataDisplayComponent_Conditional_4_Conditional_4_For_2_ng_container_0_Template","item_r12","VDataDisplayComponent_Conditional_4_Conditional_4_For_2_Template","VDataDisplayComponent_Conditional_4_div_1_Template","VDataDisplayComponent_Conditional_4_Conditional_3_Template","VDataDisplayComponent_Conditional_4_Conditional_4_Template","isLoading","_c1","VDataDisplayComponent","constructor","groupedElements","showToolbar","EventEmitter","ngAfterViewInit","changes","subscribe","buildGroups","forEach","element","key","Object","entries","push","groupingKeys$","oldLayout","onClicked","undefined","selectors","contentQueries","rf","ctx","dirIndex","VDataItemDirective","VDataDisplayComponent_Conditional_1_Template","VDataDisplayComponent_Conditional_2_Template","VDataDisplayComponent_Conditional_3_Template","VDataDisplayComponent_Conditional_4_Template","SharedModule","NgClass","NgForOf","NgIf","NgTemplateOutlet","KeyValuePipe","VIconButtonComponent","VButtonComponent","PopoverModule","Popover","VMenuComponent","VPaginatorComponent","SkeletonModule","Skeleton","styles"],"mappings":";;+hBAqBA,IAAaA,IAAkB,IAAA,CAAzB,MAAOA,CAAkB,CAC7BC,YAAmBC,EAA6B,CAA7B,KAAAA,YAAAA,EAEnB,KAAAC,cAAgB,IAAIC,EAEX,KAAAC,aAA8C,CAAA,CAJJ,CAMnDC,aAAW,CACT,KAAKH,cAAcI,KAAK,KAAKF,YAAY,CAC3C,iDATWL,GAAkBQ,EAAAC,CAAA,CAAA,CAAA,CAAA,+BAAlBT,EAAkBU,UAAA,CAAA,CAAA,GAAA,YAAA,EAAA,CAAA,EAAAC,OAAA,CAAAN,aAAA,cAAA,EAAAO,SAAA,CAAAC,CAAA,CAAA,CAAA,CAAA,SAAlBb,CAAkB,GAAA,sHEhBvBc,EAAA,EAA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