kitsng-table-factory 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +24 -0
  2. package/esm2022/kitsng-table-factory.mjs +5 -0
  3. package/esm2022/lib/kitsng-filter/kitsng-filter/kitsng-filter.component.mjs +206 -0
  4. package/esm2022/lib/kitsng-filter/kitsng-filter.module.mjs +65 -0
  5. package/esm2022/lib/kitsng-filter/lookup-list.service.mjs +132 -0
  6. package/esm2022/lib/kitsng-filter/lookup-select/lookup-select.component.mjs +349 -0
  7. package/esm2022/lib/kitsng-filter/lookup-select/lookup-select.module.mjs +43 -0
  8. package/esm2022/lib/kitsng-filter/overlay.service.mjs +30 -0
  9. package/esm2022/lib/kitsng-search/kitsng-search.component.mjs +39 -0
  10. package/esm2022/lib/kitsng-table-factory/components/kitsng-fetch-table-factory/kitsng-fetch-table-factory.component.mjs +578 -0
  11. package/esm2022/lib/kitsng-table-factory/components/kitsng-table-factory/kitsng-table-factory.component.mjs +359 -0
  12. package/esm2022/lib/kitsng-table-factory/components/kitsng-tree-table-factory/kitsng-tree-table-factory.component.mjs +587 -0
  13. package/esm2022/lib/kitsng-table-factory/core/models/kitsng-table.model.mjs +2 -0
  14. package/esm2022/lib/kitsng-table-factory/core/models/pipe-config.model.mjs +2 -0
  15. package/esm2022/lib/kitsng-table-factory/core/pipes/dynamic.pipe.mjs +40 -0
  16. package/esm2022/lib/kitsng-table-factory/core/services/api.service.mjs +108 -0
  17. package/esm2022/lib/kitsng-table-factory/kitsng-table-factory.module.mjs +54 -0
  18. package/esm2022/public-api.mjs +14 -0
  19. package/fesm2022/kitsng-table-factory.mjs +2516 -0
  20. package/fesm2022/kitsng-table-factory.mjs.map +1 -0
  21. package/index.d.ts +5 -0
  22. package/lib/kitsng-filter/kitsng-filter/kitsng-filter.component.d.ts +46 -0
  23. package/lib/kitsng-filter/kitsng-filter.module.d.ts +19 -0
  24. package/lib/kitsng-filter/lookup-list.service.d.ts +23 -0
  25. package/lib/kitsng-filter/lookup-select/lookup-select.component.d.ts +72 -0
  26. package/lib/kitsng-filter/lookup-select/lookup-select.module.d.ts +13 -0
  27. package/lib/kitsng-filter/overlay.service.d.ts +7 -0
  28. package/lib/kitsng-search/kitsng-search.component.d.ts +13 -0
  29. package/lib/kitsng-table-factory/components/kitsng-fetch-table-factory/kitsng-fetch-table-factory.component.d.ts +23 -0
  30. package/lib/kitsng-table-factory/components/kitsng-table-factory/kitsng-table-factory.component.d.ts +10 -0
  31. package/lib/kitsng-table-factory/components/kitsng-tree-table-factory/kitsng-tree-table-factory.component.d.ts +30 -0
  32. package/lib/kitsng-table-factory/core/models/kitsng-table.model.d.ts +120 -0
  33. package/lib/kitsng-table-factory/core/models/pipe-config.model.d.ts +5 -0
  34. package/lib/kitsng-table-factory/core/pipes/dynamic.pipe.d.ts +11 -0
  35. package/lib/kitsng-table-factory/core/services/api.service.d.ts +63 -0
  36. package/lib/kitsng-table-factory/kitsng-table-factory.module.d.ts +17 -0
  37. package/package.json +29 -0
  38. package/public-api.d.ts +9 -0
@@ -0,0 +1,2516 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injector, Pipe, Component, Input, Injectable, NgModule, EventEmitter, Output, ViewChild } from '@angular/core';
3
+ import { get } from 'lodash';
4
+ import * as i2 from '@angular/common';
5
+ import { CommonModule } from '@angular/common';
6
+ import * as i2$1 from 'primeng/table';
7
+ import { TableModule } from 'primeng/table';
8
+ import * as i4 from 'primeng/api';
9
+ import * as i5 from 'primeng/paginator';
10
+ import { PaginatorModule } from 'primeng/paginator';
11
+ import * as i6 from 'primeng/button';
12
+ import { ButtonModule } from 'primeng/button';
13
+ import * as i7 from 'primeng/tooltip';
14
+ import { TooltipModule } from 'primeng/tooltip';
15
+ import * as i8 from '@ngx-translate/core';
16
+ import { TranslatePipe } from '@ngx-translate/core';
17
+ import { map, catchError, throwError, Subject, takeUntil, debounceTime, of, shareReplay, finalize } from 'rxjs';
18
+ import * as i1 from '@angular/common/http';
19
+ import * as i8$1 from 'primeng/treetable';
20
+ import { TreeTableModule } from 'primeng/treetable';
21
+ import { debounceTime as debounceTime$1 } from 'rxjs/operators';
22
+ import * as i1$1 from 'primeng/inputtext';
23
+ import { InputTextModule } from 'primeng/inputtext';
24
+ import * as i1$2 from '@angular/forms';
25
+ import { FormsModule, NG_VALUE_ACCESSOR, Validators, ReactiveFormsModule } from '@angular/forms';
26
+ import * as i3$1 from 'primeng/overlaypanel';
27
+ import { OverlayPanelModule } from 'primeng/overlaypanel';
28
+ import * as i3 from 'primeng/dropdown';
29
+ import { DropdownModule } from 'primeng/dropdown';
30
+ import * as i8$2 from 'primeng/calendar';
31
+ import { CalendarModule } from 'primeng/calendar';
32
+ import * as i9 from 'primeng/badge';
33
+ import { BadgeModule } from 'primeng/badge';
34
+ import * as i6$1 from 'primeng/progressspinner';
35
+ import { ProgressSpinnerModule } from 'primeng/progressspinner';
36
+ import * as i11 from 'primeng/divider';
37
+ import { DividerModule } from 'primeng/divider';
38
+ import { ChipModule } from 'primeng/chip';
39
+
40
+ class DynamicPipe {
41
+ constructor(injector) {
42
+ this.injector = injector;
43
+ }
44
+ transform(value, pipes) {
45
+ if (!pipes || pipes.length === 0) {
46
+ return value;
47
+ }
48
+ let result = value;
49
+ for (const pipeConfig of pipes) {
50
+ result = this.applyPipe(result, pipeConfig.pipe, pipeConfig.args);
51
+ }
52
+ return result;
53
+ }
54
+ applyPipe(value, pipe, args) {
55
+ const injector = Injector.create({
56
+ name: "DynamicPipe",
57
+ parent: this.injector,
58
+ providers: [{ provide: pipe }],
59
+ });
60
+ const pipeTrans = injector.get(pipe);
61
+ if (args) {
62
+ return pipeTrans.transform(value, ...args);
63
+ }
64
+ else {
65
+ return pipeTrans.transform(value);
66
+ }
67
+ }
68
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: DynamicPipe, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Pipe }); }
69
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: DynamicPipe, name: "dynamicPipe" }); }
70
+ }
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: DynamicPipe, decorators: [{
72
+ type: Pipe,
73
+ args: [{
74
+ name: "dynamicPipe",
75
+ }]
76
+ }], ctorParameters: () => [{ type: i0.Injector }] });
77
+
78
+ class KitsngTableFactoryComponent {
79
+ getNestedValue(data, field) {
80
+ return get(data, field);
81
+ }
82
+ resolveActionProperty(property, item) {
83
+ if (typeof property === 'function') {
84
+ return property(item);
85
+ }
86
+ return property;
87
+ }
88
+ onSelectChange(event) {
89
+ if (this.tableConfig?.onSelectedItems) {
90
+ this.tableConfig?.onSelectedItems(this.tableConfig?.selectedItems);
91
+ }
92
+ }
93
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
94
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.8", type: KitsngTableFactoryComponent, selector: "kitsng-table-factory", inputs: { tableConfig: "tableConfig" }, ngImport: i0, template: `
95
+ <div class="grid row {{tableConfig.containerClass ?? 'border-round-3xl'}}">
96
+ <div class="col-12">
97
+ <ng-container *ngIf="tableConfig.tableTemplate;else defaultTableTemplate">
98
+ <ng-container *ngTemplateOutlet="tableConfig.tableTemplate;context: { $implicit: tableConfig, defaultTemplate: defaultTableTemplate}"></ng-container>
99
+ </ng-container>
100
+ <ng-template #defaultTableTemplate>
101
+ <p-table
102
+ [dataKey]="tableConfig.dataKey"
103
+ [value]="tableConfig.data"
104
+ [columns]="tableConfig.columns"
105
+ [styleClass]="(tableConfig.class ?? 'border-round-xl border-2 border-gray-200') + (tableConfig.showGridlines ? ' p-datatable-gridlines' : '') + (tableConfig.stripedRows ? ' p-datatable-striped' : '')"
106
+ [(selection)]="tableConfig.selectedItems"
107
+ [selectionMode]="'single'"
108
+ (selectionChange)="onSelectChange($event)"
109
+ [rowHover]="tableConfig.rowHover ?? true"
110
+ [resizableColumns]="tableConfig.resizableColumns ?? true"
111
+ [scrollable]="tableConfig.scrollable ?? true"
112
+ [rows]="tableConfig.pageSize"
113
+ [first]="tableConfig.first"
114
+ [showCurrentPageReport]="tableConfig.currentPageReportTemplate? true: false"
115
+ [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"
116
+ [paginator]="tableConfig.showClientPaginator ?? false"
117
+ [totalRecords]="tableConfig.totalRecords ?? 0"
118
+ [tableStyle]="tableConfig.tableStyle ?? {'min-width': '50rem'}"
119
+ [currentPageReportTemplate]="tableConfig.currentPageReportTemplate ?? 'Showing {first} to {last} of {totalRecords} entity'"
120
+ (onPage)="tableConfig.onPageChanged? tableConfig.onPageChanged($event) : false"
121
+ (sortFunction)="tableConfig.onSorting? tableConfig.onSorting($event): false" [customSort]="true">
122
+
123
+ <ng-template pTemplate="header" let-columns>
124
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
125
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
126
+ </ng-container>
127
+ <ng-template #defaultHeaderTemplate>
128
+ <tr>
129
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox" pFrozenColumn [frozen]="true" style="z-index:1;">
130
+ <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
131
+ </th>
132
+ <th
133
+ *ngFor="let col of columns"
134
+ [pSortableColumn]="col.field"
135
+ [pSortableColumnDisabled]="!col.sortable"
136
+ [ngStyle]="col?.headerCellStyle ?? {}"
137
+ [class]="col?.headerCellClass ?? ''"
138
+ pFrozenColumn
139
+ [frozen]="col?.isFrozen ?? false"
140
+ [alignFrozen]="col?.alignFrozen"
141
+ >
142
+ <div class="">
143
+ {{ (col.header||'')|translate }}
144
+ <p-sortIcon *ngIf="col.sortable" [field]="col.field"></p-sortIcon>
145
+ </div>
146
+ </th>
147
+ <th [ngStyle]="tableConfig.actionCellHeaderStyle ?? {'width': '138px'}" *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate"
148
+ pFrozenColumn
149
+ [frozen]="tableConfig.actionIsFrozen || false" [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">{{'Actions'|translate}}</th>
150
+ </tr>
151
+ </ng-template>
152
+ </ng-template>
153
+
154
+ <ng-template pTemplate="body" let-item let-columns="columns">
155
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
156
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: item, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
157
+ </ng-container>
158
+ <ng-template #defaultBodyTemplate>
159
+ <tr class="">
160
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" pFrozenColumn [frozen]="true">
161
+ <p-tableCheckbox [value]="item"></p-tableCheckbox>
162
+ </td>
163
+ <td *ngFor="let column of columns"
164
+ [ngStyle]="column?.bodyCellStyle ?? {}"
165
+ pFrozenColumn
166
+ [frozen]="column?.isFrozen ?? false"
167
+ [alignFrozen]="column?.alignFrozen"
168
+ [class]="column?.bodyCellClass ?? ''">
169
+ <ng-container *ngIf="column.template; else defaultTemplate">
170
+ <ng-container *ngTemplateOutlet="column.template; context: { $implicit: getNestedValue(item, column.field), column: column, rowData: item }"></ng-container>
171
+ </ng-container>
172
+ <ng-template #defaultTemplate>
173
+ {{ getNestedValue(item, column.field) | dynamicPipe:column.pipes ?? [] }}
174
+ </ng-template>
175
+ </td>
176
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
177
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
178
+ pFrozenColumn
179
+ [frozen]="tableConfig.actionIsFrozen || false"
180
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
181
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
182
+ <ng-container *ngIf="tableConfig.actionTemplate">
183
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: item }"></ng-container>
184
+ </ng-container>
185
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
186
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
187
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: item, defaultTemplate: defaultButtonTemplate }"></ng-container>
188
+ </ng-container>
189
+ <ng-template #defaultButtonTemplate>
190
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, item) !== false) && !resolveActionProperty(action.hidden, item)">
191
+ <p-button
192
+ [icon]="resolveActionProperty(action.icon, item)"
193
+ [iconPos]="resolveActionProperty(action.iconPos, item) ?? 'left'"
194
+ [label]="(resolveActionProperty(action.label, item)||'')|translate"
195
+ [pTooltip]="resolveActionProperty(action.tooltip, item)"
196
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, item) ?? 'top'"
197
+ [disabled]="resolveActionProperty(action.disabled, item)"
198
+ [severity]="resolveActionProperty(action.severity, item)"
199
+ [rounded]="resolveActionProperty(action.rounded, item)"
200
+ [outlined]="resolveActionProperty(action.outlined, item)"
201
+ [text]="resolveActionProperty(action.text, item)"
202
+ [raised]="resolveActionProperty(action.raised, item)"
203
+ [plain]="resolveActionProperty(action.plain, item)"
204
+ [size]="resolveActionProperty(action.size, item)"
205
+ [badge]="resolveActionProperty(action.badge, item)"
206
+ [badgeClass]="resolveActionProperty(action.badgeClass, item)"
207
+ styleClass="{{resolveActionProperty(action.buttonClass, item) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, item)}}"
208
+ (onClick)="action.onClick? action.onClick(item) : false"
209
+ ></p-button>
210
+ </ng-container>
211
+ </ng-template>
212
+ </ng-container>
213
+ </div>
214
+ </td>
215
+ </ng-container>
216
+ </tr>
217
+ </ng-template>
218
+ </ng-template>
219
+
220
+ <ng-container *ngIf="tableConfig.captionTemplate">
221
+ <ng-template pTemplate="caption">
222
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
223
+ </ng-template>
224
+ </ng-container>
225
+
226
+ <ng-container *ngIf="tableConfig.footerTemplate">
227
+ <ng-template pTemplate="footer">
228
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
229
+ </ng-template>
230
+ </ng-container>
231
+
232
+ <ng-container *ngIf="tableConfig.summaryTemplate">
233
+ <ng-template pTemplate="summary">
234
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
235
+ </ng-template>
236
+ </ng-container>
237
+
238
+ <ng-template pTemplate="emptymessage">
239
+ <ng-container *ngIf="tableConfig.emptymessageTemplate; else defaultMessageTemplate">
240
+ <ng-container *ngTemplateOutlet="tableConfig.emptymessageTemplate"></ng-container>
241
+ </ng-container>
242
+ <ng-template #defaultMessageTemplate>
243
+ <tr>
244
+ <td
245
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
246
+ class="text-center">{{tableConfig.emptymessage ?? 'No Data Found.'}}</td>
247
+ </tr>
248
+ </ng-template>
249
+ </ng-template>
250
+ </p-table>
251
+ </ng-template>
252
+ <p-paginator *ngIf="tableConfig.showPaginator ?? true" [styleClass]="tableConfig.paginatorClass ?? 'mt-3'" (onPageChange)="tableConfig.onPageChanged? tableConfig.onPageChanged($event) : false" [first]="tableConfig.first ?? 0" [rows]="tableConfig.pageSize ?? 0" [totalRecords]="tableConfig.totalRecords ?? 0" [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"></p-paginator>
253
+ </div>
254
+ </div>
255
+ `, isInline: true, dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2$1.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "selectAll", "virtualRowHeight"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i2$1.SortableColumn, selector: "[pSortableColumn]", inputs: ["pSortableColumn", "pSortableColumnDisabled"] }, { kind: "directive", type: i2$1.FrozenColumn, selector: "[pFrozenColumn]", inputs: ["frozen", "alignFrozen"] }, { kind: "component", type: i2$1.SortIcon, selector: "p-sortIcon", inputs: ["field"] }, { kind: "component", type: i2$1.TableCheckbox, selector: "p-tableCheckbox", inputs: ["disabled", "value", "index", "inputId", "name", "required", "ariaLabel"] }, { kind: "component", type: i2$1.TableHeaderCheckbox, selector: "p-tableHeaderCheckbox", inputs: ["disabled", "inputId", "name", "ariaLabel"] }, { kind: "component", type: i5.Paginator, selector: "p-paginator", inputs: ["pageLinkSize", "style", "styleClass", "alwaysShow", "dropdownAppendTo", "templateLeft", "templateRight", "appendTo", "dropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showFirstLastIcon", "totalRecords", "rows", "rowsPerPageOptions", "showJumpToPageDropdown", "showJumpToPageInput", "jumpToPageItemTemplate", "showPageLinks", "locale", "dropdownItemTemplate", "first"], outputs: ["onPageChange"] }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "style", "styleClass", "badgeClass", "ariaLabel", "autofocus"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: i7.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }, { kind: "pipe", type: DynamicPipe, name: "dynamicPipe" }] }); }
256
+ }
257
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryComponent, decorators: [{
258
+ type: Component,
259
+ args: [{ selector: 'kitsng-table-factory', template: `
260
+ <div class="grid row {{tableConfig.containerClass ?? 'border-round-3xl'}}">
261
+ <div class="col-12">
262
+ <ng-container *ngIf="tableConfig.tableTemplate;else defaultTableTemplate">
263
+ <ng-container *ngTemplateOutlet="tableConfig.tableTemplate;context: { $implicit: tableConfig, defaultTemplate: defaultTableTemplate}"></ng-container>
264
+ </ng-container>
265
+ <ng-template #defaultTableTemplate>
266
+ <p-table
267
+ [dataKey]="tableConfig.dataKey"
268
+ [value]="tableConfig.data"
269
+ [columns]="tableConfig.columns"
270
+ [styleClass]="(tableConfig.class ?? 'border-round-xl border-2 border-gray-200') + (tableConfig.showGridlines ? ' p-datatable-gridlines' : '') + (tableConfig.stripedRows ? ' p-datatable-striped' : '')"
271
+ [(selection)]="tableConfig.selectedItems"
272
+ [selectionMode]="'single'"
273
+ (selectionChange)="onSelectChange($event)"
274
+ [rowHover]="tableConfig.rowHover ?? true"
275
+ [resizableColumns]="tableConfig.resizableColumns ?? true"
276
+ [scrollable]="tableConfig.scrollable ?? true"
277
+ [rows]="tableConfig.pageSize"
278
+ [first]="tableConfig.first"
279
+ [showCurrentPageReport]="tableConfig.currentPageReportTemplate? true: false"
280
+ [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"
281
+ [paginator]="tableConfig.showClientPaginator ?? false"
282
+ [totalRecords]="tableConfig.totalRecords ?? 0"
283
+ [tableStyle]="tableConfig.tableStyle ?? {'min-width': '50rem'}"
284
+ [currentPageReportTemplate]="tableConfig.currentPageReportTemplate ?? 'Showing {first} to {last} of {totalRecords} entity'"
285
+ (onPage)="tableConfig.onPageChanged? tableConfig.onPageChanged($event) : false"
286
+ (sortFunction)="tableConfig.onSorting? tableConfig.onSorting($event): false" [customSort]="true">
287
+
288
+ <ng-template pTemplate="header" let-columns>
289
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
290
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
291
+ </ng-container>
292
+ <ng-template #defaultHeaderTemplate>
293
+ <tr>
294
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox" pFrozenColumn [frozen]="true" style="z-index:1;">
295
+ <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
296
+ </th>
297
+ <th
298
+ *ngFor="let col of columns"
299
+ [pSortableColumn]="col.field"
300
+ [pSortableColumnDisabled]="!col.sortable"
301
+ [ngStyle]="col?.headerCellStyle ?? {}"
302
+ [class]="col?.headerCellClass ?? ''"
303
+ pFrozenColumn
304
+ [frozen]="col?.isFrozen ?? false"
305
+ [alignFrozen]="col?.alignFrozen"
306
+ >
307
+ <div class="">
308
+ {{ (col.header||'')|translate }}
309
+ <p-sortIcon *ngIf="col.sortable" [field]="col.field"></p-sortIcon>
310
+ </div>
311
+ </th>
312
+ <th [ngStyle]="tableConfig.actionCellHeaderStyle ?? {'width': '138px'}" *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate"
313
+ pFrozenColumn
314
+ [frozen]="tableConfig.actionIsFrozen || false" [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">{{'Actions'|translate}}</th>
315
+ </tr>
316
+ </ng-template>
317
+ </ng-template>
318
+
319
+ <ng-template pTemplate="body" let-item let-columns="columns">
320
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
321
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: item, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
322
+ </ng-container>
323
+ <ng-template #defaultBodyTemplate>
324
+ <tr class="">
325
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" pFrozenColumn [frozen]="true">
326
+ <p-tableCheckbox [value]="item"></p-tableCheckbox>
327
+ </td>
328
+ <td *ngFor="let column of columns"
329
+ [ngStyle]="column?.bodyCellStyle ?? {}"
330
+ pFrozenColumn
331
+ [frozen]="column?.isFrozen ?? false"
332
+ [alignFrozen]="column?.alignFrozen"
333
+ [class]="column?.bodyCellClass ?? ''">
334
+ <ng-container *ngIf="column.template; else defaultTemplate">
335
+ <ng-container *ngTemplateOutlet="column.template; context: { $implicit: getNestedValue(item, column.field), column: column, rowData: item }"></ng-container>
336
+ </ng-container>
337
+ <ng-template #defaultTemplate>
338
+ {{ getNestedValue(item, column.field) | dynamicPipe:column.pipes ?? [] }}
339
+ </ng-template>
340
+ </td>
341
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
342
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
343
+ pFrozenColumn
344
+ [frozen]="tableConfig.actionIsFrozen || false"
345
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
346
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
347
+ <ng-container *ngIf="tableConfig.actionTemplate">
348
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: item }"></ng-container>
349
+ </ng-container>
350
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
351
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
352
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: item, defaultTemplate: defaultButtonTemplate }"></ng-container>
353
+ </ng-container>
354
+ <ng-template #defaultButtonTemplate>
355
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, item) !== false) && !resolveActionProperty(action.hidden, item)">
356
+ <p-button
357
+ [icon]="resolveActionProperty(action.icon, item)"
358
+ [iconPos]="resolveActionProperty(action.iconPos, item) ?? 'left'"
359
+ [label]="(resolveActionProperty(action.label, item)||'')|translate"
360
+ [pTooltip]="resolveActionProperty(action.tooltip, item)"
361
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, item) ?? 'top'"
362
+ [disabled]="resolveActionProperty(action.disabled, item)"
363
+ [severity]="resolveActionProperty(action.severity, item)"
364
+ [rounded]="resolveActionProperty(action.rounded, item)"
365
+ [outlined]="resolveActionProperty(action.outlined, item)"
366
+ [text]="resolveActionProperty(action.text, item)"
367
+ [raised]="resolveActionProperty(action.raised, item)"
368
+ [plain]="resolveActionProperty(action.plain, item)"
369
+ [size]="resolveActionProperty(action.size, item)"
370
+ [badge]="resolveActionProperty(action.badge, item)"
371
+ [badgeClass]="resolveActionProperty(action.badgeClass, item)"
372
+ styleClass="{{resolveActionProperty(action.buttonClass, item) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, item)}}"
373
+ (onClick)="action.onClick? action.onClick(item) : false"
374
+ ></p-button>
375
+ </ng-container>
376
+ </ng-template>
377
+ </ng-container>
378
+ </div>
379
+ </td>
380
+ </ng-container>
381
+ </tr>
382
+ </ng-template>
383
+ </ng-template>
384
+
385
+ <ng-container *ngIf="tableConfig.captionTemplate">
386
+ <ng-template pTemplate="caption">
387
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
388
+ </ng-template>
389
+ </ng-container>
390
+
391
+ <ng-container *ngIf="tableConfig.footerTemplate">
392
+ <ng-template pTemplate="footer">
393
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
394
+ </ng-template>
395
+ </ng-container>
396
+
397
+ <ng-container *ngIf="tableConfig.summaryTemplate">
398
+ <ng-template pTemplate="summary">
399
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
400
+ </ng-template>
401
+ </ng-container>
402
+
403
+ <ng-template pTemplate="emptymessage">
404
+ <ng-container *ngIf="tableConfig.emptymessageTemplate; else defaultMessageTemplate">
405
+ <ng-container *ngTemplateOutlet="tableConfig.emptymessageTemplate"></ng-container>
406
+ </ng-container>
407
+ <ng-template #defaultMessageTemplate>
408
+ <tr>
409
+ <td
410
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
411
+ class="text-center">{{tableConfig.emptymessage ?? 'No Data Found.'}}</td>
412
+ </tr>
413
+ </ng-template>
414
+ </ng-template>
415
+ </p-table>
416
+ </ng-template>
417
+ <p-paginator *ngIf="tableConfig.showPaginator ?? true" [styleClass]="tableConfig.paginatorClass ?? 'mt-3'" (onPageChange)="tableConfig.onPageChanged? tableConfig.onPageChanged($event) : false" [first]="tableConfig.first ?? 0" [rows]="tableConfig.pageSize ?? 0" [totalRecords]="tableConfig.totalRecords ?? 0" [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"></p-paginator>
418
+ </div>
419
+ </div>
420
+ ` }]
421
+ }], propDecorators: { tableConfig: [{
422
+ type: Input,
423
+ args: [{ required: true }]
424
+ }] } });
425
+
426
+ const getMappedData = (res) => {
427
+ //
428
+ const camelize = (str) => {
429
+ return str
430
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
431
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
432
+ })
433
+ .replace(/\s+/g, "");
434
+ };
435
+ if (res.lookupsV2 && res.lookupsV2.length > 0) {
436
+ res.lookupsV2.forEach((lookup) => {
437
+ lookup.props
438
+ .map((k) => camelize(k))
439
+ .map((k) => ({
440
+ idProp: k,
441
+ mapProp: k.endsWith("Id") ? k.slice(0, k.length - 2) : k,
442
+ }))
443
+ .forEach((ks) => {
444
+ res.data.items.forEach((row) => {
445
+ let mval = (row[ks.idProp]?.indexOf?.(",")) > -1 ? lookup.dic[row[ks.idProp].split(",").shift()] : lookup.dic[row[ks.idProp]];
446
+ if (row[ks.idProp]?.indexOf?.(",") > -1) {
447
+ mval = {
448
+ ...mval,
449
+ text: row[ks.idProp].split(",").map((f) => lookup.dic[f]?.text).join(", ")
450
+ };
451
+ }
452
+ if (mval) {
453
+ row[ks.mapProp] = mval;
454
+ }
455
+ else {
456
+ }
457
+ });
458
+ });
459
+ });
460
+ }
461
+ //
462
+ return res.data;
463
+ };
464
+ var SanedFilterConditionValue;
465
+ (function (SanedFilterConditionValue) {
466
+ SanedFilterConditionValue[SanedFilterConditionValue["Equal"] = 0] = "Equal";
467
+ SanedFilterConditionValue[SanedFilterConditionValue["GreaterThan"] = 1] = "GreaterThan";
468
+ SanedFilterConditionValue[SanedFilterConditionValue["GreaterThanOrEqual"] = 2] = "GreaterThanOrEqual";
469
+ SanedFilterConditionValue[SanedFilterConditionValue["IN"] = 3] = "IN";
470
+ SanedFilterConditionValue[SanedFilterConditionValue["LessThen"] = 4] = "LessThen";
471
+ SanedFilterConditionValue[SanedFilterConditionValue["LessThenorEqual"] = 5] = "LessThenorEqual";
472
+ SanedFilterConditionValue[SanedFilterConditionValue["NotEqual"] = 6] = "NotEqual";
473
+ SanedFilterConditionValue[SanedFilterConditionValue["NotIN"] = 7] = "NotIN";
474
+ SanedFilterConditionValue[SanedFilterConditionValue["REGEX"] = 8] = "REGEX";
475
+ })(SanedFilterConditionValue || (SanedFilterConditionValue = {}));
476
+ class ApiService {
477
+ /**
478
+ * Constructor
479
+ */
480
+ constructor(_httpClient) {
481
+ this._httpClient = _httpClient;
482
+ this.baseUrl = "";
483
+ this.baseUri = "";
484
+ this.module = "";
485
+ this.entity = "";
486
+ this.path = "page";
487
+ this.version = "v1";
488
+ this._initBaseUrl();
489
+ }
490
+ _initService(module, entity, version, baseUri, path) {
491
+ this.module = module;
492
+ this.entity = entity;
493
+ this.version = version ?? this.version;
494
+ this.baseUri = baseUri ?? this.baseUri;
495
+ this.path = path ?? this.path;
496
+ this._initBaseUrl();
497
+ }
498
+ _initBaseUrl() {
499
+ this.baseUrl = `${this.baseUri}/api/default/${this.module}/${this.entity}/${this.version}`;
500
+ }
501
+ getPaged(query) {
502
+ return this._httpClient
503
+ .post(`${this.baseUrl}/${this.path}`, query)
504
+ .pipe(map((response) => {
505
+ console.log(response);
506
+ return this.checkResponseStatus(response);
507
+ }))
508
+ .pipe(catchError((response) => {
509
+ return throwError(response.error);
510
+ }));
511
+ }
512
+ checkResponseStatus(response) {
513
+ if (response?.status === 200) {
514
+ return getMappedData(response);
515
+ }
516
+ else {
517
+ return null;
518
+ }
519
+ }
520
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
521
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiService, providedIn: "root" }); }
522
+ }
523
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiService, decorators: [{
524
+ type: Injectable,
525
+ args: [{
526
+ providedIn: "root",
527
+ }]
528
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
529
+
530
+ class KitsngFetchTableFactoryComponent {
531
+ constructor(apiService) {
532
+ this.apiService = apiService;
533
+ this.destroy$ = new Subject();
534
+ }
535
+ ngOnInit() {
536
+ if (this.tableConfig.fetchApiInfo) {
537
+ this.apiService._initService(this.tableConfig.fetchApiInfo?.module, this.tableConfig.fetchApiInfo?.entity, this.tableConfig.fetchApiInfo?.version ?? "v1", this.tableConfig.fetchApiInfo?.baseUri ?? "", this.tableConfig.fetchApiInfo?.path ?? "page");
538
+ if (this.tableConfig.fetchApiInfo?._getData) {
539
+ this._getData = this.tableConfig.fetchApiInfo._getData;
540
+ }
541
+ else {
542
+ this._getData = new Subject();
543
+ }
544
+ this.getData$ = this._getData.asObservable();
545
+ this.subscribeToData();
546
+ this._getData.next();
547
+ }
548
+ }
549
+ getNestedValue(data, field) {
550
+ return get(data, field);
551
+ }
552
+ resolveActionProperty(property, item) {
553
+ if (typeof property === 'function') {
554
+ return property(item);
555
+ }
556
+ return property;
557
+ }
558
+ onSelectChange(event) {
559
+ if (this.tableConfig?.onSelectedItems) {
560
+ this.tableConfig?.onSelectedItems(this.tableConfig?.selectedItems);
561
+ }
562
+ }
563
+ subscribeToData() {
564
+ this.getData$
565
+ .pipe(takeUntil(this.destroy$))
566
+ .pipe(debounceTime(500)).subscribe(() => {
567
+ let query = {
568
+ pageIndex: this.tableConfig?.pageIndex ?? 1,
569
+ pageSize: this.tableConfig?.pageSize ?? 10,
570
+ };
571
+ if (this.tableConfig.fetchApiInfo?.searchWord != null ||
572
+ this.tableConfig.fetchApiInfo?.searchWord != undefined) {
573
+ query["search"] = this.tableConfig.fetchApiInfo?.searchWord;
574
+ }
575
+ if (this.tableConfig.fetchApiInfo?.filters) {
576
+ query["filters"] = this.tableConfig.fetchApiInfo?.filters;
577
+ }
578
+ if (this.tableConfig.fetchApiInfo?.orders) {
579
+ query["orders"] = this.tableConfig.fetchApiInfo?.orders;
580
+ }
581
+ if (this.tableConfig.fetchApiInfo?.queryMapper) {
582
+ query = this.tableConfig.fetchApiInfo.queryMapper(query) || query;
583
+ }
584
+ this.apiService._initService(this.tableConfig.fetchApiInfo?.module || "", this.tableConfig.fetchApiInfo?.entity || "", this.tableConfig.fetchApiInfo?.version || "v1", this.tableConfig.fetchApiInfo?.baseUri || "", this.tableConfig.fetchApiInfo?.path || "page");
585
+ this.apiService.getPaged(query)
586
+ .pipe(takeUntil(this.destroy$)).subscribe({
587
+ next: (res) => {
588
+ if (!res.pageInfo && res.page) {
589
+ res.pageInfo = res.page;
590
+ }
591
+ this.tableConfig.totalRecords = res.pageInfo.totalItems;
592
+ this.tableConfig.data = res.items ?? [];
593
+ if (this.tableConfig.fetchApiInfo?.onDataLoaded) {
594
+ this.tableConfig.fetchApiInfo.onDataLoaded(this.tableConfig.data, res.pageInfo);
595
+ }
596
+ },
597
+ error: (error) => {
598
+ if (this.tableConfig?.fetchApiInfo?.onFetchDataError) {
599
+ this.tableConfig.fetchApiInfo.onFetchDataError(error);
600
+ }
601
+ },
602
+ });
603
+ });
604
+ }
605
+ customSort(sort) {
606
+ if (this.tableConfig?.onSorting) {
607
+ this.tableConfig?.onSorting(sort);
608
+ }
609
+ else {
610
+ if (this.tableConfig.fetchApiInfo) {
611
+ const order = sort.order == 1 ? 0 : 1;
612
+ if (!this.tableConfig.fetchApiInfo?.orders) {
613
+ this.tableConfig.fetchApiInfo.orders = {};
614
+ }
615
+ if (sort?.field &&
616
+ this.tableConfig.fetchApiInfo?.orders &&
617
+ this.tableConfig.fetchApiInfo?.orders[sort?.field] != order) {
618
+ this.tableConfig.fetchApiInfo.orders[sort.field] = order;
619
+ this.tableConfig.fetchApiInfo.orders = Object.fromEntries(Object.entries(this.tableConfig.fetchApiInfo.orders).filter(([key]) => [sort?.field].includes(key)));
620
+ this._getData.next();
621
+ }
622
+ }
623
+ }
624
+ }
625
+ pageChanged(event) {
626
+ if (this.tableConfig?.onPageChanged) {
627
+ this.tableConfig?.onPageChanged(event);
628
+ }
629
+ else {
630
+ if (event.first != this.tableConfig.first ||
631
+ event.rows != this.tableConfig?.pageSize) {
632
+ this.tableConfig.first = event.first;
633
+ this.tableConfig.pageSize = event.rows;
634
+ this.tableConfig.pageIndex = event.page + 1;
635
+ this._getData.next();
636
+ }
637
+ else {
638
+ console.log("No Change in Page");
639
+ }
640
+ }
641
+ }
642
+ ngOnDestroy() {
643
+ this.destroy$.next(true);
644
+ }
645
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFetchTableFactoryComponent, deps: [{ token: ApiService }], target: i0.ɵɵFactoryTarget.Component }); }
646
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.8", type: KitsngFetchTableFactoryComponent, selector: "kitsng-fetch-table-factory", inputs: { tableConfig: "tableConfig" }, providers: [ApiService], ngImport: i0, template: `
647
+ <div class="grid row {{ tableConfig.containerClass ?? 'border-round-3xl' }}">
648
+ <div class="col-12">
649
+ <ng-container *ngIf="tableConfig.tableTemplate;else defaultTableTemplate">
650
+ <ng-container *ngTemplateOutlet="tableConfig.tableTemplate;context: { $implicit: tableConfig, defaultTemplate: defaultTableTemplate}"></ng-container>
651
+ </ng-container>
652
+ <ng-template #defaultTableTemplate>
653
+ <p-table
654
+ [dataKey]="tableConfig.dataKey"
655
+ [value]="tableConfig.data"
656
+ [columns]="tableConfig.columns"
657
+ [styleClass]="
658
+ (tableConfig.class ?? 'border-round-xl border-2 border-gray-200') + (tableConfig.showGridlines ? ' p-datatable-gridlines' : '') + (tableConfig.stripedRows ? ' p-datatable-striped' : '')
659
+ "
660
+ [(selection)]="tableConfig.selectedItems"
661
+ [selectionMode]="'single'"
662
+ (selectionChange)="onSelectChange($event)"
663
+ [rowHover]="tableConfig.rowHover ?? true"
664
+ [rows]="tableConfig.pageSize"
665
+ [first]="tableConfig.first"
666
+ [showCurrentPageReport]="
667
+ tableConfig.currentPageReportTemplate ? true : false
668
+ "
669
+ [rowsPerPageOptions]="
670
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
671
+ "
672
+ [paginator]="false"
673
+ [resizableColumns]="tableConfig.resizableColumns ?? true"
674
+ [scrollable]="tableConfig.scrollable ?? true"
675
+ [totalRecords]="tableConfig.totalRecords ?? 0"
676
+ [tableStyle]="tableConfig.tableStyle ?? { 'min-width': '50rem' }"
677
+ [currentPageReportTemplate]="
678
+ tableConfig.currentPageReportTemplate ??
679
+ 'Showing {first} to {last} of {totalRecords} entity'
680
+ "
681
+ (onPage)="pageChanged($event)"
682
+ (sortFunction)="customSort($event)"
683
+ [customSort]="true"
684
+ >
685
+ <ng-template pTemplate="header" let-columns>
686
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
687
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
688
+ </ng-container>
689
+ <ng-template #defaultHeaderTemplate>
690
+ <tr>
691
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox" pFrozenColumn [frozen]="true">
692
+ <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
693
+ </th>
694
+ <th
695
+ *ngFor="let col of columns"
696
+ [pSortableColumn]="col.field"
697
+ [pSortableColumnDisabled]="!col.sortable"
698
+ pFrozenColumn
699
+ [frozen]="col?.isFrozen ?? false"
700
+ [alignFrozen]="col?.alignFrozen"
701
+ [ngStyle]="col?.headerCellStyle ?? {}"
702
+ [class]="col?.headerCellClass ?? ''"
703
+ >
704
+ <div class="">
705
+ {{ (col.header||'')|translate }}
706
+ <p-sortIcon
707
+ *ngIf="col.sortable"
708
+ [field]="col.field"
709
+ ></p-sortIcon>
710
+ </div>
711
+ </th>
712
+ <th
713
+ [ngStyle]="
714
+ tableConfig.actionCellHeaderStyle ?? { width: '138px' }
715
+ "
716
+ *ngIf="
717
+ (tableConfig.actionButtons?.length ?? -1) > 0 ||
718
+ tableConfig.actionTemplate
719
+ "
720
+ pFrozenColumn
721
+ [frozen]="tableConfig.actionIsFrozen || false"
722
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'"
723
+ >
724
+ {{'Actions'|translate}}
725
+ </th>
726
+ </tr>
727
+ </ng-template>
728
+ </ng-template>
729
+
730
+ <ng-template pTemplate="body" let-item let-columns="columns">
731
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
732
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: item, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
733
+ </ng-container>
734
+ <ng-template #defaultBodyTemplate>
735
+ <tr class="">
736
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" pFrozenColumn [frozen]="true">
737
+ <p-tableCheckbox [value]="item"></p-tableCheckbox>
738
+ </td>
739
+ <td
740
+ *ngFor="let column of columns"
741
+ [ngStyle]="column?.bodyCellStyle ?? {}"
742
+ [class]="column?.bodyCellClass ?? ''"
743
+ pFrozenColumn
744
+ [frozen]="column?.isFrozen ?? false"
745
+ [alignFrozen]="column?.alignFrozen"
746
+ >
747
+ <ng-container *ngIf="column.template; else defaultTemplate">
748
+ <ng-container
749
+ *ngTemplateOutlet="
750
+ column.template;
751
+ context: {
752
+ $implicit: getNestedValue(item, column.field),
753
+ column: column,
754
+ rowData: item
755
+ }
756
+ "
757
+ ></ng-container>
758
+ </ng-container>
759
+ <ng-template #defaultTemplate>
760
+ {{
761
+ getNestedValue(item, column.field)
762
+ | dynamicPipe : column.pipes ?? []
763
+ }}
764
+ </ng-template>
765
+ </td>
766
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
767
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
768
+ pFrozenColumn
769
+ [frozen]="tableConfig.actionIsFrozen || false"
770
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
771
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
772
+ <ng-container *ngIf="tableConfig.actionTemplate">
773
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: item }"></ng-container>
774
+ </ng-container>
775
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
776
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
777
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: item, defaultTemplate: defaultButtonTemplate }"></ng-container>
778
+ </ng-container>
779
+ <ng-template #defaultButtonTemplate>
780
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, item) !== false) && !resolveActionProperty(action.hidden, item)">
781
+ <p-button
782
+ [icon]="resolveActionProperty(action.icon, item)"
783
+ [iconPos]="resolveActionProperty(action.iconPos, item) ?? 'left'"
784
+ [label]="(resolveActionProperty(action.label, item)||'')|translate"
785
+ [pTooltip]="resolveActionProperty(action.tooltip, item)"
786
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, item) ?? 'top'"
787
+ [disabled]="resolveActionProperty(action.disabled, item)"
788
+ [severity]="resolveActionProperty(action.severity, item)"
789
+ [rounded]="resolveActionProperty(action.rounded, item)"
790
+ [outlined]="resolveActionProperty(action.outlined, item)"
791
+ [text]="resolveActionProperty(action.text, item)"
792
+ [raised]="resolveActionProperty(action.raised, item)"
793
+ [plain]="resolveActionProperty(action.plain, item)"
794
+ [size]="resolveActionProperty(action.size, item)"
795
+ [badge]="resolveActionProperty(action.badge, item)"
796
+ [badgeClass]="resolveActionProperty(action.badgeClass, item)"
797
+ styleClass="{{resolveActionProperty(action.buttonClass, item) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, item)}}"
798
+ (onClick)="action.onClick? action.onClick(item) : false"
799
+ ></p-button>
800
+ </ng-container>
801
+ </ng-template>
802
+ </ng-container>
803
+ </div>
804
+ </td>
805
+ </ng-container>
806
+ </tr>
807
+ </ng-template>
808
+ </ng-template>
809
+
810
+ <ng-container *ngIf="tableConfig.captionTemplate">
811
+ <ng-template pTemplate="caption">
812
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
813
+ </ng-template>
814
+ </ng-container>
815
+
816
+ <ng-container *ngIf="tableConfig.footerTemplate">
817
+ <ng-template pTemplate="footer">
818
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
819
+ </ng-template>
820
+ </ng-container>
821
+
822
+ <ng-container *ngIf="tableConfig.summaryTemplate">
823
+ <ng-template pTemplate="summary">
824
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
825
+ </ng-template>
826
+ </ng-container>
827
+
828
+ <ng-template pTemplate="emptymessage">
829
+ <ng-container
830
+ *ngIf="
831
+ tableConfig.emptymessageTemplate;
832
+ else defaultMessageTemplate
833
+ "
834
+ >
835
+ <ng-container
836
+ *ngTemplateOutlet="tableConfig.emptymessageTemplate"
837
+ ></ng-container>
838
+ </ng-container>
839
+ <ng-template #defaultMessageTemplate>
840
+ <tr>
841
+ <td
842
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
843
+ class="text-center"
844
+ >
845
+ {{ tableConfig.emptymessage ?? "No Data Found." }}
846
+ </td>
847
+ </tr>
848
+ </ng-template>
849
+ </ng-template>
850
+ </p-table>
851
+ </ng-template>
852
+ <p-paginator
853
+ *ngIf="tableConfig.showPaginator ?? true"
854
+ [styleClass]="tableConfig.paginatorClass ?? 'mt-3'"
855
+ (onPageChange)="pageChanged($event)"
856
+ [first]="tableConfig.first ?? 0"
857
+ [rows]="tableConfig.pageSize ?? 0"
858
+ [totalRecords]="tableConfig.totalRecords ?? 0"
859
+ [rowsPerPageOptions]="
860
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
861
+ "
862
+ ></p-paginator>
863
+ </div>
864
+ </div>
865
+ `, isInline: true, dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2$1.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "selectAll", "virtualRowHeight"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i2$1.SortableColumn, selector: "[pSortableColumn]", inputs: ["pSortableColumn", "pSortableColumnDisabled"] }, { kind: "directive", type: i2$1.FrozenColumn, selector: "[pFrozenColumn]", inputs: ["frozen", "alignFrozen"] }, { kind: "component", type: i2$1.SortIcon, selector: "p-sortIcon", inputs: ["field"] }, { kind: "component", type: i2$1.TableCheckbox, selector: "p-tableCheckbox", inputs: ["disabled", "value", "index", "inputId", "name", "required", "ariaLabel"] }, { kind: "component", type: i2$1.TableHeaderCheckbox, selector: "p-tableHeaderCheckbox", inputs: ["disabled", "inputId", "name", "ariaLabel"] }, { kind: "component", type: i5.Paginator, selector: "p-paginator", inputs: ["pageLinkSize", "style", "styleClass", "alwaysShow", "dropdownAppendTo", "templateLeft", "templateRight", "appendTo", "dropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showFirstLastIcon", "totalRecords", "rows", "rowsPerPageOptions", "showJumpToPageDropdown", "showJumpToPageInput", "jumpToPageItemTemplate", "showPageLinks", "locale", "dropdownItemTemplate", "first"], outputs: ["onPageChange"] }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "style", "styleClass", "badgeClass", "ariaLabel", "autofocus"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: i7.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }, { kind: "pipe", type: DynamicPipe, name: "dynamicPipe" }] }); }
866
+ }
867
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFetchTableFactoryComponent, decorators: [{
868
+ type: Component,
869
+ args: [{ selector: "kitsng-fetch-table-factory", template: `
870
+ <div class="grid row {{ tableConfig.containerClass ?? 'border-round-3xl' }}">
871
+ <div class="col-12">
872
+ <ng-container *ngIf="tableConfig.tableTemplate;else defaultTableTemplate">
873
+ <ng-container *ngTemplateOutlet="tableConfig.tableTemplate;context: { $implicit: tableConfig, defaultTemplate: defaultTableTemplate}"></ng-container>
874
+ </ng-container>
875
+ <ng-template #defaultTableTemplate>
876
+ <p-table
877
+ [dataKey]="tableConfig.dataKey"
878
+ [value]="tableConfig.data"
879
+ [columns]="tableConfig.columns"
880
+ [styleClass]="
881
+ (tableConfig.class ?? 'border-round-xl border-2 border-gray-200') + (tableConfig.showGridlines ? ' p-datatable-gridlines' : '') + (tableConfig.stripedRows ? ' p-datatable-striped' : '')
882
+ "
883
+ [(selection)]="tableConfig.selectedItems"
884
+ [selectionMode]="'single'"
885
+ (selectionChange)="onSelectChange($event)"
886
+ [rowHover]="tableConfig.rowHover ?? true"
887
+ [rows]="tableConfig.pageSize"
888
+ [first]="tableConfig.first"
889
+ [showCurrentPageReport]="
890
+ tableConfig.currentPageReportTemplate ? true : false
891
+ "
892
+ [rowsPerPageOptions]="
893
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
894
+ "
895
+ [paginator]="false"
896
+ [resizableColumns]="tableConfig.resizableColumns ?? true"
897
+ [scrollable]="tableConfig.scrollable ?? true"
898
+ [totalRecords]="tableConfig.totalRecords ?? 0"
899
+ [tableStyle]="tableConfig.tableStyle ?? { 'min-width': '50rem' }"
900
+ [currentPageReportTemplate]="
901
+ tableConfig.currentPageReportTemplate ??
902
+ 'Showing {first} to {last} of {totalRecords} entity'
903
+ "
904
+ (onPage)="pageChanged($event)"
905
+ (sortFunction)="customSort($event)"
906
+ [customSort]="true"
907
+ >
908
+ <ng-template pTemplate="header" let-columns>
909
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
910
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
911
+ </ng-container>
912
+ <ng-template #defaultHeaderTemplate>
913
+ <tr>
914
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox" pFrozenColumn [frozen]="true">
915
+ <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
916
+ </th>
917
+ <th
918
+ *ngFor="let col of columns"
919
+ [pSortableColumn]="col.field"
920
+ [pSortableColumnDisabled]="!col.sortable"
921
+ pFrozenColumn
922
+ [frozen]="col?.isFrozen ?? false"
923
+ [alignFrozen]="col?.alignFrozen"
924
+ [ngStyle]="col?.headerCellStyle ?? {}"
925
+ [class]="col?.headerCellClass ?? ''"
926
+ >
927
+ <div class="">
928
+ {{ (col.header||'')|translate }}
929
+ <p-sortIcon
930
+ *ngIf="col.sortable"
931
+ [field]="col.field"
932
+ ></p-sortIcon>
933
+ </div>
934
+ </th>
935
+ <th
936
+ [ngStyle]="
937
+ tableConfig.actionCellHeaderStyle ?? { width: '138px' }
938
+ "
939
+ *ngIf="
940
+ (tableConfig.actionButtons?.length ?? -1) > 0 ||
941
+ tableConfig.actionTemplate
942
+ "
943
+ pFrozenColumn
944
+ [frozen]="tableConfig.actionIsFrozen || false"
945
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'"
946
+ >
947
+ {{'Actions'|translate}}
948
+ </th>
949
+ </tr>
950
+ </ng-template>
951
+ </ng-template>
952
+
953
+ <ng-template pTemplate="body" let-item let-columns="columns">
954
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
955
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: item, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
956
+ </ng-container>
957
+ <ng-template #defaultBodyTemplate>
958
+ <tr class="">
959
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" pFrozenColumn [frozen]="true">
960
+ <p-tableCheckbox [value]="item"></p-tableCheckbox>
961
+ </td>
962
+ <td
963
+ *ngFor="let column of columns"
964
+ [ngStyle]="column?.bodyCellStyle ?? {}"
965
+ [class]="column?.bodyCellClass ?? ''"
966
+ pFrozenColumn
967
+ [frozen]="column?.isFrozen ?? false"
968
+ [alignFrozen]="column?.alignFrozen"
969
+ >
970
+ <ng-container *ngIf="column.template; else defaultTemplate">
971
+ <ng-container
972
+ *ngTemplateOutlet="
973
+ column.template;
974
+ context: {
975
+ $implicit: getNestedValue(item, column.field),
976
+ column: column,
977
+ rowData: item
978
+ }
979
+ "
980
+ ></ng-container>
981
+ </ng-container>
982
+ <ng-template #defaultTemplate>
983
+ {{
984
+ getNestedValue(item, column.field)
985
+ | dynamicPipe : column.pipes ?? []
986
+ }}
987
+ </ng-template>
988
+ </td>
989
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
990
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
991
+ pFrozenColumn
992
+ [frozen]="tableConfig.actionIsFrozen || false"
993
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
994
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
995
+ <ng-container *ngIf="tableConfig.actionTemplate">
996
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: item }"></ng-container>
997
+ </ng-container>
998
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
999
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
1000
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: item, defaultTemplate: defaultButtonTemplate }"></ng-container>
1001
+ </ng-container>
1002
+ <ng-template #defaultButtonTemplate>
1003
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, item) !== false) && !resolveActionProperty(action.hidden, item)">
1004
+ <p-button
1005
+ [icon]="resolveActionProperty(action.icon, item)"
1006
+ [iconPos]="resolveActionProperty(action.iconPos, item) ?? 'left'"
1007
+ [label]="(resolveActionProperty(action.label, item)||'')|translate"
1008
+ [pTooltip]="resolveActionProperty(action.tooltip, item)"
1009
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, item) ?? 'top'"
1010
+ [disabled]="resolveActionProperty(action.disabled, item)"
1011
+ [severity]="resolveActionProperty(action.severity, item)"
1012
+ [rounded]="resolveActionProperty(action.rounded, item)"
1013
+ [outlined]="resolveActionProperty(action.outlined, item)"
1014
+ [text]="resolveActionProperty(action.text, item)"
1015
+ [raised]="resolveActionProperty(action.raised, item)"
1016
+ [plain]="resolveActionProperty(action.plain, item)"
1017
+ [size]="resolveActionProperty(action.size, item)"
1018
+ [badge]="resolveActionProperty(action.badge, item)"
1019
+ [badgeClass]="resolveActionProperty(action.badgeClass, item)"
1020
+ styleClass="{{resolveActionProperty(action.buttonClass, item) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, item)}}"
1021
+ (onClick)="action.onClick? action.onClick(item) : false"
1022
+ ></p-button>
1023
+ </ng-container>
1024
+ </ng-template>
1025
+ </ng-container>
1026
+ </div>
1027
+ </td>
1028
+ </ng-container>
1029
+ </tr>
1030
+ </ng-template>
1031
+ </ng-template>
1032
+
1033
+ <ng-container *ngIf="tableConfig.captionTemplate">
1034
+ <ng-template pTemplate="caption">
1035
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
1036
+ </ng-template>
1037
+ </ng-container>
1038
+
1039
+ <ng-container *ngIf="tableConfig.footerTemplate">
1040
+ <ng-template pTemplate="footer">
1041
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
1042
+ </ng-template>
1043
+ </ng-container>
1044
+
1045
+ <ng-container *ngIf="tableConfig.summaryTemplate">
1046
+ <ng-template pTemplate="summary">
1047
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
1048
+ </ng-template>
1049
+ </ng-container>
1050
+
1051
+ <ng-template pTemplate="emptymessage">
1052
+ <ng-container
1053
+ *ngIf="
1054
+ tableConfig.emptymessageTemplate;
1055
+ else defaultMessageTemplate
1056
+ "
1057
+ >
1058
+ <ng-container
1059
+ *ngTemplateOutlet="tableConfig.emptymessageTemplate"
1060
+ ></ng-container>
1061
+ </ng-container>
1062
+ <ng-template #defaultMessageTemplate>
1063
+ <tr>
1064
+ <td
1065
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
1066
+ class="text-center"
1067
+ >
1068
+ {{ tableConfig.emptymessage ?? "No Data Found." }}
1069
+ </td>
1070
+ </tr>
1071
+ </ng-template>
1072
+ </ng-template>
1073
+ </p-table>
1074
+ </ng-template>
1075
+ <p-paginator
1076
+ *ngIf="tableConfig.showPaginator ?? true"
1077
+ [styleClass]="tableConfig.paginatorClass ?? 'mt-3'"
1078
+ (onPageChange)="pageChanged($event)"
1079
+ [first]="tableConfig.first ?? 0"
1080
+ [rows]="tableConfig.pageSize ?? 0"
1081
+ [totalRecords]="tableConfig.totalRecords ?? 0"
1082
+ [rowsPerPageOptions]="
1083
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
1084
+ "
1085
+ ></p-paginator>
1086
+ </div>
1087
+ </div>
1088
+ `, providers: [ApiService] }]
1089
+ }], ctorParameters: () => [{ type: ApiService }], propDecorators: { tableConfig: [{
1090
+ type: Input,
1091
+ args: [{ required: true }]
1092
+ }] } });
1093
+
1094
+ class KitsngTreeTableFactoryComponent {
1095
+ constructor(apiService, cd) {
1096
+ this.apiService = apiService;
1097
+ this.cd = cd;
1098
+ this.treeData = []; // TreeNode data structure for PrimeNG tree table
1099
+ this.loading = false;
1100
+ this.destroy$ = new Subject();
1101
+ }
1102
+ ngOnInit() {
1103
+ if (this.tableConfig.fetchApiInfo) {
1104
+ this.apiService._initService(this.tableConfig.fetchApiInfo?.module, this.tableConfig.fetchApiInfo?.entity, this.tableConfig.fetchApiInfo?.version ?? "v1", this.tableConfig.fetchApiInfo?.baseUri ?? "", this.tableConfig.fetchApiInfo?.path ?? "page");
1105
+ this._getData = this.tableConfig.fetchApiInfo._getData ?? new Subject();
1106
+ this.getData$ = this._getData.asObservable();
1107
+ this.subscribeToData();
1108
+ this._getData.next();
1109
+ }
1110
+ else {
1111
+ if (this.tableConfig?.data?.length > 0) {
1112
+ this.treeData = this.tableConfig.data.map((item) => {
1113
+ return this.convertToTreeDataWithChildren(item);
1114
+ });
1115
+ this.cd.markForCheck();
1116
+ }
1117
+ }
1118
+ }
1119
+ getNestedValue(data, field) {
1120
+ return get(data, field);
1121
+ }
1122
+ resolveActionProperty(property, item) {
1123
+ if (typeof property === 'function') {
1124
+ return property(item);
1125
+ }
1126
+ return property;
1127
+ }
1128
+ onSelectChange(event) {
1129
+ this.tableConfig?.onSelectedItems?.(this.tableConfig.selectedItems);
1130
+ }
1131
+ subscribeToData() {
1132
+ this.getData$
1133
+ .pipe(takeUntil(this.destroy$)).pipe(debounceTime(500)).subscribe(() => {
1134
+ const query = {
1135
+ pageIndex: this.tableConfig?.pageIndex ?? 1,
1136
+ pageSize: this.tableConfig?.pageSize ?? 10,
1137
+ search: this.tableConfig.fetchApiInfo?.searchWord,
1138
+ filters: this.tableConfig.fetchApiInfo?.filters,
1139
+ orders: this.tableConfig.fetchApiInfo?.orders,
1140
+ };
1141
+ this.loading = true;
1142
+ this.apiService.getPaged(query)
1143
+ .pipe(takeUntil(this.destroy$)).subscribe({
1144
+ next: (res) => {
1145
+ if (!res.pageInfo && res.page) {
1146
+ res.pageInfo = res.page;
1147
+ }
1148
+ this.tableConfig.data = res.items;
1149
+ this.tableConfig.totalRecords = res.pageInfo.totalItems;
1150
+ if (this.tableConfig.fetchApiInfo?.onDataLoaded) {
1151
+ this.tableConfig.fetchApiInfo.onDataLoaded(this.tableConfig.data, res.pageInfo);
1152
+ }
1153
+ this.treeData = this.convertToTreeData(this.tableConfig.data ?? []);
1154
+ this.cd.markForCheck();
1155
+ this.loading = false;
1156
+ },
1157
+ error: (error) => {
1158
+ this.loading = false;
1159
+ if (this.tableConfig?.fetchApiInfo?.onFetchDataError) {
1160
+ this.tableConfig.fetchApiInfo.onFetchDataError(error);
1161
+ }
1162
+ },
1163
+ });
1164
+ });
1165
+ }
1166
+ convertToTreeData(data) {
1167
+ return data.map((item) => ({
1168
+ data: item,
1169
+ leaf: false,
1170
+ children: item?.[this.tableConfig?.treeChildrenKeyName ?? "items"]?.map((child) => this.convertToTreeDataWithChildren(child)) ?? [],
1171
+ }));
1172
+ }
1173
+ convertToTreeDataWithChildren(item) {
1174
+ return {
1175
+ data: item,
1176
+ leaf: !(item?.[this.tableConfig?.treeChildrenKeyName ?? "items"]?.length > 0),
1177
+ children: item?.[this.tableConfig?.treeChildrenKeyName ?? "items"]?.map((child) => this.convertToTreeDataWithChildren(child)) ?? [],
1178
+ };
1179
+ }
1180
+ loadNodeChildren(node) {
1181
+ if (node.children && node.children.length > 0)
1182
+ return;
1183
+ if (!this.tableConfig.fetchApiInfo)
1184
+ return;
1185
+ this.loading = true;
1186
+ const query = {
1187
+ filters: {
1188
+ ...this.tableConfig.treeNodeChildrenFilters,
1189
+ [this.tableConfig.treeNodeChildrenFilterKey ?? "parentId"]: { value: node.data[this.tableConfig.treeNodeChildrenFilterValue ?? "id"] }
1190
+ }
1191
+ };
1192
+ this.apiService.getPaged(query)
1193
+ .pipe(takeUntil(this.destroy$)).subscribe({
1194
+ next: (response) => {
1195
+ const children = response.items;
1196
+ node.children = this.convertToTreeData(children);
1197
+ node.leaf = response.items.length <= 0;
1198
+ this.loading = false;
1199
+ this.treeData = [...this.treeData];
1200
+ this.cd.markForCheck();
1201
+ },
1202
+ error: (error) => {
1203
+ console.error("Error loading children:", error);
1204
+ // node.leaf = true;
1205
+ this.loading = false;
1206
+ },
1207
+ });
1208
+ }
1209
+ customSort(sort) {
1210
+ if (this.tableConfig?.onSorting) {
1211
+ this.tableConfig?.onSorting(sort);
1212
+ }
1213
+ else {
1214
+ if (this.tableConfig.fetchApiInfo) {
1215
+ const order = sort.order == 1 ? 0 : 1;
1216
+ if (!this.tableConfig.fetchApiInfo?.orders) {
1217
+ this.tableConfig.fetchApiInfo.orders = {};
1218
+ }
1219
+ if (sort?.field &&
1220
+ this.tableConfig.fetchApiInfo?.orders &&
1221
+ this.tableConfig.fetchApiInfo?.orders[sort?.field] != order) {
1222
+ this.tableConfig.fetchApiInfo.orders[sort.field] = order;
1223
+ this.tableConfig.fetchApiInfo.orders = Object.fromEntries(Object.entries(this.tableConfig.fetchApiInfo.orders).filter(([key]) => [sort?.field].includes(key)));
1224
+ this._getData.next();
1225
+ }
1226
+ }
1227
+ }
1228
+ }
1229
+ pageChanged(event) {
1230
+ if (this.tableConfig?.onPageChanged) {
1231
+ this.tableConfig?.onPageChanged(event);
1232
+ }
1233
+ else {
1234
+ if (event.first != this.tableConfig.first ||
1235
+ event.rows != this.tableConfig?.pageSize) {
1236
+ this.tableConfig.first = event.first;
1237
+ this.tableConfig.pageSize = event.rows;
1238
+ this.tableConfig.pageIndex = event.page + 1;
1239
+ this._getData.next();
1240
+ }
1241
+ else {
1242
+ console.log("No Change in Page");
1243
+ }
1244
+ }
1245
+ }
1246
+ ngOnDestroy() {
1247
+ this.destroy$.next(true);
1248
+ }
1249
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTreeTableFactoryComponent, deps: [{ token: ApiService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
1250
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.8", type: KitsngTreeTableFactoryComponent, selector: "kitsng-tree-table-factory", inputs: { tableConfig: "tableConfig" }, providers: [ApiService], ngImport: i0, template: `
1251
+ <div class="grid row {{ tableConfig.containerClass }}">
1252
+ <div class="col-12">
1253
+ <p-treeTable
1254
+ [dataKey]="tableConfig.dataKey"
1255
+ [value]="treeData"
1256
+ [columns]="tableConfig.columns"
1257
+ [styleClass]="tableConfig.treeClass"
1258
+ [style]="tableConfig.treeStyle ?? {}"
1259
+ [tableStyle]="tableConfig.tableStyle ?? {}"
1260
+ [tableStyleClass]="
1261
+ (tableConfig.class ?? '') + (tableConfig.showGridlines ? ' p-treetable-gridlines border-round-xl border-2 border-gray-200' : '')
1262
+ "
1263
+ [(selection)]="tableConfig.selectedItems"
1264
+ [selectionMode]="'single'"
1265
+ (selectionChange)="onSelectChange($event)"
1266
+ [rowHover]="tableConfig.rowHover ?? false"
1267
+ [rows]="tableConfig.pageSize"
1268
+ [paginator]="tableConfig.showClientPaginator ?? false"
1269
+ [customSort]="tableConfig.fetchApiInfo? true: false"
1270
+ [resizableColumns]="tableConfig.resizableColumns ?? false"
1271
+ [scrollable]="tableConfig.scrollable ?? false"
1272
+ [first]="tableConfig.first"
1273
+ [showCurrentPageReport]="tableConfig.currentPageReportTemplate? true: false"
1274
+ [lazy]="(tableConfig.fetchApiInfo? true : false) && (tableConfig.treeLazyLoad ?? true)"
1275
+ [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"
1276
+ [totalRecords]="tableConfig.totalRecords ?? 0"
1277
+ [loading]="tableConfig.treeShowLoader && loading"
1278
+ (sortFunction)="customSort($event)"
1279
+ (onNodeExpand)="loadNodeChildren($event.node)"
1280
+ >
1281
+ <ng-template pTemplate="header" let-columns>
1282
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
1283
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
1284
+ </ng-container>
1285
+ <ng-template #defaultHeaderTemplate>
1286
+ <tr>
1287
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox">
1288
+ <p-treeTableHeaderCheckbox></p-treeTableHeaderCheckbox>
1289
+ </th>
1290
+ <th
1291
+ *ngFor="let col of columns"
1292
+ [ttSortableColumn]="col.field"
1293
+ [ttSortableColumnDisabled]="!col.sortable"
1294
+ [ngStyle]="col?.headerCellStyle ?? {}"
1295
+ [class]="col?.headerCellClass ?? ''"
1296
+ >
1297
+ <div class="">
1298
+ {{ (col.header||'')|translate }}
1299
+ <p-treeTableSortIcon *ngIf="col.sortable" [field]="col.field"></p-treeTableSortIcon>
1300
+ </div>
1301
+ </th>
1302
+ <th
1303
+ [ngStyle]="
1304
+ tableConfig.actionCellHeaderStyle ?? { width: '138px' }
1305
+ "
1306
+ *ngIf="
1307
+ (tableConfig.actionButtons?.length ?? -1) > 0 ||
1308
+ tableConfig.actionTemplate
1309
+ "
1310
+ >
1311
+ {{'Actions'|translate}}
1312
+ </th>
1313
+ </tr>
1314
+ </ng-template>
1315
+ </ng-template>
1316
+
1317
+ <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
1318
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
1319
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: rowData, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
1320
+ </ng-container>
1321
+ <ng-template #defaultBodyTemplate>
1322
+ <tr class="" [ttRow]="rowNode">
1323
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" >
1324
+ <p-treeTableCheckbox [value]="rowNode"></p-treeTableCheckbox>
1325
+ </td>
1326
+ <td
1327
+ *ngFor="let column of columns; let i=index"
1328
+ [ngStyle]="column?.bodyCellStyle ?? {}"
1329
+ [class]="column?.bodyCellClass ?? ''"
1330
+ >
1331
+ <div class="{{i===0? 'flex d-flex align-items-center' : ''}}">
1332
+ <p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0" />
1333
+ <ng-container *ngIf="column.template; else defaultTemplate">
1334
+ <ng-container
1335
+ *ngTemplateOutlet="
1336
+ column.template;
1337
+ context: {
1338
+ $implicit: getNestedValue(rowData, column.field),
1339
+ column: column,
1340
+ rowData: rowData
1341
+ }
1342
+ "
1343
+ ></ng-container>
1344
+ </ng-container>
1345
+ <ng-template #defaultTemplate>
1346
+ {{
1347
+ getNestedValue(rowData, column.field)
1348
+ | dynamicPipe : column.pipes ?? []
1349
+ }}
1350
+ </ng-template>
1351
+ </div>
1352
+ </td>
1353
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
1354
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
1355
+ pFrozenColumn
1356
+ [frozen]="tableConfig.actionIsFrozen || false"
1357
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
1358
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
1359
+ <ng-container *ngIf="tableConfig.actionTemplate">
1360
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: rowData }"></ng-container>
1361
+ </ng-container>
1362
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
1363
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
1364
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: rowData, defaultTemplate: defaultButtonTemplate }"></ng-container>
1365
+ </ng-container>
1366
+ <ng-template #defaultButtonTemplate>
1367
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, rowData) !== false) && !resolveActionProperty(action.hidden, rowData)">
1368
+ <p-button
1369
+ [icon]="resolveActionProperty(action.icon, rowData)"
1370
+ [iconPos]="resolveActionProperty(action.iconPos, rowData) ?? 'left'"
1371
+ [label]="(resolveActionProperty(action.label, rowData)||'')|translate"
1372
+ [pTooltip]="resolveActionProperty(action.tooltip, rowData)"
1373
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, rowData) ?? 'top'"
1374
+ [disabled]="resolveActionProperty(action.disabled, rowData)"
1375
+ [severity]="resolveActionProperty(action.severity, rowData)"
1376
+ [rounded]="resolveActionProperty(action.rounded, rowData)"
1377
+ [outlined]="resolveActionProperty(action.outlined, rowData)"
1378
+ [text]="resolveActionProperty(action.text, rowData)"
1379
+ [raised]="resolveActionProperty(action.raised, rowData)"
1380
+ [plain]="resolveActionProperty(action.plain, rowData)"
1381
+ [size]="resolveActionProperty(action.size, rowData)"
1382
+ [badge]="resolveActionProperty(action.badge, rowData)"
1383
+ [badgeClass]="resolveActionProperty(action.badgeClass, rowData)"
1384
+ styleClass="{{resolveActionProperty(action.buttonClass, rowData) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, rowData)}}"
1385
+ (onClick)="action.onClick? action.onClick(rowData) : false"
1386
+ ></p-button>
1387
+ </ng-container>
1388
+ </ng-template>
1389
+ </ng-container>
1390
+ </div>
1391
+ </td>
1392
+ </ng-container>
1393
+ </tr>
1394
+ </ng-template>
1395
+ </ng-template>
1396
+
1397
+ <ng-container *ngIf="tableConfig.captionTemplate">
1398
+ <ng-template pTemplate="caption">
1399
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
1400
+ </ng-template>
1401
+ </ng-container>
1402
+
1403
+ <ng-container *ngIf="tableConfig.footerTemplate">
1404
+ <ng-template pTemplate="footer">
1405
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
1406
+ </ng-template>
1407
+ </ng-container>
1408
+
1409
+ <ng-container *ngIf="tableConfig.summaryTemplate">
1410
+ <ng-template pTemplate="summary">
1411
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
1412
+ </ng-template>
1413
+ </ng-container>
1414
+
1415
+ <ng-template pTemplate="emptymessage">
1416
+ <ng-container
1417
+ *ngIf="
1418
+ tableConfig.emptymessageTemplate;
1419
+ else defaultMessageTemplate
1420
+ "
1421
+ >
1422
+ <ng-container
1423
+ *ngTemplateOutlet="tableConfig.emptymessageTemplate"
1424
+ ></ng-container>
1425
+ </ng-container>
1426
+ <ng-template #defaultMessageTemplate>
1427
+ <tr>
1428
+ <td
1429
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
1430
+ class="text-center"
1431
+ >
1432
+ {{ tableConfig.emptymessage ?? "No Data Found." }}
1433
+ </td>
1434
+ </tr>
1435
+ </ng-template>
1436
+ </ng-template>
1437
+ </p-treeTable>
1438
+ <p-paginator
1439
+ *ngIf="tableConfig.showPaginator ?? true"
1440
+ [styleClass]="tableConfig.paginatorClass ?? 'mt-3'"
1441
+ (onPageChange)="pageChanged($event)"
1442
+ [first]="tableConfig.first ?? 0"
1443
+ [rows]="tableConfig.pageSize ?? 0"
1444
+ [totalRecords]="tableConfig.totalRecords ?? 0"
1445
+ [rowsPerPageOptions]="
1446
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
1447
+ "
1448
+ ></p-paginator>
1449
+ </div>
1450
+ </div>
1451
+ `, isInline: true, dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i2$1.FrozenColumn, selector: "[pFrozenColumn]", inputs: ["frozen", "alignFrozen"] }, { kind: "component", type: i5.Paginator, selector: "p-paginator", inputs: ["pageLinkSize", "style", "styleClass", "alwaysShow", "dropdownAppendTo", "templateLeft", "templateRight", "appendTo", "dropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showFirstLastIcon", "totalRecords", "rows", "rowsPerPageOptions", "showJumpToPageDropdown", "showJumpToPageInput", "jumpToPageItemTemplate", "showPageLinks", "locale", "dropdownItemTemplate", "first"], outputs: ["onPageChange"] }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "style", "styleClass", "badgeClass", "ariaLabel", "autofocus"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: i7.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "component", type: i8$1.TreeTable, selector: "p-treeTable", inputs: ["columns", "style", "styleClass", "tableStyle", "tableStyleClass", "autoLayout", "lazy", "lazyLoadOnInit", "paginator", "rows", "first", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "customSort", "selectionMode", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "compareSelectionBy", "rowHover", "loading", "loadingIcon", "showLoader", "scrollable", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "frozenColumns", "resizableColumns", "columnResizeMode", "reorderableColumns", "contextMenu", "rowTrackBy", "filters", "globalFilterFields", "filterDelay", "filterMode", "filterLocale", "paginatorLocale", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "value", "virtualRowHeight", "selectionKeys"], outputs: ["selectionChange", "contextMenuSelectionChange", "onFilter", "onNodeExpand", "onNodeCollapse", "onPage", "onSort", "onLazyLoad", "sortFunction", "onColResize", "onColReorder", "onNodeSelect", "onNodeUnselect", "onContextMenuSelect", "onHeaderCheckboxToggle", "onEditInit", "onEditComplete", "onEditCancel", "selectionKeysChange"] }, { kind: "component", type: i8$1.TreeTableToggler, selector: "p-treeTableToggler", inputs: ["rowNode"] }, { kind: "directive", type: i8$1.TTSortableColumn, selector: "[ttSortableColumn]", inputs: ["ttSortableColumn", "ttSortableColumnDisabled"] }, { kind: "component", type: i8$1.TTSortIcon, selector: "p-treeTableSortIcon", inputs: ["field", "ariaLabelDesc", "ariaLabelAsc"] }, { kind: "directive", type: i8$1.TTRow, selector: "[ttRow]", inputs: ["ttRow"] }, { kind: "component", type: i8$1.TTCheckbox, selector: "p-treeTableCheckbox", inputs: ["disabled", "value"] }, { kind: "component", type: i8$1.TTHeaderCheckbox, selector: "p-treeTableHeaderCheckbox" }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }, { kind: "pipe", type: DynamicPipe, name: "dynamicPipe" }] }); }
1452
+ }
1453
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTreeTableFactoryComponent, decorators: [{
1454
+ type: Component,
1455
+ args: [{
1456
+ selector: "kitsng-tree-table-factory",
1457
+ template: `
1458
+ <div class="grid row {{ tableConfig.containerClass }}">
1459
+ <div class="col-12">
1460
+ <p-treeTable
1461
+ [dataKey]="tableConfig.dataKey"
1462
+ [value]="treeData"
1463
+ [columns]="tableConfig.columns"
1464
+ [styleClass]="tableConfig.treeClass"
1465
+ [style]="tableConfig.treeStyle ?? {}"
1466
+ [tableStyle]="tableConfig.tableStyle ?? {}"
1467
+ [tableStyleClass]="
1468
+ (tableConfig.class ?? '') + (tableConfig.showGridlines ? ' p-treetable-gridlines border-round-xl border-2 border-gray-200' : '')
1469
+ "
1470
+ [(selection)]="tableConfig.selectedItems"
1471
+ [selectionMode]="'single'"
1472
+ (selectionChange)="onSelectChange($event)"
1473
+ [rowHover]="tableConfig.rowHover ?? false"
1474
+ [rows]="tableConfig.pageSize"
1475
+ [paginator]="tableConfig.showClientPaginator ?? false"
1476
+ [customSort]="tableConfig.fetchApiInfo? true: false"
1477
+ [resizableColumns]="tableConfig.resizableColumns ?? false"
1478
+ [scrollable]="tableConfig.scrollable ?? false"
1479
+ [first]="tableConfig.first"
1480
+ [showCurrentPageReport]="tableConfig.currentPageReportTemplate? true: false"
1481
+ [lazy]="(tableConfig.fetchApiInfo? true : false) && (tableConfig.treeLazyLoad ?? true)"
1482
+ [rowsPerPageOptions]="tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]"
1483
+ [totalRecords]="tableConfig.totalRecords ?? 0"
1484
+ [loading]="tableConfig.treeShowLoader && loading"
1485
+ (sortFunction)="customSort($event)"
1486
+ (onNodeExpand)="loadNodeChildren($event.node)"
1487
+ >
1488
+ <ng-template pTemplate="header" let-columns>
1489
+ <ng-container *ngIf="tableConfig.headerTemplate; else defaultHeaderTemplate">
1490
+ <ng-container *ngTemplateOutlet="tableConfig.headerTemplate;context: { $implicit: columns, defaultTemplate: defaultHeaderTemplate, tableConfig: tableConfig}"></ng-container>
1491
+ </ng-container>
1492
+ <ng-template #defaultHeaderTemplate>
1493
+ <tr>
1494
+ <th style="width: 4rem" *ngIf="tableConfig.showSelectionCheckbox">
1495
+ <p-treeTableHeaderCheckbox></p-treeTableHeaderCheckbox>
1496
+ </th>
1497
+ <th
1498
+ *ngFor="let col of columns"
1499
+ [ttSortableColumn]="col.field"
1500
+ [ttSortableColumnDisabled]="!col.sortable"
1501
+ [ngStyle]="col?.headerCellStyle ?? {}"
1502
+ [class]="col?.headerCellClass ?? ''"
1503
+ >
1504
+ <div class="">
1505
+ {{ (col.header||'')|translate }}
1506
+ <p-treeTableSortIcon *ngIf="col.sortable" [field]="col.field"></p-treeTableSortIcon>
1507
+ </div>
1508
+ </th>
1509
+ <th
1510
+ [ngStyle]="
1511
+ tableConfig.actionCellHeaderStyle ?? { width: '138px' }
1512
+ "
1513
+ *ngIf="
1514
+ (tableConfig.actionButtons?.length ?? -1) > 0 ||
1515
+ tableConfig.actionTemplate
1516
+ "
1517
+ >
1518
+ {{'Actions'|translate}}
1519
+ </th>
1520
+ </tr>
1521
+ </ng-template>
1522
+ </ng-template>
1523
+
1524
+ <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
1525
+ <ng-container *ngIf="tableConfig.bodyTemplate; else defaultBodyTemplate">
1526
+ <ng-container *ngTemplateOutlet="tableConfig.bodyTemplate;context: { $implicit: rowData, columns:columns, defaultTemplate: defaultBodyTemplate, tableConfig: tableConfig}"></ng-container>
1527
+ </ng-container>
1528
+ <ng-template #defaultBodyTemplate>
1529
+ <tr class="" [ttRow]="rowNode">
1530
+ <td *ngIf="tableConfig.showSelectionCheckbox ?? false" >
1531
+ <p-treeTableCheckbox [value]="rowNode"></p-treeTableCheckbox>
1532
+ </td>
1533
+ <td
1534
+ *ngFor="let column of columns; let i=index"
1535
+ [ngStyle]="column?.bodyCellStyle ?? {}"
1536
+ [class]="column?.bodyCellClass ?? ''"
1537
+ >
1538
+ <div class="{{i===0? 'flex d-flex align-items-center' : ''}}">
1539
+ <p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0" />
1540
+ <ng-container *ngIf="column.template; else defaultTemplate">
1541
+ <ng-container
1542
+ *ngTemplateOutlet="
1543
+ column.template;
1544
+ context: {
1545
+ $implicit: getNestedValue(rowData, column.field),
1546
+ column: column,
1547
+ rowData: rowData
1548
+ }
1549
+ "
1550
+ ></ng-container>
1551
+ </ng-container>
1552
+ <ng-template #defaultTemplate>
1553
+ {{
1554
+ getNestedValue(rowData, column.field)
1555
+ | dynamicPipe : column.pipes ?? []
1556
+ }}
1557
+ </ng-template>
1558
+ </div>
1559
+ </td>
1560
+ <ng-container *ngIf="(tableConfig.actionButtons?.length ?? -1) > 0 || tableConfig.actionTemplate">
1561
+ <td [ngStyle]="tableConfig.actionCellBodyStyle ?? {}"
1562
+ pFrozenColumn
1563
+ [frozen]="tableConfig.actionIsFrozen || false"
1564
+ [alignFrozen]="tableConfig.actionAlignFrozen ?? 'right'">
1565
+ <div class="flex d-flex align-items-center justify-content-center gap-2">
1566
+ <ng-container *ngIf="tableConfig.actionTemplate">
1567
+ <ng-container *ngTemplateOutlet="tableConfig.actionTemplate; context: { $implicit: rowData }"></ng-container>
1568
+ </ng-container>
1569
+ <ng-container *ngFor="let action of tableConfig.actionButtons ?? []">
1570
+ <ng-container *ngIf="action.template;else defaultButtonTemplate">
1571
+ <ng-container *ngTemplateOutlet="action.template; context: { $implicit: rowData, defaultTemplate: defaultButtonTemplate }"></ng-container>
1572
+ </ng-container>
1573
+ <ng-template #defaultButtonTemplate>
1574
+ <ng-container *ngIf="(resolveActionProperty(action.isVisible, rowData) !== false) && !resolveActionProperty(action.hidden, rowData)">
1575
+ <p-button
1576
+ [icon]="resolveActionProperty(action.icon, rowData)"
1577
+ [iconPos]="resolveActionProperty(action.iconPos, rowData) ?? 'left'"
1578
+ [label]="(resolveActionProperty(action.label, rowData)||'')|translate"
1579
+ [pTooltip]="resolveActionProperty(action.tooltip, rowData)"
1580
+ [tooltipPosition]="resolveActionProperty(action.tooltipPosition, rowData) ?? 'top'"
1581
+ [disabled]="resolveActionProperty(action.disabled, rowData)"
1582
+ [severity]="resolveActionProperty(action.severity, rowData)"
1583
+ [rounded]="resolveActionProperty(action.rounded, rowData)"
1584
+ [outlined]="resolveActionProperty(action.outlined, rowData)"
1585
+ [text]="resolveActionProperty(action.text, rowData)"
1586
+ [raised]="resolveActionProperty(action.raised, rowData)"
1587
+ [plain]="resolveActionProperty(action.plain, rowData)"
1588
+ [size]="resolveActionProperty(action.size, rowData)"
1589
+ [badge]="resolveActionProperty(action.badge, rowData)"
1590
+ [badgeClass]="resolveActionProperty(action.badgeClass, rowData)"
1591
+ styleClass="{{resolveActionProperty(action.buttonClass, rowData) ?? 'p-button-rounded p-button-outlined'}} {{resolveActionProperty(action.colorClass, rowData)}}"
1592
+ (onClick)="action.onClick? action.onClick(rowData) : false"
1593
+ ></p-button>
1594
+ </ng-container>
1595
+ </ng-template>
1596
+ </ng-container>
1597
+ </div>
1598
+ </td>
1599
+ </ng-container>
1600
+ </tr>
1601
+ </ng-template>
1602
+ </ng-template>
1603
+
1604
+ <ng-container *ngIf="tableConfig.captionTemplate">
1605
+ <ng-template pTemplate="caption">
1606
+ <ng-container *ngTemplateOutlet="tableConfig.captionTemplate;context: { $implicit: tableConfig}"></ng-container>
1607
+ </ng-template>
1608
+ </ng-container>
1609
+
1610
+ <ng-container *ngIf="tableConfig.footerTemplate">
1611
+ <ng-template pTemplate="footer">
1612
+ <ng-container *ngTemplateOutlet="tableConfig.footerTemplate;context: { $implicit: tableConfig}"></ng-container>
1613
+ </ng-template>
1614
+ </ng-container>
1615
+
1616
+ <ng-container *ngIf="tableConfig.summaryTemplate">
1617
+ <ng-template pTemplate="summary">
1618
+ <ng-container *ngTemplateOutlet="tableConfig.summaryTemplate;context: { $implicit: tableConfig}"></ng-container>
1619
+ </ng-template>
1620
+ </ng-container>
1621
+
1622
+ <ng-template pTemplate="emptymessage">
1623
+ <ng-container
1624
+ *ngIf="
1625
+ tableConfig.emptymessageTemplate;
1626
+ else defaultMessageTemplate
1627
+ "
1628
+ >
1629
+ <ng-container
1630
+ *ngTemplateOutlet="tableConfig.emptymessageTemplate"
1631
+ ></ng-container>
1632
+ </ng-container>
1633
+ <ng-template #defaultMessageTemplate>
1634
+ <tr>
1635
+ <td
1636
+ [colSpan]="tableConfig.columns.length + (((tableConfig.actionButtons?.length || 0) > 0 || tableConfig.actionTemplate)? 1: 0) + ((tableConfig.showSelectionCheckbox)? 1 :0)"
1637
+ class="text-center"
1638
+ >
1639
+ {{ tableConfig.emptymessage ?? "No Data Found." }}
1640
+ </td>
1641
+ </tr>
1642
+ </ng-template>
1643
+ </ng-template>
1644
+ </p-treeTable>
1645
+ <p-paginator
1646
+ *ngIf="tableConfig.showPaginator ?? true"
1647
+ [styleClass]="tableConfig.paginatorClass ?? 'mt-3'"
1648
+ (onPageChange)="pageChanged($event)"
1649
+ [first]="tableConfig.first ?? 0"
1650
+ [rows]="tableConfig.pageSize ?? 0"
1651
+ [totalRecords]="tableConfig.totalRecords ?? 0"
1652
+ [rowsPerPageOptions]="
1653
+ tableConfig.rowsPerPageOptions ?? [5, 10, 25, 50, 100]
1654
+ "
1655
+ ></p-paginator>
1656
+ </div>
1657
+ </div>
1658
+ `,
1659
+ providers: [ApiService],
1660
+ }]
1661
+ }], ctorParameters: () => [{ type: ApiService }, { type: i0.ChangeDetectorRef }], propDecorators: { tableConfig: [{
1662
+ type: Input,
1663
+ args: [{ required: true }]
1664
+ }] } });
1665
+
1666
+ class KitsngTableFactoryModule {
1667
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1668
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryModule, declarations: [KitsngTableFactoryComponent,
1669
+ DynamicPipe,
1670
+ KitsngFetchTableFactoryComponent,
1671
+ KitsngTreeTableFactoryComponent], imports: [CommonModule,
1672
+ TableModule,
1673
+ PaginatorModule,
1674
+ ButtonModule,
1675
+ TooltipModule,
1676
+ TreeTableModule,
1677
+ TranslatePipe], exports: [KitsngTableFactoryComponent, KitsngFetchTableFactoryComponent, KitsngTreeTableFactoryComponent] }); }
1678
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryModule, imports: [CommonModule,
1679
+ TableModule,
1680
+ PaginatorModule,
1681
+ ButtonModule,
1682
+ TooltipModule,
1683
+ TreeTableModule] }); }
1684
+ }
1685
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngTableFactoryModule, decorators: [{
1686
+ type: NgModule,
1687
+ args: [{
1688
+ declarations: [
1689
+ KitsngTableFactoryComponent,
1690
+ DynamicPipe,
1691
+ KitsngFetchTableFactoryComponent,
1692
+ KitsngTreeTableFactoryComponent,
1693
+ ],
1694
+ imports: [
1695
+ CommonModule,
1696
+ TableModule,
1697
+ PaginatorModule,
1698
+ ButtonModule,
1699
+ TooltipModule,
1700
+ TreeTableModule,
1701
+ TranslatePipe,
1702
+ ],
1703
+ exports: [KitsngTableFactoryComponent, KitsngFetchTableFactoryComponent, KitsngTreeTableFactoryComponent]
1704
+ }]
1705
+ }] });
1706
+
1707
+ class KitsngSearch {
1708
+ constructor() {
1709
+ this.value = "";
1710
+ this.debounce = 500;
1711
+ this.valueChange = new EventEmitter();
1712
+ this.inputSubject = new Subject();
1713
+ this.search = new EventEmitter();
1714
+ this.inputSubject.pipe(debounceTime$1(this.debounce)).subscribe((value) => {
1715
+ this.valueChange.next(value);
1716
+ this.search.emit(value);
1717
+ });
1718
+ }
1719
+ onInput(value) {
1720
+ this.inputSubject.next(value);
1721
+ }
1722
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngSearch, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1723
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.8", type: KitsngSearch, isStandalone: true, selector: "kitsng-search", inputs: { value: "value", debounce: "debounce" }, outputs: { valueChange: "valueChange", search: "search" }, ngImport: i0, template: "<div class=\"search-input-group\">\n <span class=\"p-input-icon-left\">\n <i class=\"pi pi-search\"></i>\n <input style=\"width: 350px\" pInputText [(ngModel)]=\"value\" (ngModelChange)=\"onInput($event)\" />\n </span>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i1$1.InputText, selector: "[pInputText]", inputs: ["variant"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1724
+ }
1725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngSearch, decorators: [{
1726
+ type: Component,
1727
+ args: [{ selector: "kitsng-search", standalone: true, imports: [InputTextModule, FormsModule], template: "<div class=\"search-input-group\">\n <span class=\"p-input-icon-left\">\n <i class=\"pi pi-search\"></i>\n <input style=\"width: 350px\" pInputText [(ngModel)]=\"value\" (ngModelChange)=\"onInput($event)\" />\n </span>\n</div>\n" }]
1728
+ }], ctorParameters: () => [], propDecorators: { value: [{
1729
+ type: Input
1730
+ }], debounce: [{
1731
+ type: Input
1732
+ }], valueChange: [{
1733
+ type: Output
1734
+ }], search: [{
1735
+ type: Output
1736
+ }] } });
1737
+
1738
+ class OverLayService {
1739
+ constructor() { }
1740
+ // -----------------------------------------------------------------------------------------------------
1741
+ // @ Accessors
1742
+ // -----------------------------------------------------------------------------------------------------
1743
+ setMaxHeight(event) {
1744
+ const overlayPanel = document.getElementsByClassName('custom-overlaypanel').item(0).children.item(0);
1745
+ if (overlayPanel) {
1746
+ const viewportHeight = window.innerHeight;
1747
+ const panelRect = overlayPanel.getBoundingClientRect();
1748
+ const panelTop = panelRect.top;
1749
+ const panelBottom = panelRect.bottom;
1750
+ const spaceAbove = viewportHeight - panelTop;
1751
+ const spaceBelow = viewportHeight - panelBottom;
1752
+ const maxHeight = Math.max(spaceAbove, spaceBelow) - 16;
1753
+ overlayPanel.style.maxHeight = maxHeight + 'px';
1754
+ }
1755
+ }
1756
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OverLayService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1757
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OverLayService, providedIn: 'root' }); }
1758
+ }
1759
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OverLayService, decorators: [{
1760
+ type: Injectable,
1761
+ args: [{
1762
+ providedIn: 'root'
1763
+ }]
1764
+ }], ctorParameters: () => [] });
1765
+
1766
+ class LookupListService {
1767
+ /**
1768
+ * Constructor
1769
+ */
1770
+ constructor(_httpClient) {
1771
+ this._httpClient = _httpClient;
1772
+ this.module = "SanedSharedData";
1773
+ this.version = "v1.2";
1774
+ // Stores active observables keyed by cacheKey to prevent duplicate API calls
1775
+ this.activeRequests = {};
1776
+ // In-memory cache store
1777
+ this.memoryCache = {};
1778
+ // Cache lifetime (in milliseconds)
1779
+ this.CACHE_LIFETIME_MS = 1 * 60 * 1000;
1780
+ sessionStorage.clear();
1781
+ // this.baseUrl = `${this.getBaseUrl()}/api/default/${this.module}/${this.entity}/${this.version}`;
1782
+ }
1783
+ getLookupLists(apiBaseUrl, entity, session = true, query = null, module = this.module, version = this.version, endPointPath = "all", memoryCache = false) {
1784
+ // Create a unique cache key based on all parameters
1785
+ const cacheKey = this.generateCacheKey(apiBaseUrl, entity, module, version, endPointPath, query);
1786
+ console.log(cacheKey, "cacheKey");
1787
+ if (memoryCache) {
1788
+ // Check in-memory cache first
1789
+ const cachedData = this.getFromMemoryCache(cacheKey);
1790
+ if (cachedData) {
1791
+ return of(cachedData);
1792
+ }
1793
+ }
1794
+ // 2. Check if identical request is already in progress
1795
+ if (this.activeRequests[cacheKey]) {
1796
+ return this.activeRequests[cacheKey];
1797
+ }
1798
+ const path = (endPointPath === "all" || endPointPath === "page") ? `lookup/${endPointPath}` : endPointPath;
1799
+ const url = `${apiBaseUrl ?? this.getBaseUrl()}/api/default/${module}/${entity}/${version}/${path}`;
1800
+ if (session) {
1801
+ const seesionData = sessionStorage.getItem(entity);
1802
+ if (seesionData) {
1803
+ const data = JSON.parse(seesionData);
1804
+ return of(data);
1805
+ }
1806
+ }
1807
+ const request$ = this._httpClient
1808
+ .post(url, query ?? {}).pipe(shareReplay(1), // Critical: Shares the result with all concurrent subscribers
1809
+ catchError(err => {
1810
+ delete this.activeRequests[cacheKey]; // Clean up on error
1811
+ return throwError(err);
1812
+ }), finalize(() => {
1813
+ delete this.activeRequests[cacheKey]; // Clean up when complete
1814
+ }))
1815
+ .pipe(map((response) => {
1816
+ if (session) {
1817
+ let oldData;
1818
+ const oldSeesionData = sessionStorage.getItem(entity);
1819
+ if (oldSeesionData) {
1820
+ oldData = JSON.parse(oldSeesionData);
1821
+ }
1822
+ else {
1823
+ oldData = null;
1824
+ }
1825
+ if (oldData?.data?.items) {
1826
+ oldData.data.items = [...oldData?.data?.items, ...response?.data?.items];
1827
+ oldData.data.items = oldData.data.items.filter((item, index, self) => index === self.findIndex((t) => (t?.id === item?.id)));
1828
+ }
1829
+ if (!oldData) {
1830
+ oldData = response;
1831
+ }
1832
+ const seesionData = JSON.stringify(oldData);
1833
+ sessionStorage.setItem(entity, seesionData);
1834
+ }
1835
+ if (memoryCache) {
1836
+ this.setMemoryCache(cacheKey, response);
1837
+ }
1838
+ return response;
1839
+ }))
1840
+ .pipe(catchError((response) => {
1841
+ return throwError(response.error);
1842
+ }));
1843
+ // Store the observable to prevent duplicate requests
1844
+ this.activeRequests[cacheKey] = request$;
1845
+ return request$;
1846
+ }
1847
+ getById(id, entity, module = this.module, version = this.version, apiBaseUrl) {
1848
+ const url = `${apiBaseUrl ?? this.getBaseUrl()}/api/default/${module}/${entity}/${version}/lookup`;
1849
+ return this._httpClient
1850
+ .get(`${url}/${id}`)
1851
+ .pipe(map((response) => {
1852
+ return response.data;
1853
+ }))
1854
+ .pipe(catchError((response) => {
1855
+ return throwError(response.error);
1856
+ }));
1857
+ }
1858
+ // Helper to generate a consistent cache key
1859
+ generateCacheKey(apiBaseUrl, entity, module, version, path, query) {
1860
+ const queryString = query ? JSON.stringify(query) : 'no-query';
1861
+ return `${apiBaseUrl}|${module}|${entity}|${version}|${path}|${queryString}`;
1862
+ }
1863
+ // Memory cache management
1864
+ getFromMemoryCache(key) {
1865
+ const cacheEntry = this.memoryCache[key];
1866
+ if (cacheEntry && (Date.now() - cacheEntry.timestamp) < this.CACHE_LIFETIME_MS) {
1867
+ return cacheEntry.data;
1868
+ }
1869
+ // Remove stale cache entry
1870
+ if (cacheEntry) {
1871
+ delete this.memoryCache[key];
1872
+ }
1873
+ return null;
1874
+ }
1875
+ setMemoryCache(key, data) {
1876
+ this.memoryCache[key] = {
1877
+ data: data,
1878
+ timestamp: Date.now()
1879
+ };
1880
+ }
1881
+ getBaseUrl() {
1882
+ return window.location.origin;
1883
+ }
1884
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupListService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1885
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupListService, providedIn: 'root' }); }
1886
+ }
1887
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupListService, decorators: [{
1888
+ type: Injectable,
1889
+ args: [{
1890
+ providedIn: 'root',
1891
+ }]
1892
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
1893
+
1894
+ class LookupSelectComponent {
1895
+ constructor(lookupListService) {
1896
+ this.lookupListService = lookupListService;
1897
+ this.isInvalid = false;
1898
+ this.validInput = false;
1899
+ this.session = false;
1900
+ this.module = 'SanedSharedData';
1901
+ this.version = 'v1';
1902
+ this.placeholder = 'Select ';
1903
+ this.styleClass = 'w-full';
1904
+ this.filterBy = 'text';
1905
+ this.optionValue = 'id';
1906
+ this.optionLabel = 'text';
1907
+ this.query = {};
1908
+ this.apiBaseUrl = {};
1909
+ this.loockupValue = new EventEmitter();
1910
+ this.clearValue = new EventEmitter();
1911
+ this.disabled = false;
1912
+ this.forceGetOptionById = false;
1913
+ this.pageSize = 10;
1914
+ this.loadLookupFromSession = false;
1915
+ this.path = "all";
1916
+ this.memoryCache = false;
1917
+ this.loadingError = false;
1918
+ this.destroy$ = new Subject();
1919
+ this.pageIndex = 1;
1920
+ this._filterOptions = new Subject();
1921
+ this.filterOptions$ = this._filterOptions.asObservable();
1922
+ this.firstTime = true;
1923
+ this.loadingOptions = true;
1924
+ this.tempOptions = [];
1925
+ this.onChange = (value) => {
1926
+ // this.loockupValue.emit(value)
1927
+ };
1928
+ this.onTouched = () => { };
1929
+ }
1930
+ ngOnInit() {
1931
+ this.getOptions();
1932
+ this.filterOptions$
1933
+ .pipe(debounceTime(500), takeUntil(this.destroy$))
1934
+ .subscribe({
1935
+ next: (filter) => {
1936
+ this.filterWord = filter;
1937
+ this.getOptions();
1938
+ },
1939
+ });
1940
+ }
1941
+ onValueChange(e) {
1942
+ if (this.disabled) {
1943
+ return;
1944
+ }
1945
+ this.value = e;
1946
+ const option = this.options.find(co => co[this.optionValue] == this.value);
1947
+ this.loockupValue.next(option);
1948
+ this.onChange(this.value);
1949
+ }
1950
+ registerOnChange(fn) {
1951
+ this.onChange = fn;
1952
+ }
1953
+ registerOnTouched(fn) {
1954
+ this.onTouched = fn;
1955
+ }
1956
+ setDisabledState(isDisabled) {
1957
+ this.disabled = isDisabled;
1958
+ }
1959
+ writeValue(value) {
1960
+ this.value = value;
1961
+ }
1962
+ markAsTouched() {
1963
+ this.onTouched();
1964
+ }
1965
+ getOptionName() {
1966
+ if (this.value) {
1967
+ const option = this.options.find(co => co[this.optionValue] == this.value);
1968
+ if (!option) {
1969
+ return '';
1970
+ }
1971
+ return option[this.optionLabel] ?? '';
1972
+ }
1973
+ return '';
1974
+ }
1975
+ onClear(event) {
1976
+ this.clearValue.emit(event);
1977
+ }
1978
+ getOptions() {
1979
+ this.loadingOptions = true;
1980
+ this.loadingError = false;
1981
+ let q = {
1982
+ pageIndex: this.pageIndex,
1983
+ pageSize: this.pageSize ?? 100,
1984
+ ...(this.query ?? {}),
1985
+ };
1986
+ if (this.filterWord != '' &&
1987
+ this.filterWord != null &&
1988
+ this.filterWord != undefined) {
1989
+ q['search'] = this.filterWord;
1990
+ }
1991
+ this.lookupListService
1992
+ .getLookupLists(this.apiBaseUrl, this.entity, (this.loadLookupFromSession ?? false) &&
1993
+ this.firstTime &&
1994
+ Object.keys(this.query ?? {}).length === 0, q, this.module, this.version, this.path ?? 'page', this.memoryCache ?? false)
1995
+ .pipe(finalize(() => (this.loadingOptions = false)))
1996
+ .subscribe({
1997
+ next: (response) => {
1998
+ this.totalItems = response?.data?.pageInfo?.totalItems;
1999
+ if (!this.options || this.pageIndex == 1) {
2000
+ this.options = [];
2001
+ }
2002
+ this.options.push(...(response.data?.items?.map((item) => {
2003
+ return {
2004
+ ...item,
2005
+ ...item.kv,
2006
+ };
2007
+ }) ?? []));
2008
+ if (this.options?.length > 0 && this.firstTime) {
2009
+ // if (this.value) {
2010
+ // this.writeValue(this.value); // check if it will return an error
2011
+ // }
2012
+ this.allTotalItems = response?.data?.pageInfo?.totalItems;
2013
+ this.firstTime = false;
2014
+ }
2015
+ this.options = this.deduplicate(this.options);
2016
+ if (!this.filterWord) {
2017
+ this.tempOptions = this.options;
2018
+ }
2019
+ else {
2020
+ this.tempOptions = this.deduplicate([
2021
+ ...this.tempOptions,
2022
+ ...this.options,
2023
+ ]);
2024
+ }
2025
+ this.updateOverlayoptions();
2026
+ if (this.value &&
2027
+ (this.filterWord == '' ||
2028
+ this.filterWord == null ||
2029
+ this.filterWord == undefined)) {
2030
+ const option = this.options.find((co) => co[this.optionValue ?? 'id'] ==
2031
+ this.value);
2032
+ if (!option) {
2033
+ this.getOptionOfDefaultValue();
2034
+ }
2035
+ }
2036
+ },
2037
+ error: (error) => {
2038
+ this.loadingError = true;
2039
+ console.error('Failed to load options:', error);
2040
+ },
2041
+ });
2042
+ }
2043
+ filterOptions(event) {
2044
+ const inputElement = event.target;
2045
+ this.filterWord = inputElement.value;
2046
+ this.applyfilter();
2047
+ }
2048
+ applyfilter() {
2049
+ if (this.filterWord == '' ||
2050
+ this.filterWord == null ||
2051
+ this.filterWord == undefined) {
2052
+ this.options = this.tempOptions;
2053
+ this.totalItems = this.allTotalItems;
2054
+ this.updateOverlayoptions();
2055
+ }
2056
+ else if (this.allTotalItems > this.tempOptions.length ||
2057
+ (!this.allTotalItems && this.path !== 'all')) {
2058
+ this.pageIndex = 1;
2059
+ this.options = [];
2060
+ this.loadingOptions = true;
2061
+ this._filterOptions.next(this.filterWord);
2062
+ }
2063
+ else {
2064
+ this.options = this.tempOptions.filter((option) => option[this.filterBy ?? 'text']
2065
+ .toLowerCase()
2066
+ .includes(this.filterWord?.toLowerCase()));
2067
+ this.updateOverlayoptions();
2068
+ }
2069
+ }
2070
+ deduplicate(arr) {
2071
+ return arr?.filter((item, index, self) => index === self?.findIndex((t) => (t?.id === item?.id)));
2072
+ }
2073
+ resetFilter() {
2074
+ if (this.filterWord != '' &&
2075
+ this.filterWord != null &&
2076
+ this.filterWord != undefined) {
2077
+ this.filterWord = '';
2078
+ this.totalItems = this.allTotalItems;
2079
+ this.applyfilter();
2080
+ }
2081
+ }
2082
+ loadMore() {
2083
+ this.pageIndex++;
2084
+ this.getOptions();
2085
+ }
2086
+ getOptionOfDefaultValue() {
2087
+ if (this.currentOption) {
2088
+ this.addCurrentOptionToList();
2089
+ }
2090
+ else {
2091
+ if (!this.optionValue ||
2092
+ this.optionValue === 'id' ||
2093
+ this.forceGetOptionById) {
2094
+ this.getOptionById();
2095
+ }
2096
+ else {
2097
+ this.getOptionByFilterAllLookup();
2098
+ }
2099
+ }
2100
+ }
2101
+ getOptionById() {
2102
+ this.lookupListService
2103
+ .getById(this.value, this.entity, this.module, this.version, this.apiBaseUrl)
2104
+ .subscribe({
2105
+ next: (value) => {
2106
+ this.currentOption = {
2107
+ ...value,
2108
+ ...value?.kv
2109
+ };
2110
+ this.addCurrentOptionToList();
2111
+ // this.ngModelChange(this._formControl?.value);
2112
+ },
2113
+ });
2114
+ }
2115
+ getOptionByFilterAllLookup() {
2116
+ let q = {
2117
+ pageIndex: this.pageIndex,
2118
+ pageSize: this.pageSize ?? 100,
2119
+ ...(this.query ?? {}),
2120
+ filters: {
2121
+ [this.optionValue ?? 'id']: {
2122
+ value: this.value,
2123
+ },
2124
+ },
2125
+ };
2126
+ this.lookupListService
2127
+ .getLookupLists(this.apiBaseUrl, this.entity, false, q, this.module, this.version, this.path ?? 'all')
2128
+ .subscribe({
2129
+ next: (value) => {
2130
+ const option = (value.data?.items?.map((item) => {
2131
+ return {
2132
+ ...item,
2133
+ ...item.kv,
2134
+ };
2135
+ }) ?? [])?.find((el) => el?.[this.optionValue ?? 'id'] === this.value) || null;
2136
+ this.currentOption = option;
2137
+ this.addCurrentOptionToList();
2138
+ // this.ngModelChange(this._formControl?.value);
2139
+ },
2140
+ });
2141
+ }
2142
+ addCurrentOptionToList() {
2143
+ this.options = [
2144
+ {
2145
+ ...this.currentOption,
2146
+ ...this.currentOption.kv,
2147
+ },
2148
+ ...this.options,
2149
+ ];
2150
+ this.tempOptions = this.options;
2151
+ this.updateOverlayoptions();
2152
+ }
2153
+ updateOverlayoptions() {
2154
+ if (this.pdropdown?.options) {
2155
+ this.pdropdown.options = this.options;
2156
+ }
2157
+ }
2158
+ ngOnDestroy() {
2159
+ this.destroy$.next();
2160
+ this.destroy$.complete();
2161
+ }
2162
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectComponent, deps: [{ token: LookupListService }], target: i0.ɵɵFactoryTarget.Component }); }
2163
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.8", type: LookupSelectComponent, selector: "app-lookup-select", inputs: { isInvalid: "isInvalid", validInput: "validInput", session: "session", entity: "entity", module: "module", version: "version", placeholder: "placeholder", styleClass: "styleClass", filterBy: "filterBy", optionValue: "optionValue", optionLabel: "optionLabel", query: "query", apiBaseUrl: "apiBaseUrl", emptyTemplate: "emptyTemplate", options: "options", disabled: "disabled", forceGetOptionById: "forceGetOptionById", pageSize: "pageSize", loadLookupFromSession: "loadLookupFromSession", path: "path", memoryCache: "memoryCache" }, outputs: { loockupValue: "loockupValue", clearValue: "clearValue" }, providers: [
2164
+ {
2165
+ provide: NG_VALUE_ACCESSOR,
2166
+ multi: true,
2167
+ useExisting: LookupSelectComponent
2168
+ }
2169
+ ], viewQueries: [{ propertyName: "pdropdown", first: true, predicate: ["pdropdown"], descendants: true }], ngImport: i0, template: "\n<p-dropdown\n [ngClass]=\"{'ng-invalid ng-dirty': validInput }\"\n [options]=\"options\" [styleClass]=\"styleClass\"\n [(ngModel)]=\"value\" (blur)=\"onTouched()\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n (ngModelChange)=\"onValueChange($event)\"\n (focus)=\"markAsTouched()\"\n appendTo=\"body\"\n [showClear]=\"true\"\n (onClear)=\"onClear($event)\"\n [optionLabel]=\"optionLabel\" [optionValue]=\"optionValue\"\n [filter]=\"true\" [filterBy]=\"filterBy\"\n [resetFilterOnHide]=\"true\"\n (onHide)=\"resetFilter()\"\n #pdropdown\n [ngClass]=\"{'ng-invalid ng-dirty': isInvalid}\">\n<ng-template pTemplate=\"filter\" let-options=\"options\">\n<div class=\"p-inputgroup\" style=\"width: 100%;\">\n<span class=\"p-inputgroup-addon\"><i class=\"pi pi-search\"></i></span>\n<input\n pInputText\n placeholder=\"Search Item\"\n [(ngModel)]=\"filterWord\"\n [ngModelOptions]=\"{standalone: true}\"\n (keyup)=\"filterOptions($event)\"\n style=\"width: 100%;\" />\n</div>\n</ng-template>\n\n <ng-template pTemplate=\"selectedItem\">\n @if (value) {\n <div class=\"d-flex d-flex gap-2\">\n <span>{{ getOptionName() }}</span>\n </div>\n }\n </ng-template>\n <ng-template let-option pTemplate=\"item\">\n <div class=\"d-flex d-flex gap-2\">\n <span>{{ option[optionLabel] }}</span>\n </div>\n </ng-template>\n <ng-template pTemplate=\"empty\">\n <ng-template [ngTemplateOutlet]=\"emptyTemplate??defaultTemplate\"></ng-template>\n </ng-template>\n <ng-template pTemplate=\"footer\">\n @if (!loadingOptions) {\n @if (totalItems > (tempOptions.length || 0)) {\n <div class=\"flex d-flex align-items-center justify-content-center\">\n <p-button type=\"button\" styleClass=\"p-button-outlined p-button-link\" label=\"Load More\" icon=\"pi pi-spinner\" (onClick)=\"loadMore()\"></p-button>\n </div>\n }\n } @else {\n @if (!firstTime && ((pdropdown?.options?.length || 0) > 0)) {\n <div class=\"flex d-flex align-items-center justify-content-center text-primary fw-medium py-3 gap-2\">\n <i class=\"pi pi-spinner-dotted pi-spin \"></i>\n <span>{{'Loading Options'|translate}}...</span>\n </div>\n }\n }\n </ng-template>\n</p-dropdown>\n\n <ng-template #defaultTemplate>\n <div class=\"text-center\">\n @if (loadingOptions) {\n <div>\n <p-progressSpinner styleClass=\"w-4rem h-4rem\"></p-progressSpinner>\n <p>{{'Loading Options'|translate}}</p>\n </div>\n } @else if (loadingError) {\n <div>\n <p>{{'Failed to load options.'|translate}}</p>\n <p-button\n label=\"Retry\"\n icon=\"pi pi-refresh\"\n (onClick)=\"getOptions()\"\n styleClass=\"p-button-outlined p-button-danger\" />\n </div>\n } @else {\n <p>\n {{'No Options Found'|translate}}\n </p>\n }\n </div>\n </ng-template>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i3.Dropdown, selector: "p-dropdown", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i6$1.ProgressSpinner, selector: "p-progressSpinner", inputs: ["styleClass", "style", "strokeWidth", "fill", "animationDuration", "ariaLabel"] }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "style", "styleClass", "badgeClass", "ariaLabel", "autofocus"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }] }); }
2170
+ }
2171
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectComponent, decorators: [{
2172
+ type: Component,
2173
+ args: [{ selector: 'app-lookup-select', providers: [
2174
+ {
2175
+ provide: NG_VALUE_ACCESSOR,
2176
+ multi: true,
2177
+ useExisting: LookupSelectComponent
2178
+ }
2179
+ ], template: "\n<p-dropdown\n [ngClass]=\"{'ng-invalid ng-dirty': validInput }\"\n [options]=\"options\" [styleClass]=\"styleClass\"\n [(ngModel)]=\"value\" (blur)=\"onTouched()\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n (ngModelChange)=\"onValueChange($event)\"\n (focus)=\"markAsTouched()\"\n appendTo=\"body\"\n [showClear]=\"true\"\n (onClear)=\"onClear($event)\"\n [optionLabel]=\"optionLabel\" [optionValue]=\"optionValue\"\n [filter]=\"true\" [filterBy]=\"filterBy\"\n [resetFilterOnHide]=\"true\"\n (onHide)=\"resetFilter()\"\n #pdropdown\n [ngClass]=\"{'ng-invalid ng-dirty': isInvalid}\">\n<ng-template pTemplate=\"filter\" let-options=\"options\">\n<div class=\"p-inputgroup\" style=\"width: 100%;\">\n<span class=\"p-inputgroup-addon\"><i class=\"pi pi-search\"></i></span>\n<input\n pInputText\n placeholder=\"Search Item\"\n [(ngModel)]=\"filterWord\"\n [ngModelOptions]=\"{standalone: true}\"\n (keyup)=\"filterOptions($event)\"\n style=\"width: 100%;\" />\n</div>\n</ng-template>\n\n <ng-template pTemplate=\"selectedItem\">\n @if (value) {\n <div class=\"d-flex d-flex gap-2\">\n <span>{{ getOptionName() }}</span>\n </div>\n }\n </ng-template>\n <ng-template let-option pTemplate=\"item\">\n <div class=\"d-flex d-flex gap-2\">\n <span>{{ option[optionLabel] }}</span>\n </div>\n </ng-template>\n <ng-template pTemplate=\"empty\">\n <ng-template [ngTemplateOutlet]=\"emptyTemplate??defaultTemplate\"></ng-template>\n </ng-template>\n <ng-template pTemplate=\"footer\">\n @if (!loadingOptions) {\n @if (totalItems > (tempOptions.length || 0)) {\n <div class=\"flex d-flex align-items-center justify-content-center\">\n <p-button type=\"button\" styleClass=\"p-button-outlined p-button-link\" label=\"Load More\" icon=\"pi pi-spinner\" (onClick)=\"loadMore()\"></p-button>\n </div>\n }\n } @else {\n @if (!firstTime && ((pdropdown?.options?.length || 0) > 0)) {\n <div class=\"flex d-flex align-items-center justify-content-center text-primary fw-medium py-3 gap-2\">\n <i class=\"pi pi-spinner-dotted pi-spin \"></i>\n <span>{{'Loading Options'|translate}}...</span>\n </div>\n }\n }\n </ng-template>\n</p-dropdown>\n\n <ng-template #defaultTemplate>\n <div class=\"text-center\">\n @if (loadingOptions) {\n <div>\n <p-progressSpinner styleClass=\"w-4rem h-4rem\"></p-progressSpinner>\n <p>{{'Loading Options'|translate}}</p>\n </div>\n } @else if (loadingError) {\n <div>\n <p>{{'Failed to load options.'|translate}}</p>\n <p-button\n label=\"Retry\"\n icon=\"pi pi-refresh\"\n (onClick)=\"getOptions()\"\n styleClass=\"p-button-outlined p-button-danger\" />\n </div>\n } @else {\n <p>\n {{'No Options Found'|translate}}\n </p>\n }\n </div>\n </ng-template>\n" }]
2180
+ }], ctorParameters: () => [{ type: LookupListService }], propDecorators: { isInvalid: [{
2181
+ type: Input
2182
+ }], validInput: [{
2183
+ type: Input
2184
+ }], session: [{
2185
+ type: Input
2186
+ }], entity: [{
2187
+ type: Input
2188
+ }], module: [{
2189
+ type: Input
2190
+ }], version: [{
2191
+ type: Input
2192
+ }], placeholder: [{
2193
+ type: Input
2194
+ }], styleClass: [{
2195
+ type: Input
2196
+ }], filterBy: [{
2197
+ type: Input
2198
+ }], optionValue: [{
2199
+ type: Input
2200
+ }], optionLabel: [{
2201
+ type: Input
2202
+ }], query: [{
2203
+ type: Input
2204
+ }], apiBaseUrl: [{
2205
+ type: Input
2206
+ }], emptyTemplate: [{
2207
+ type: Input
2208
+ }], loockupValue: [{
2209
+ type: Output
2210
+ }], clearValue: [{
2211
+ type: Output
2212
+ }], options: [{
2213
+ type: Input
2214
+ }], disabled: [{
2215
+ type: Input
2216
+ }], forceGetOptionById: [{
2217
+ type: Input
2218
+ }], pageSize: [{
2219
+ type: Input
2220
+ }], loadLookupFromSession: [{
2221
+ type: Input
2222
+ }], path: [{
2223
+ type: Input
2224
+ }], memoryCache: [{
2225
+ type: Input
2226
+ }], pdropdown: [{
2227
+ type: ViewChild,
2228
+ args: ['pdropdown']
2229
+ }] } });
2230
+
2231
+ class KitsngFilterComponent {
2232
+ get rules() {
2233
+ return this.form.get("rules");
2234
+ }
2235
+ constructor(fb, _overlayService) {
2236
+ this.fb = fb;
2237
+ this._overlayService = _overlayService;
2238
+ this.label = "Filter";
2239
+ this.icon = "pi pi-filter";
2240
+ this.styleClass = "p-button-raised p-button-text";
2241
+ this.fields = [];
2242
+ this.fieldPlaceHolder = "Select field";
2243
+ this.conditions = [
2244
+ { name: "Equal", id: 0 },
2245
+ { name: "Not Equal", id: 6 },
2246
+ { name: "Contains", id: 1 },
2247
+ { name: "Not Contains", id: 2 },
2248
+ { name: "Starts with", id: 3 },
2249
+ { name: "Ends With", id: 4 },
2250
+ // { name: "Greater Than", id: 1 },
2251
+ // { name: "Greater Than or Equal", id: 2 },
2252
+ // { name: "IN", id: 3 },
2253
+ // { name: "Less Then", id: 4 },
2254
+ // { name: "Less Then or Equal", id: 5 },
2255
+ // { name: "Not IN", id: 7 },
2256
+ // { name: "REGEX", id: 8 },
2257
+ ];
2258
+ this.dateConditions = [
2259
+ { name: "Equal", id: 0 },
2260
+ { name: "Not Equal", id: 6 },
2261
+ { name: "Greater Than", id: 1 },
2262
+ { name: "Greater Than or Equal", id: 2 },
2263
+ // { name: "IN", id: 3 },
2264
+ { name: "Less Then", id: 4 },
2265
+ { name: "Less Then or Equal", id: 5 },
2266
+ // { name: "Not IN", id: 7 },
2267
+ // { name: "REGEX", id: 8 },
2268
+ ];
2269
+ this.conditionPlaceholder = "Select Condition";
2270
+ this.clear = new EventEmitter();
2271
+ this.applay = new EventEmitter();
2272
+ this.selectedFields = [null];
2273
+ this.isShow = true;
2274
+ this.form = this.fb.group({
2275
+ rules: this.fb.array([
2276
+ this.fb.group({
2277
+ field: [null, [Validators.required]],
2278
+ condition: [null, [Validators.required]],
2279
+ value: [null, [Validators.required]],
2280
+ }),
2281
+ ]),
2282
+ });
2283
+ }
2284
+ ngOnInit() { }
2285
+ fieldSelected(event, form, index) {
2286
+ this.isShow = false;
2287
+ const field = this.fields.find((f) => f.id == event);
2288
+ setTimeout(() => {
2289
+ this.isShow = true;
2290
+ }, 10);
2291
+ if (field) {
2292
+ this.selectedFields[index] = field;
2293
+ form.patchValue({
2294
+ condition: 0,
2295
+ });
2296
+ form.updateValueAndValidity();
2297
+ }
2298
+ else {
2299
+ this.selectedFields[index] = null;
2300
+ }
2301
+ form.get("value")?.setValue(null);
2302
+ form.get("value")?.updateValueAndValidity();
2303
+ }
2304
+ onClear() {
2305
+ this.form.reset();
2306
+ this.selectedFields = [];
2307
+ this.clear.next();
2308
+ }
2309
+ onApply() {
2310
+ if (this.form.invalid) {
2311
+ return;
2312
+ }
2313
+ const filters = this.rules.controls.map(form => {
2314
+ const value = this.getValue(form);
2315
+ const filter = {
2316
+ [form.value.field]: {
2317
+ value: value.value,
2318
+ level: 0,
2319
+ conOp: value.condition,
2320
+ logOp: 0,
2321
+ },
2322
+ };
2323
+ return filter;
2324
+ });
2325
+ console.log(filters);
2326
+ this.applay.next(filters);
2327
+ this.overlay.hide();
2328
+ }
2329
+ getValue(form) {
2330
+ const field = this.fields.find((f) => f.id == this.form.value.field);
2331
+ if (field?.type == "dropdown" ||
2332
+ field?.type == "date" ||
2333
+ field?.type == "lookup" ||
2334
+ form.value.condition == 0 ||
2335
+ form.value.condition == 6) {
2336
+ return {
2337
+ value: form.value.value,
2338
+ condition: form.value.condition,
2339
+ };
2340
+ }
2341
+ else {
2342
+ return { value: this.generateRegexValue(form), condition: 8 };
2343
+ }
2344
+ }
2345
+ generateRegexValue(form) {
2346
+ const value = form.value.value;
2347
+ let pattern = value;
2348
+ switch (form.value.condition) {
2349
+ case 1:
2350
+ pattern = `^${value}$`; // Contains
2351
+ break;
2352
+ case 2:
2353
+ pattern = value; // Not Contains
2354
+ break;
2355
+ case 3:
2356
+ pattern = `^${value}`; // Starts with
2357
+ break;
2358
+ case 4:
2359
+ pattern = `${value}$`; // Ends With
2360
+ break;
2361
+ default:
2362
+ pattern = value;
2363
+ break;
2364
+ }
2365
+ return pattern;
2366
+ }
2367
+ addNewRule() {
2368
+ const rule = this.createNewRule();
2369
+ const index = this.rules.length;
2370
+ this.rules.push(rule);
2371
+ this.selectedFields.push(null);
2372
+ }
2373
+ createNewRule() {
2374
+ return this.fb.group({
2375
+ field: [null, [Validators.required]],
2376
+ condition: [null, [Validators.required]],
2377
+ value: [null, [Validators.required]],
2378
+ });
2379
+ }
2380
+ removeRule(index) {
2381
+ this.rules.removeAt(index);
2382
+ this.selectedFields.splice(index, 1);
2383
+ }
2384
+ onShow(event) {
2385
+ this._overlayService.setMaxHeight(event);
2386
+ }
2387
+ onHide() { }
2388
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterComponent, deps: [{ token: i1$2.FormBuilder }, { token: OverLayService }], target: i0.ɵɵFactoryTarget.Component }); }
2389
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.8", type: KitsngFilterComponent, selector: "kitsng-filter", inputs: { label: "label", icon: "icon", styleClass: "styleClass", fields: "fields", fieldPlaceHolder: "fieldPlaceHolder", conditions: "conditions", dateConditions: "dateConditions", conditionPlaceholder: "conditionPlaceholder" }, outputs: { clear: "clear", applay: "applay" }, viewQueries: [{ propertyName: "overlay", first: true, predicate: ["op"], descendants: true }, { propertyName: "op", first: true, predicate: ["op"], descendants: true }], ngImport: i0, template: "\n<div\n class=\"filter-container flex d-flex align-items-center justify-content-center cursor-pointer {{styleClass}}\"\n (click)=\"op.toggle($event)\"\n pBadge value=\"{{form.valid?1:0}}\"\n [badgeDisabled]=\"form.valid?false:true\"\n >\n <div class=\"\">\n <!-- badge=\"{{form.valid?'1':''}}\" badgeClass=\"\" -->\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"19\"\n height=\"20\"\n viewBox=\"0 0 19 20\"\n fill=\"none\"\n >\n <path\n d=\"M4.76615 9.8702H14.2526M2.39453 5.12695H16.6243M7.13777 14.6134H11.881\"\n stroke=\"#344054\"\n stroke-width=\"1.58424\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n\n <p-overlayPanel #op [dismissable]=\"false\" styleClass=\"w-18rem custom-overlaypanel\" [showCloseIcon]=\"true\"\n appendTo=\"body\" (onShow)=\"onShow($event)\" (onHide)=\"onHide()\">\n <ng-template pTemplate=\"content\">\n <div class=\"grid row grid-nogutter gap-2\" [formGroup]=\"form\">\n <!-- field dropdown -->\n @for (form of rules.controls; track i; let i = $index; let first = $first) {\n <ng-container formArrayName=\"rules\">\n <div class=\"col-12\" [formGroupName]=\"i\">\n <div class=\"grid row grid-nogutter gap-2\">\n @if (!first) {\n <div class=\"col-12\">\n <p-divider [align]=\"'center'\"><b>And</b></p-divider>\n </div>\n }\n <div class=\"col-12\">\n <p-dropdown [options]=\"fields\" formControlName=\"field\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"fieldPlaceHolder\" (ngModelChange)=\"fieldSelected($event, form, i)\"></p-dropdown>\n </div>\n @if (selectedFields[i]?.type != 'dropdown' && selectedFields[i]?.type != 'lookup' && selectedFields[i]?.type != 'date') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"conditions\" formControlName=\"condition\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"conditionPlaceholder\"></p-dropdown>\n </div>\n }\n @if (selectedFields[i]?.type == 'date') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"dateConditions\" formControlName=\"condition\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"conditionPlaceholder\"></p-dropdown>\n </div>\n }\n @switch (selectedFields[i]?.type) {\n @case ('dropdown') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"selectedFields[i]?.options??[]\" formControlName=\"value\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n placeholder=\"Select Option\"></p-dropdown>\n </div>\n }\n @case ('date') {\n <div class=\"col-12\">\n <p-calendar formControlName=\"value\" class=\"flex-fill\" id=\"value\"\n [showIcon]=\"true\" appendTo=\"body\"></p-calendar>\n </div>\n }\n @case ('lookup') {\n <div class=\"col-12\">\n @if (isShow) {\n <app-lookup-select\n [module]=\"selectedFields[i]?.module\"\n [entity]=\"selectedFields[i]?.entity\"\n [version]=\"selectedFields[i]?.version\"\n [apiBaseUrl]=\"selectedFields[i]?.apiBaseUrl ?? ''\"\n [forceGetOptionById]=\"selectedFields[i]?.forceGetOptionById ?? false\"\n [pageSize]=\"selectedFields[i]?.pageSize ?? 100\"\n [loadLookupFromSession]=\"selectedFields[i]?.loadLookupFromSession ?? false\"\n [path]=\"selectedFields[i]?.path ?? 'all'\"\n [query]=\"selectedFields[i]?.query || {}\"\n [memoryCache]=\"selectedFields[i]?.memoryCache ?? false\"\n [placeholder]=\"(selectedFields[i]?.placeholder || 'Select ')|translate\"\n [styleClass]=\"selectedFields[i]?.styleClass || 'w-full'\"\n [filterBy]=\"selectedFields[i]?.filterBy || 'text'\"\n [optionLabel]=\"selectedFields[i]?.optionLabel || 'text'\"\n [optionValue]=\"selectedFields[i]?.optionValue || 'id'\"\n formControlName=\"value\"\n placeholder=\"Select Option\"\n ></app-lookup-select>\n }\n </div>\n }\n @default {\n <div class=\"col-12\" >\n <input pInputText class=\"w-full\" formControlName=\"value\">\n </div>\n }\n }\n @if (rules.controls.length > 1) {\n <div class=\"col-12\">\n <p-button label=\"Remove Rule\" styleClass=\"w-full p-button-outlined p-button-danger\" (onClick)=\"removeRule(i)\"></p-button>\n </div>\n }\n </div>\n </div>\n </ng-container>\n }\n\n <div class=\"col-12\">\n <p-divider></p-divider>\n </div>\n <div class=\"col-12\">\n <p-button label=\"Add New Rule\" styleClass=\"w-full p-button-outlined\" (onClick)=\"addNewRule()\"></p-button>\n </div>\n <div class=\"col-12\">\n <div class=\"flex d-flex justify-content-between\">\n <div class=\"\">\n <p-button label=\"Clear\" styleClass=\"p-button-raised\" [disabled]=\"form.invalid\" (onClick)=\"onClear()\"></p-button>\n </div>\n <div class=\"\">\n <p-button label=\"Apply\" styleClass=\"p-button-raised p-button-text\" (onClick)=\"onApply()\"></p-button>\n </div>\n </div>\n </div>\n </div>\n </ng-template>\n </p-overlayPanel>\n", styles: [".filter-container{border-radius:8px;border:1px solid var(--gray-300, #D0D5DD);background:var(--white, #FFF);box-shadow:0 1px 2px #1018280d;width:31.6px;height:31.6px}\n"], dependencies: [{ kind: "component", type: i3$1.OverlayPanel, selector: "p-overlayPanel", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "showCloseIcon", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions"], outputs: ["onShow", "onHide"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$2.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "directive", type: i1$2.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "style", "styleClass", "badgeClass", "ariaLabel", "autofocus"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: i3.Dropdown, selector: "p-dropdown", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "directive", type: i1$1.InputText, selector: "[pInputText]", inputs: ["variant"] }, { kind: "component", type: i8$2.Calendar, selector: "p-calendar", inputs: ["iconDisplay", "style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepYearPicker", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "variant", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "locale", "view", "defaultDate"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { kind: "directive", type: i9.BadgeDirective, selector: "[pBadge]", inputs: ["badgeDisabled", "badgeSize", "size", "severity", "value", "badgeStyle", "badgeStyleClass"] }, { kind: "component", type: LookupSelectComponent, selector: "app-lookup-select", inputs: ["isInvalid", "validInput", "session", "entity", "module", "version", "placeholder", "styleClass", "filterBy", "optionValue", "optionLabel", "query", "apiBaseUrl", "emptyTemplate", "options", "disabled", "forceGetOptionById", "pageSize", "loadLookupFromSession", "path", "memoryCache"], outputs: ["loockupValue", "clearValue"] }, { kind: "component", type: i11.Divider, selector: "p-divider", inputs: ["style", "styleClass", "layout", "type", "align"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }] }); }
2390
+ }
2391
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterComponent, decorators: [{
2392
+ type: Component,
2393
+ args: [{ selector: "kitsng-filter", template: "\n<div\n class=\"filter-container flex d-flex align-items-center justify-content-center cursor-pointer {{styleClass}}\"\n (click)=\"op.toggle($event)\"\n pBadge value=\"{{form.valid?1:0}}\"\n [badgeDisabled]=\"form.valid?false:true\"\n >\n <div class=\"\">\n <!-- badge=\"{{form.valid?'1':''}}\" badgeClass=\"\" -->\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"19\"\n height=\"20\"\n viewBox=\"0 0 19 20\"\n fill=\"none\"\n >\n <path\n d=\"M4.76615 9.8702H14.2526M2.39453 5.12695H16.6243M7.13777 14.6134H11.881\"\n stroke=\"#344054\"\n stroke-width=\"1.58424\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n\n <p-overlayPanel #op [dismissable]=\"false\" styleClass=\"w-18rem custom-overlaypanel\" [showCloseIcon]=\"true\"\n appendTo=\"body\" (onShow)=\"onShow($event)\" (onHide)=\"onHide()\">\n <ng-template pTemplate=\"content\">\n <div class=\"grid row grid-nogutter gap-2\" [formGroup]=\"form\">\n <!-- field dropdown -->\n @for (form of rules.controls; track i; let i = $index; let first = $first) {\n <ng-container formArrayName=\"rules\">\n <div class=\"col-12\" [formGroupName]=\"i\">\n <div class=\"grid row grid-nogutter gap-2\">\n @if (!first) {\n <div class=\"col-12\">\n <p-divider [align]=\"'center'\"><b>And</b></p-divider>\n </div>\n }\n <div class=\"col-12\">\n <p-dropdown [options]=\"fields\" formControlName=\"field\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"fieldPlaceHolder\" (ngModelChange)=\"fieldSelected($event, form, i)\"></p-dropdown>\n </div>\n @if (selectedFields[i]?.type != 'dropdown' && selectedFields[i]?.type != 'lookup' && selectedFields[i]?.type != 'date') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"conditions\" formControlName=\"condition\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"conditionPlaceholder\"></p-dropdown>\n </div>\n }\n @if (selectedFields[i]?.type == 'date') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"dateConditions\" formControlName=\"condition\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n [placeholder]=\"conditionPlaceholder\"></p-dropdown>\n </div>\n }\n @switch (selectedFields[i]?.type) {\n @case ('dropdown') {\n <div class=\"col-12\">\n <p-dropdown [options]=\"selectedFields[i]?.options??[]\" formControlName=\"value\" styleClass=\"w-full\" optionLabel=\"name\" optionValue=\"id\" appendTo=\"body\"\n placeholder=\"Select Option\"></p-dropdown>\n </div>\n }\n @case ('date') {\n <div class=\"col-12\">\n <p-calendar formControlName=\"value\" class=\"flex-fill\" id=\"value\"\n [showIcon]=\"true\" appendTo=\"body\"></p-calendar>\n </div>\n }\n @case ('lookup') {\n <div class=\"col-12\">\n @if (isShow) {\n <app-lookup-select\n [module]=\"selectedFields[i]?.module\"\n [entity]=\"selectedFields[i]?.entity\"\n [version]=\"selectedFields[i]?.version\"\n [apiBaseUrl]=\"selectedFields[i]?.apiBaseUrl ?? ''\"\n [forceGetOptionById]=\"selectedFields[i]?.forceGetOptionById ?? false\"\n [pageSize]=\"selectedFields[i]?.pageSize ?? 100\"\n [loadLookupFromSession]=\"selectedFields[i]?.loadLookupFromSession ?? false\"\n [path]=\"selectedFields[i]?.path ?? 'all'\"\n [query]=\"selectedFields[i]?.query || {}\"\n [memoryCache]=\"selectedFields[i]?.memoryCache ?? false\"\n [placeholder]=\"(selectedFields[i]?.placeholder || 'Select ')|translate\"\n [styleClass]=\"selectedFields[i]?.styleClass || 'w-full'\"\n [filterBy]=\"selectedFields[i]?.filterBy || 'text'\"\n [optionLabel]=\"selectedFields[i]?.optionLabel || 'text'\"\n [optionValue]=\"selectedFields[i]?.optionValue || 'id'\"\n formControlName=\"value\"\n placeholder=\"Select Option\"\n ></app-lookup-select>\n }\n </div>\n }\n @default {\n <div class=\"col-12\" >\n <input pInputText class=\"w-full\" formControlName=\"value\">\n </div>\n }\n }\n @if (rules.controls.length > 1) {\n <div class=\"col-12\">\n <p-button label=\"Remove Rule\" styleClass=\"w-full p-button-outlined p-button-danger\" (onClick)=\"removeRule(i)\"></p-button>\n </div>\n }\n </div>\n </div>\n </ng-container>\n }\n\n <div class=\"col-12\">\n <p-divider></p-divider>\n </div>\n <div class=\"col-12\">\n <p-button label=\"Add New Rule\" styleClass=\"w-full p-button-outlined\" (onClick)=\"addNewRule()\"></p-button>\n </div>\n <div class=\"col-12\">\n <div class=\"flex d-flex justify-content-between\">\n <div class=\"\">\n <p-button label=\"Clear\" styleClass=\"p-button-raised\" [disabled]=\"form.invalid\" (onClick)=\"onClear()\"></p-button>\n </div>\n <div class=\"\">\n <p-button label=\"Apply\" styleClass=\"p-button-raised p-button-text\" (onClick)=\"onApply()\"></p-button>\n </div>\n </div>\n </div>\n </div>\n </ng-template>\n </p-overlayPanel>\n", styles: [".filter-container{border-radius:8px;border:1px solid var(--gray-300, #D0D5DD);background:var(--white, #FFF);box-shadow:0 1px 2px #1018280d;width:31.6px;height:31.6px}\n"] }]
2394
+ }], ctorParameters: () => [{ type: i1$2.FormBuilder }, { type: OverLayService }], propDecorators: { overlay: [{
2395
+ type: ViewChild,
2396
+ args: ["op"]
2397
+ }], label: [{
2398
+ type: Input
2399
+ }], icon: [{
2400
+ type: Input
2401
+ }], styleClass: [{
2402
+ type: Input
2403
+ }], fields: [{
2404
+ type: Input
2405
+ }], fieldPlaceHolder: [{
2406
+ type: Input
2407
+ }], conditions: [{
2408
+ type: Input
2409
+ }], dateConditions: [{
2410
+ type: Input
2411
+ }], conditionPlaceholder: [{
2412
+ type: Input
2413
+ }], clear: [{
2414
+ type: Output
2415
+ }], applay: [{
2416
+ type: Output
2417
+ }], op: [{
2418
+ type: ViewChild,
2419
+ args: ["op"]
2420
+ }] } });
2421
+
2422
+ class LookupSelectModule {
2423
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2424
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectModule, declarations: [LookupSelectComponent], imports: [CommonModule,
2425
+ DropdownModule,
2426
+ FormsModule,
2427
+ ProgressSpinnerModule,
2428
+ ButtonModule,
2429
+ TranslatePipe], exports: [LookupSelectComponent] }); }
2430
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectModule, imports: [CommonModule,
2431
+ DropdownModule,
2432
+ FormsModule,
2433
+ ProgressSpinnerModule,
2434
+ ButtonModule] }); }
2435
+ }
2436
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: LookupSelectModule, decorators: [{
2437
+ type: NgModule,
2438
+ args: [{
2439
+ declarations: [
2440
+ LookupSelectComponent
2441
+ ],
2442
+ imports: [
2443
+ CommonModule,
2444
+ DropdownModule,
2445
+ FormsModule,
2446
+ ProgressSpinnerModule,
2447
+ ButtonModule,
2448
+ TranslatePipe,
2449
+ ],
2450
+ exports: [
2451
+ LookupSelectComponent
2452
+ ]
2453
+ }]
2454
+ }] });
2455
+
2456
+ class KitsngFilterModule {
2457
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2458
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterModule, declarations: [KitsngFilterComponent], imports: [CommonModule,
2459
+ OverlayPanelModule,
2460
+ ReactiveFormsModule,
2461
+ ButtonModule,
2462
+ ChipModule,
2463
+ DropdownModule,
2464
+ InputTextModule,
2465
+ CalendarModule,
2466
+ BadgeModule,
2467
+ LookupSelectModule,
2468
+ DividerModule,
2469
+ TranslatePipe], exports: [KitsngFilterComponent] }); }
2470
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterModule, imports: [CommonModule,
2471
+ OverlayPanelModule,
2472
+ ReactiveFormsModule,
2473
+ ButtonModule,
2474
+ ChipModule,
2475
+ DropdownModule,
2476
+ InputTextModule,
2477
+ CalendarModule,
2478
+ BadgeModule,
2479
+ LookupSelectModule,
2480
+ DividerModule] }); }
2481
+ }
2482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: KitsngFilterModule, decorators: [{
2483
+ type: NgModule,
2484
+ args: [{
2485
+ declarations: [
2486
+ KitsngFilterComponent,
2487
+ ],
2488
+ imports: [
2489
+ CommonModule,
2490
+ OverlayPanelModule,
2491
+ ReactiveFormsModule,
2492
+ ButtonModule,
2493
+ ChipModule,
2494
+ DropdownModule,
2495
+ InputTextModule,
2496
+ CalendarModule,
2497
+ BadgeModule,
2498
+ LookupSelectModule,
2499
+ DividerModule,
2500
+ TranslatePipe,
2501
+ ],
2502
+ exports: [KitsngFilterComponent],
2503
+ }]
2504
+ }] });
2505
+
2506
+ /*
2507
+ * Public API Surface of kitsng-table-factory
2508
+ */
2509
+ // export * from './lib/kitsng-table-factory.service';
2510
+
2511
+ /**
2512
+ * Generated bundle index. Do not edit.
2513
+ */
2514
+
2515
+ export { KitsngFetchTableFactoryComponent, KitsngFilterComponent, KitsngFilterModule, KitsngSearch, KitsngTableFactoryComponent, KitsngTableFactoryModule, KitsngTreeTableFactoryComponent };
2516
+ //# sourceMappingURL=kitsng-table-factory.mjs.map