{"ast":null,"code":"import { ApiService } from '../../../services/user-management.api.service';\nimport { GuiPagingDisplay, GuiTheme } from '@generic-ui/ngx-grid';\nimport { Subscription } from 'rxjs/internal/Subscription';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"src/app/services/color-mode.service\";\nimport * as i2 from \"@generic-ui/ngx-grid\";\nconst _c0 = [\"grid\"];\nexport let BaseTableComponent = /*#__PURE__*/(() => {\n class BaseTableComponent {\n constructor(service, columns, cModeService) {\n this.cModeService = cModeService;\n this.columnMenu = {\n enabled: true,\n sort: true,\n columnsManager: false,\n filter: false\n };\n this.sorting = {\n enabled: true,\n multiSorting: true\n };\n this.loading = true;\n this.autoResizeWidth = true;\n this.rowDetail = {\n enabled: true,\n template: item => {\n return `\n
`;\n }\n };\n this.paging = {\n enabled: true,\n page: 1,\n pageSize: 15,\n pageSizes: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],\n pagerTop: true,\n pagerBottom: false,\n display: GuiPagingDisplay.ADVANCED\n };\n this.searching = {\n enabled: true,\n placeholder: 'Suche'\n };\n this.maxHeight = 400;\n this.infoPanel = {\n enabled: true,\n infoDialog: false,\n columnsManager: true,\n schemaManager: true\n };\n this.titlePanel = {\n enabled: false,\n template: () => {\n return `\n
List of contract workers
\n `;\n }\n };\n this.theme = localStorage.getItem('theme') === 'dark' ? GuiTheme.DARK : GuiTheme.FABRIC;\n this.themeSubscription = new Subscription();\n this.rowDetailTemplate = null;\n this.isCellEditable = false;\n this.cellEditing = {\n enabled: this.isCellEditable,\n rowEdit: (value, item, index) => {\n return Boolean(index % 2);\n },\n cellEdit: (value, item, index) => {\n return Boolean(index % 5);\n }\n };\n this.rowSelection = true;\n this.onSelectedRows = rows => {};\n this.initData = this.fetchData;\n this.columns = [];\n this.selected = false;\n this.service = service;\n if (this.columns.length == 0) this.columns = columns;\n //assign row details\n if (this.rowDetailTemplate === null || this.rowDetailTemplate === undefined) this.rowDetail = {\n enabled: false\n };else this.rowDetail = {\n enabled: true,\n template: this.rowDetailTemplate\n };\n }\n safelyUnselectAll() {\n this.selected = true;\n if (this.api?.getSelectedRows() != undefined) if ((this.api?.getSelectedRows().length ?? 0 > 0) && this.selected) {\n this.api?.unselectAll();\n this.selected = false;\n }\n }\n get api() {\n return this.mainGrid.api;\n }\n set source(data) {\n this.api.setSource(data);\n }\n get selectedRows() {\n return this.api.getSelectedRows();\n }\n ngOnInit() {\n const subscription = this.cModeService.themeChanges$.subscribe(theme => {\n this.theme = theme === 'dark' ? GuiTheme.DARK : GuiTheme.FABRIC;\n });\n this.themeSubscription.add(subscription);\n this.initData();\n }\n ngOnDestroy() {\n this.themeSubscription.unsubscribe();\n }\n ngAfterViewInit() {}\n fetchData() {\n this.service.getAll().subscribe({\n next: response => {\n if (response.isSuccess && response.data) {\n this.source = response.data;\n this.loading = false;\n } else {\n // Handle response failure\n console.error('Failed to fetch users');\n }\n },\n error: error => console.error('Error fetching users:', error)\n });\n }\n static #_ = this.ɵfac = function BaseTableComponent_Factory(t) {\n return new (t || BaseTableComponent)(i0.ɵɵdirectiveInject(ApiService), i0.ɵɵdirectiveInject(Array), i0.ɵɵdirectiveInject(i1.ColorModeService));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: BaseTableComponent,\n selectors: [[\"app-base-table\"]],\n viewQuery: function BaseTableComponent_Query(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵviewQuery(_c0, 7);\n }\n if (rf & 2) {\n let _t;\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.mainGrid = _t.first);\n }\n },\n inputs: {\n rowDetailTemplate: \"rowDetailTemplate\",\n isCellEditable: \"isCellEditable\",\n cellEditing: \"cellEditing\",\n rowSelection: \"rowSelection\",\n onSelectedRows: \"onSelectedRows\",\n initData: \"initData\",\n columns: \"columns\"\n },\n decls: 2,\n vars: 14,\n consts: [[\"grid\", \"\"], [3, \"selectedRows\", \"columns\", \"columnMenu\", \"sorting\", \"loading\", \"rowSelection\", \"rowDetail\", \"autoResizeWidth\", \"paging\", \"searching\", \"cellEditing\", \"virtualScroll\", \"infoPanel\", \"titlePanel\", \"theme\"]],\n template: function BaseTableComponent_Template(rf, ctx) {\n if (rf & 1) {\n const _r1 = i0.ɵɵgetCurrentView();\n i0.ɵɵelementStart(0, \"gui-grid\", 1, 0);\n i0.ɵɵlistener(\"selectedRows\", function BaseTableComponent_Template_gui_grid_selectedRows_0_listener($event) {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onSelectedRows($event));\n });\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n i0.ɵɵproperty(\"columns\", ctx.columns)(\"columnMenu\", ctx.columnMenu)(\"sorting\", ctx.sorting)(\"loading\", ctx.loading)(\"rowSelection\", ctx.rowSelection)(\"rowDetail\", ctx.rowDetail)(\"autoResizeWidth\", ctx.autoResizeWidth)(\"paging\", ctx.paging)(\"searching\", ctx.searching)(\"cellEditing\", ctx.cellEditing)(\"virtualScroll\", true)(\"infoPanel\", ctx.infoPanel)(\"titlePanel\", ctx.titlePanel)(\"theme\", ctx.theme);\n }\n },\n dependencies: [i2.GuiGridComponent]\n });\n }\n return BaseTableComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}