@sd-angular/core 1.3.146 → 1.3.148

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 (140) hide show
  1. package/bundles/sd-angular-core-grid-material.umd.js +1 -1
  2. package/bundles/sd-angular-core-grid-material.umd.js.map +1 -1
  3. package/bundles/sd-angular-core-grid-material.umd.min.js +1 -1
  4. package/bundles/sd-angular-core-grid-material.umd.min.js.map +1 -1
  5. package/bundles/sd-angular-core-table.umd.js +4077 -0
  6. package/bundles/sd-angular-core-table.umd.js.map +1 -0
  7. package/bundles/sd-angular-core-table.umd.min.js +2 -0
  8. package/bundles/sd-angular-core-table.umd.min.js.map +1 -0
  9. package/bundles/sd-angular-core.umd.js +6 -4
  10. package/bundles/sd-angular-core.umd.js.map +1 -1
  11. package/bundles/sd-angular-core.umd.min.js +1 -1
  12. package/bundles/sd-angular-core.umd.min.js.map +1 -1
  13. package/esm2015/grid-material/src/lib/components/column-inline-filter/column-inline-filter.component.js +2 -2
  14. package/esm2015/lib/core.module.js +4 -1
  15. package/esm2015/public-api.js +2 -1
  16. package/esm2015/table/index.js +2 -0
  17. package/esm2015/table/sd-angular-core-table.js +40 -0
  18. package/esm2015/table/src/lib/components/column-inline-filter/column-inline-filter.component.js +96 -0
  19. package/esm2015/table/src/lib/components/desktop-cell/desktop-cell.component.js +25 -0
  20. package/esm2015/table/src/lib/components/desktop-cell-view/desktop-cell-view.component.js +21 -0
  21. package/esm2015/table/src/lib/components/desktop-command/desktop-command.component.js +20 -0
  22. package/esm2015/table/src/lib/components/grid-filter/grid-filter.component.js +99 -0
  23. package/esm2015/table/src/lib/components/popup-filter/popup-filter.component.js +79 -0
  24. package/esm2015/table/src/lib/components/popup-grid-configuration/popup-grid-configuration.component.js +96 -0
  25. package/esm2015/table/src/lib/components/quick-action/quick-action.component.js +24 -0
  26. package/esm2015/table/src/lib/directives/sd-material-cell-def.directive.js +18 -0
  27. package/esm2015/table/src/lib/directives/sd-material-empty-data-def.directive.js +15 -0
  28. package/esm2015/table/src/lib/directives/sd-material-filter-def.directive.js +22 -0
  29. package/esm2015/table/src/lib/directives/sd-material-footer-def.directive.js +18 -0
  30. package/esm2015/table/src/lib/directives/sd-material-sub-information-def.directive.js +15 -0
  31. package/esm2015/table/src/lib/models/grid-cell.model.js +2 -0
  32. package/esm2015/table/src/lib/models/index.js +4 -0
  33. package/esm2015/table/src/lib/models/table-column.model.js +63 -0
  34. package/esm2015/table/src/lib/models/table-command.model.js +2 -0
  35. package/esm2015/table/src/lib/models/table-configuration.model.js +9 -0
  36. package/esm2015/table/src/lib/models/table-item.model.js +15 -0
  37. package/esm2015/table/src/lib/models/table-option-config.model.js +2 -0
  38. package/esm2015/table/src/lib/models/table-option-expand.model.js +2 -0
  39. package/esm2015/table/src/lib/models/table-option-export.model.js +2 -0
  40. package/esm2015/table/src/lib/models/table-option-group.model.js +2 -0
  41. package/esm2015/table/src/lib/models/table-option-paginate.model.js +2 -0
  42. package/esm2015/table/src/lib/models/table-option-reload.model.js +2 -0
  43. package/esm2015/table/src/lib/models/table-option-selector.model.js +2 -0
  44. package/esm2015/table/src/lib/models/table-option-sort.model.js +2 -0
  45. package/esm2015/table/src/lib/models/table-option-style.model.js +2 -0
  46. package/esm2015/table/src/lib/models/table-option.model.js +2 -0
  47. package/esm2015/table/src/lib/pipes/cell-view.pipe.js +180 -0
  48. package/esm2015/table/src/lib/pipes/column-badge.pipe.js +43 -0
  49. package/esm2015/table/src/lib/pipes/column-children-filter.pipe.js +31 -0
  50. package/esm2015/table/src/lib/pipes/column-html-template.pipe.js +23 -0
  51. package/esm2015/table/src/lib/pipes/column-tooltip.pipe.js +17 -0
  52. package/esm2015/table/src/lib/pipes/column-transform.pipe.js +35 -0
  53. package/esm2015/table/src/lib/pipes/column-values.pipe.js +63 -0
  54. package/esm2015/table/src/lib/pipes/command-disable.pipe.js +18 -0
  55. package/esm2015/table/src/lib/pipes/command-filter.pipe.js +79 -0
  56. package/esm2015/table/src/lib/pipes/command-icon.pipe.js +18 -0
  57. package/esm2015/table/src/lib/pipes/command-title.pipe.js +18 -0
  58. package/esm2015/table/src/lib/pipes/filter-column.pipe.js +30 -0
  59. package/esm2015/table/src/lib/pipes/filter-external.pipe.js +19 -0
  60. package/esm2015/table/src/lib/pipes/grid-configuration-result.pipe.js +21 -0
  61. package/esm2015/table/src/lib/pipes/sd-group.pipe.js +45 -0
  62. package/esm2015/table/src/lib/pipes/selection-action-filter.pipe.js +72 -0
  63. package/esm2015/table/src/lib/pipes/selection-disable.pipe.js +55 -0
  64. package/esm2015/table/src/lib/pipes/selection-visible-select-all.pipe.js +34 -0
  65. package/esm2015/table/src/lib/pipes/selection-visible.pipe.js +82 -0
  66. package/esm2015/table/src/lib/services/table-configuration.service.js +292 -0
  67. package/esm2015/table/src/lib/services/table-filter/table-filter.model.js +3 -0
  68. package/esm2015/table/src/lib/services/table-filter/table-filter.service.js +229 -0
  69. package/esm2015/table/src/lib/table.component.js +832 -0
  70. package/esm2015/table/src/lib/table.module.js +175 -0
  71. package/esm2015/table/src/public-api.js +5 -0
  72. package/fesm2015/sd-angular-core-grid-material.js +1 -1
  73. package/fesm2015/sd-angular-core-grid-material.js.map +1 -1
  74. package/fesm2015/sd-angular-core-table.js +2927 -0
  75. package/fesm2015/sd-angular-core-table.js.map +1 -0
  76. package/fesm2015/sd-angular-core.js +3 -0
  77. package/fesm2015/sd-angular-core.js.map +1 -1
  78. package/grid-material/sd-angular-core-grid-material.metadata.json +1 -1
  79. package/package.json +1 -1
  80. package/public-api.d.ts +1 -0
  81. package/{sd-angular-core-1.3.146.tgz → sd-angular-core-1.3.148.tgz} +0 -0
  82. package/sd-angular-core.metadata.json +1 -1
  83. package/table/index.d.ts +1 -0
  84. package/table/package.json +12 -0
  85. package/table/sd-angular-core-table.d.ts +39 -0
  86. package/table/sd-angular-core-table.metadata.json +1 -0
  87. package/table/src/lib/components/column-inline-filter/column-inline-filter.component.d.ts +29 -0
  88. package/table/src/lib/components/desktop-cell/desktop-cell.component.d.ts +17 -0
  89. package/table/src/lib/components/desktop-cell-view/desktop-cell-view.component.d.ts +11 -0
  90. package/table/src/lib/components/desktop-command/desktop-command.component.d.ts +7 -0
  91. package/table/src/lib/components/grid-filter/grid-filter.component.d.ts +35 -0
  92. package/table/src/lib/components/popup-filter/popup-filter.component.d.ts +27 -0
  93. package/table/src/lib/components/popup-grid-configuration/popup-grid-configuration.component.d.ts +39 -0
  94. package/table/src/lib/components/quick-action/quick-action.component.d.ts +9 -0
  95. package/table/src/lib/directives/sd-material-cell-def.directive.d.ts +6 -0
  96. package/table/src/lib/directives/sd-material-empty-data-def.directive.d.ts +5 -0
  97. package/table/src/lib/directives/sd-material-filter-def.directive.d.ts +8 -0
  98. package/table/src/lib/directives/sd-material-footer-def.directive.d.ts +6 -0
  99. package/table/src/lib/directives/sd-material-sub-information-def.directive.d.ts +5 -0
  100. package/table/src/lib/models/grid-cell.model.d.ts +16 -0
  101. package/table/src/lib/models/index.d.ts +3 -0
  102. package/table/src/lib/models/table-column.model.d.ts +125 -0
  103. package/table/src/lib/models/table-command.model.d.ts +19 -0
  104. package/table/src/lib/models/table-configuration.model.d.ts +20 -0
  105. package/table/src/lib/models/table-item.model.d.ts +25 -0
  106. package/table/src/lib/models/table-option-config.model.d.ts +62 -0
  107. package/table/src/lib/models/table-option-expand.model.d.ts +6 -0
  108. package/table/src/lib/models/table-option-export.model.d.ts +31 -0
  109. package/table/src/lib/models/table-option-group.model.d.ts +4 -0
  110. package/table/src/lib/models/table-option-paginate.model.d.ts +6 -0
  111. package/table/src/lib/models/table-option-reload.model.d.ts +5 -0
  112. package/table/src/lib/models/table-option-selector.model.d.ts +32 -0
  113. package/table/src/lib/models/table-option-sort.model.d.ts +3 -0
  114. package/table/src/lib/models/table-option-style.model.d.ts +6 -0
  115. package/table/src/lib/models/table-option.model.d.ts +44 -0
  116. package/table/src/lib/pipes/cell-view.pipe.d.ts +15 -0
  117. package/table/src/lib/pipes/column-badge.pipe.d.ts +11 -0
  118. package/table/src/lib/pipes/column-children-filter.pipe.d.ts +8 -0
  119. package/table/src/lib/pipes/column-html-template.pipe.d.ts +8 -0
  120. package/table/src/lib/pipes/column-tooltip.pipe.d.ts +6 -0
  121. package/table/src/lib/pipes/column-transform.pipe.d.ts +8 -0
  122. package/table/src/lib/pipes/column-values.pipe.d.ts +6 -0
  123. package/table/src/lib/pipes/command-disable.pipe.d.ts +5 -0
  124. package/table/src/lib/pipes/command-filter.pipe.d.ts +6 -0
  125. package/table/src/lib/pipes/command-icon.pipe.d.ts +5 -0
  126. package/table/src/lib/pipes/command-title.pipe.d.ts +5 -0
  127. package/table/src/lib/pipes/filter-column.pipe.d.ts +5 -0
  128. package/table/src/lib/pipes/filter-external.pipe.d.ts +5 -0
  129. package/table/src/lib/pipes/grid-configuration-result.pipe.d.ts +10 -0
  130. package/table/src/lib/pipes/sd-group.pipe.d.ts +6 -0
  131. package/table/src/lib/pipes/selection-action-filter.pipe.d.ts +7 -0
  132. package/table/src/lib/pipes/selection-disable.pipe.d.ts +6 -0
  133. package/table/src/lib/pipes/selection-visible-select-all.pipe.d.ts +6 -0
  134. package/table/src/lib/pipes/selection-visible.pipe.d.ts +6 -0
  135. package/table/src/lib/services/table-configuration.service.d.ts +13 -0
  136. package/table/src/lib/services/table-filter/table-filter.model.d.ts +117 -0
  137. package/table/src/lib/services/table-filter/table-filter.service.d.ts +15 -0
  138. package/table/src/lib/table.component.d.ts +87 -0
  139. package/table/src/lib/table.module.d.ts +11 -0
  140. package/table/src/public-api.d.ts +5 -0
@@ -0,0 +1,2927 @@
1
+ import { SdScrollDirective, SdCommonModule } from '@sd-angular/core/common';
2
+ import { InjectionToken, Directive, TemplateRef, Input, Component, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, Injectable, Inject, Optional, Pipe, QueryList, ContentChild, ContentChildren, EventEmitter, HostListener, Output, NgModule } from '@angular/core';
3
+ import { CommonModule, DatePipe, DecimalPipe } from '@angular/common';
4
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { MatFormFieldModule } from '@angular/material/form-field';
6
+ import { MatIconModule } from '@angular/material/icon';
7
+ import { MatInputModule } from '@angular/material/input';
8
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __awaiter, __rest } from 'tslib';
9
+ import { MatPaginator, MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
10
+ import { MatSort, MatSortModule } from '@angular/material/sort';
11
+ import { trigger, state, style, transition, animate } from '@angular/animations';
12
+ import { v4 } from 'uuid';
13
+ import { BehaviorSubject, Subscription, Subject, isObservable, combineLatest } from 'rxjs';
14
+ import { SdNotifyService } from '@sd-angular/core/notify';
15
+ import { startWith, map, debounceTime, switchMap } from 'rxjs/operators';
16
+ import { SdModal } from '@sd-angular/core/modal';
17
+ import { DeviceDetectorService } from 'ngx-device-detector';
18
+ import { SdExportService } from '@sd-angular/core/export';
19
+ import * as hash from 'object-hash';
20
+ import hash__default from 'object-hash';
21
+ import { SdSettingService } from '@sd-angular/core/setting';
22
+ import { SdQuickAction } from '@sd-angular/core/quick-action';
23
+ import { MatTableModule } from '@angular/material/table';
24
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
25
+ import { CdkTableModule, CdkColumnDef } from '@angular/cdk/table';
26
+ import { ScrollingModule } from '@angular/cdk/scrolling';
27
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
28
+ import { MatMenuModule } from '@angular/material/menu';
29
+ import { MatSliderModule } from '@angular/material/slider';
30
+ import { MatButtonModule } from '@angular/material/button';
31
+ import { SdServiceModule } from '@sd-angular/core/service';
32
+ import { MatTooltipModule } from '@angular/material/tooltip';
33
+ import { MatChipsModule } from '@angular/material/chips';
34
+ import { MatRadioModule } from '@angular/material/radio';
35
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
36
+ import { SdFormModule } from '@sd-angular/core/form';
37
+ import { MatCheckboxModule } from '@angular/material/checkbox';
38
+ import { SdTranslateService } from '@sd-angular/core/translate';
39
+ import { MatListModule } from '@angular/material/list';
40
+ import { MatDividerModule } from '@angular/material/divider';
41
+ import { SdUtilityService } from '@sd-angular/core/utility';
42
+ import { SdGroupModule } from '@sd-angular/core/group';
43
+
44
+ const DEFAULT_TABLE_CONFIG = {
45
+ paginate: {
46
+ pageSize: 50,
47
+ pages: [50, 100, 200]
48
+ }
49
+ };
50
+ const TABLE_CONFIG = new InjectionToken('sd-table.configuration');
51
+
52
+ class SdMaterialCellDefDirective {
53
+ constructor(templateRef) {
54
+ this.templateRef = templateRef;
55
+ }
56
+ }
57
+ SdMaterialCellDefDirective.decorators = [
58
+ { type: Directive, args: [{
59
+ selector: '[sdMaterialCellDef]'
60
+ },] }
61
+ ];
62
+ SdMaterialCellDefDirective.ctorParameters = () => [
63
+ { type: TemplateRef }
64
+ ];
65
+ SdMaterialCellDefDirective.propDecorators = {
66
+ sdMaterialCellDef: [{ type: Input }]
67
+ };
68
+
69
+ var _filterRegister;
70
+ class SdPopupFilter {
71
+ constructor(cdRef) {
72
+ this.cdRef = cdRef;
73
+ _filterRegister.set(this, void 0);
74
+ this.externalFilters = [];
75
+ this.externalFilter = {};
76
+ this.inlineExternal = {};
77
+ this.columns = [];
78
+ this.columnFilter = {};
79
+ this.inlineColumn = {};
80
+ this.filterDefs = [];
81
+ this.filterDef = {};
82
+ this.inlineFilterDef = {};
83
+ this.open = () => {
84
+ const configuration = __classPrivateFieldGet(this, _filterRegister).configuration.get();
85
+ this.inlineColumn = JSON.parse(JSON.stringify(configuration.inlineColumn));
86
+ this.inlineExternal = JSON.parse(JSON.stringify(configuration.inlineExternal));
87
+ this.inlineFilterDef = JSON.parse(JSON.stringify(configuration.inlineFilterDef));
88
+ const filterValue = __classPrivateFieldGet(this, _filterRegister).value.get();
89
+ this.columnFilter = JSON.parse(JSON.stringify(filterValue.columnFilter));
90
+ this.externalFilter = JSON.parse(JSON.stringify(filterValue.externalFilter));
91
+ this.filterDef = JSON.parse(JSON.stringify(filterValue.filterDef));
92
+ this.modal.open();
93
+ this.cdRef.markForCheck();
94
+ };
95
+ this.close = () => {
96
+ this.modal.close();
97
+ this.cdRef.markForCheck();
98
+ };
99
+ this.onApply = () => {
100
+ __classPrivateFieldGet(this, _filterRegister).configuration.set({
101
+ inlineColumn: this.inlineColumn,
102
+ inlineExternal: this.inlineExternal,
103
+ inlineFilterDef: this.inlineFilterDef,
104
+ });
105
+ __classPrivateFieldGet(this, _filterRegister).value.set({
106
+ columnFilter: this.columnFilter,
107
+ externalFilter: this.externalFilter,
108
+ filterDef: this.filterDef,
109
+ });
110
+ this.modal.close();
111
+ this.cdRef.markForCheck();
112
+ };
113
+ }
114
+ set filterRegister(value) {
115
+ __classPrivateFieldSet(this, _filterRegister, value);
116
+ }
117
+ ngAfterViewInit() { }
118
+ ngOnDestroy() { }
119
+ onClear() {
120
+ __classPrivateFieldGet(this, _filterRegister).value.remove();
121
+ this.modal.close();
122
+ this.cdRef.markForCheck();
123
+ }
124
+ }
125
+ _filterRegister = new WeakMap();
126
+ SdPopupFilter.decorators = [
127
+ { type: Component, args: [{
128
+ selector: 'sd-popup-filter',
129
+ template: "<sd-modal width=\"500px\" [title]=\"'Filter' | sdTranslate\">\r\n <sd-modal-body class=\"c-popup-filter\">\r\n <ng-container *ngFor=\"let column of columns | sdFilterColumn\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineColumn[column.field]\" color=\"primary\"></mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <sd-input\r\n *ngIf=\"column.type === 'string'\"\r\n [label]=\"column.title\"\r\n type=\"text\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-input\r\n *ngIf=\"column.type === 'number'\"\r\n [label]=\"column.title\"\r\n type=\" number\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-select\r\n *ngIf=\"column.type === 'bool'\"\r\n [label]=\"column.title\"\r\n [items]=\"[\r\n { value: '1', display: column.trueValue || 'True' },\r\n { value: '0', display: column.falseValue || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"column.type === 'values' && !column?.editor?.autocomplete\"\r\n [label]=\"column.title\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"column.type === 'values' && column?.editor?.autocomplete\"\r\n [label]=\"column.title\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-date-time\r\n *ngIf=\"column.type === 'date' || column.type === 'datetime' || column.type === 'time'\"\r\n [label]=\"column.title\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n type=\"date\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n </div>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineExternal[item.field]\" color=\"primary\"></mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <sd-input\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'string'\"\r\n type=\"text\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"externalFilter[item.field]\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'bool'\"\r\n [items]=\"[\r\n { value: '1', display: item.option?.displayOnTrue || 'True' },\r\n { value: '0', display: item.option?.displayOnFalse || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <ng-container *ngIf=\"item.type === 'values'\">\r\n <sd-select\r\n *ngIf=\"item.option?.selection === 'MULTIPLE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\"\r\n multiple>\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"item.option?.selection === 'AUTOCOMPLETE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\">\r\n </sd-autocomplete>\r\n <sd-select\r\n *ngIf=\"item.option?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n filtered=\"true\"\r\n multiple>\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"!item.option?.selection\"\r\n [label]=\"item.title\"\r\n [items]=\"item.values\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\">\r\n </sd-select>\r\n </ng-container>\r\n <sd-date-time\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'date' || item.type === 'datetime'\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n [type]=\"item.type\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n <sd-date-range\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'daterange' && externalFilter[item.field]\"\r\n [(from)]=\"externalFilter[item.field].from\"\r\n [(to)]=\"externalFilter[item.field].to\"\r\n [min]=\"item.minDate\"\r\n [max]=\"item.maxDate\"\r\n appearance=\"outline\">\r\n </sd-date-range>\r\n </div>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngFor=\"let filter of filterDefs\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineFilterDef[filter.sdMaterialFilterDef]\" color=\"primary\"> </mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <ng-container *ngTemplateOutlet=\"filter.templateRef; context: { filterDef: filterDef }\"> </ng-container>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </sd-modal-body>\r\n <sd-modal-footer *sdDesktop>\r\n <sd-button class=\"mr-auto\" (action)=\"onClear()\" title=\"M\u1EB7c \u0111\u1ECBnh\" size=\"sm\" type=\"link\"> </sd-button>\r\n <sd-button (action)=\"onApply()\" title=\"\u0110\u1ED3ng \u00FD\" color=\"primary\" size=\"sm\" type=\"fill\"></sd-button>\r\n </sd-modal-footer>\r\n <sd-modal-footer *sdMobileTablet>\r\n <sd-button style=\"flex: 1; padding-right: 5px\" (action)=\"onClear()\" title=\"M\u1EB7c \u0111\u1ECBnh\" width=\"100%\" size=\"sm\" type=\"link\"></sd-button>\r\n <sd-button\r\n style=\"flex: 1; padding-left: 5px\"\r\n (action)=\"onApply()\"\r\n title=\"\u0110\u1ED3ng \u00FD\"\r\n color=\"primary\"\r\n width=\"100%\"\r\n size=\"sm\"\r\n type=\"fill\"></sd-button>\r\n </sd-modal-footer>\r\n</sd-modal>\r\n",
130
+ changeDetection: ChangeDetectionStrategy.OnPush,
131
+ styles: [".c-checkable{width:50px}.c-filterable{flex:1}::ng-deep sd-modal-body.c-popup-filter .mat-form-field-wrapper{padding-bottom:0}"]
132
+ },] }
133
+ ];
134
+ SdPopupFilter.ctorParameters = () => [
135
+ { type: ChangeDetectorRef }
136
+ ];
137
+ SdPopupFilter.propDecorators = {
138
+ modal: [{ type: ViewChild, args: [SdModal,] }],
139
+ filterRegister: [{ type: Input }],
140
+ externalFilters: [{ type: Input }],
141
+ columns: [{ type: Input }],
142
+ filterDefs: [{ type: Input }]
143
+ };
144
+
145
+ var _subscription;
146
+ class SdGridFilter {
147
+ constructor(ref, deviceService) {
148
+ this.ref = ref;
149
+ this.deviceService = deviceService;
150
+ this.columns = [];
151
+ this.externalFilters = [];
152
+ this.filterDefs = [];
153
+ this.filterRegisterChange = new BehaviorSubject(null);
154
+ this.filterDef = {};
155
+ this.inlineFilterDef = {};
156
+ this.columnFilter = {};
157
+ this.inlineColumn = {};
158
+ this.externalFilter = {};
159
+ this.inlineExternal = {};
160
+ _subscription.set(this, new Subscription());
161
+ this.onFilter = (item) => {
162
+ this.filterRegister.value.set({
163
+ columnFilter: this.columnFilter,
164
+ externalFilter: this.externalFilter,
165
+ filterDef: this.filterDef,
166
+ });
167
+ };
168
+ this.updateFilter = () => {
169
+ this.filterRegister.value.set({
170
+ columnFilter: this.columnFilter,
171
+ externalFilter: this.externalFilter,
172
+ filterDef: this.filterDef,
173
+ notReload: true
174
+ });
175
+ };
176
+ this.open = () => {
177
+ this.popupFilter.open();
178
+ };
179
+ this.isMobileOrTablet = !this.deviceService.isDesktop();
180
+ this.ref.markForCheck();
181
+ }
182
+ set _filter(filter) {
183
+ this.filter = filter;
184
+ }
185
+ set _externalFilters(value) {
186
+ this.externalFilters = value || [];
187
+ }
188
+ set _filterRegister(value) {
189
+ this.filterRegister = value;
190
+ this.filterRegisterChange.next(this.filterRegister);
191
+ }
192
+ ngAfterViewInit() {
193
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegisterChange.pipe(startWith(this.filterRegister)).subscribe(filterRegister => {
194
+ if (this.filterRegister) {
195
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegister.configuration.observer.subscribe(configuration => {
196
+ const { inlineColumn, inlineExternal, inlineFilterDef } = configuration;
197
+ this.inlineColumn = inlineColumn;
198
+ this.inlineExternal = inlineExternal;
199
+ this.inlineFilterDef = inlineFilterDef;
200
+ this.ref.markForCheck();
201
+ }));
202
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegister.value.observer.subscribe(value => {
203
+ const { columnFilter, externalFilter, filterDef } = value;
204
+ this.columnFilter = columnFilter;
205
+ this.externalFilter = externalFilter;
206
+ this.filterDef = filterDef;
207
+ this.ref.markForCheck();
208
+ }));
209
+ }
210
+ }));
211
+ }
212
+ ngOnDestroy() {
213
+ __classPrivateFieldGet(this, _subscription).unsubscribe();
214
+ }
215
+ }
216
+ _subscription = new WeakMap();
217
+ SdGridFilter.decorators = [
218
+ { type: Component, args: [{
219
+ selector: 'sd-grid-filter',
220
+ template: "<ng-container *ngIf=\"!filter?.disabled\">\r\n <ng-container *ngIf=\"filter?.enableCollapse;else noCollapse\">\r\n <sd-group class=\"p-12\" [isExpanded]=\"false\" title=\"T\u00ECm ki\u1EBFm\" expandable>\r\n <div sdGroupBody>\r\n <ng-container *ngTemplateOutlet=\"noCollapse\"></ng-container>\r\n </div>\r\n </sd-group>\r\n </ng-container>\r\n <ng-template #noCollapse>\r\n <div\r\n *ngIf=\"!isMobileOrTablet && ((columns?.length && !filter?.inlineColumn) || externalFilters?.length || filterDefs?.length)\"\r\n class=\"row mx-0\">\r\n <ng-container *ngIf=\"filter?.sorts?.length\">\r\n <ng-container *ngFor=\"let field of filter?.sorts\">\r\n <ng-container *ngIf=\"columns?.length && !filter?.inlineColumn\">\r\n <ng-container *ngFor=\"let item of columns | sdFilterColumn:field\">\r\n <ng-container *ngTemplateOutlet=\"filterColumn; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"externalFilters?.length\">\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal:field\">\r\n <ng-container *ngTemplateOutlet=\"filterExternal; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of filterDefs\">\r\n <div *ngIf=\"inlineFilterDef[item.sdMaterialFilterDef] && item.sdMaterialFilterDef === field\"\r\n class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <ng-container *ngTemplateOutlet=\"item.templateRef;context:{filterDef:filterDef, isInline: true}\">\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!filter?.sorts?.length\">\r\n <ng-container *ngIf=\"columns?.length && !filter?.inlineColumn\">\r\n <ng-container *ngFor=\"let item of columns | sdFilterColumn\">\r\n <ng-container *ngTemplateOutlet=\"filterColumn; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"externalFilters?.length\">\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal\">\r\n <ng-container *ngTemplateOutlet=\"filterExternal; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of filterDefs\">\r\n <div *ngIf=\"inlineFilterDef[item.sdMaterialFilterDef]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <ng-container *ngTemplateOutlet=\"item.templateRef;context:{filterDef:filterDef, isInline: true}\">\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n <ng-template #filterColumn let-item=\"item\">\r\n <div *ngIf=\"inlineColumn[item.field]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <sd-input [label]=\"item.title\" *ngIf=\"item.type === 'string'\" type=\"text\" [(model)]=\"columnFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"columnFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select [label]=\"item.title\" *ngIf=\"item.type === 'bool'\" [items]=\"[{value:'1',display:item.option?.displayOnTrue || 'True' },\r\n {value:'0',display:item.option?.displayOnFalse || 'False' }]\" valueField=\"value\" displayField=\"display\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n <sd-select *ngIf=\"item.type === 'values' && item?.option?.selection !== 'AUTOCOMPLETE'\"\r\n [items]=\"item.option?.items\" [valueField]=\"item.option?.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" [disabled]=\"item.filter?.disabled\"\r\n [multiple]=\"item?.option?.selection === 'MULTIPLE' || item?.item?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [filtered]=\"item?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\" appearance=\"outline\">\r\n </sd-select>\r\n <sd-autocomplete *ngIf=\"item.type === 'values' && item?.option?.selection === 'AUTOCOMPLETE'\"\r\n [items]=\"item.option?.items\" [valueField]=\"item.option?.valueField\" [displayField]=\"item.option?.displayField\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" [disabled]=\"item.filter?.disabled\"\r\n appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-date-time *ngIf=\"item.type === 'date' || item.type === 'datetime' || item.type === 'time'\"\r\n [label]=\"item.title\" [(model)]=\"columnFilter[item.field]\" [type]=\"item.type\" (sdChange)=\"onFilter(item)\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n </div>\r\n </ng-template>\r\n <ng-template #filterExternal let-item=\"item\">\r\n <div *ngIf=\"inlineExternal[item.field]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <sd-input [label]=\"item.title\" *ngIf=\"item.type === 'string'\" type=\"text\" [(model)]=\"externalFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"externalFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select [label]=\"item.title\" *ngIf=\"item.type === 'bool'\" [items]=\"[{value:'1',display:item.option?.displayOnTrue || 'True' },\r\n {value:'0',display:item.option?.displayOnFalse || 'False' }]\" valueField=\"value\" displayField=\"display\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n <ng-container *ngIf=\"item.type === 'values' && item.option\">\r\n <sd-select *ngIf=\"item.option?.selection === 'MULTIPLE'\" [label]=\"item.title\" [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" [selectAll]=\"item.option.selectAll\"\r\n appearance=\"outline\" multiple>\r\n </sd-select>\r\n <sd-autocomplete *ngIf=\"item.option?.selection === 'AUTOCOMPLETE'\" [label]=\"item.title\"\r\n [items]=\"item.option.items\" [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-select *ngIf=\"item.option?.selection === 'MULTIPLEAUTOCOMPLETE'\" [label]=\"item.title\"\r\n [items]=\"item.option.items\" [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" filtered=\"true\" appearance=\"outline\"\r\n multiple>\r\n </sd-select>\r\n <sd-select *ngIf=\"!item.option?.selection\" [label]=\"item.title\" [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n </ng-container>\r\n <sd-date-time [label]=\"item.title\" *ngIf=\"item.type ==='date' || item.type ==='datetime'\"\r\n [(model)]=\"externalFilter[item.field]\" [type]=\"item.type\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-date-time>\r\n <sd-date-range [label]=\"item.title\" *ngIf=\"item.type ==='daterange' && externalFilter[item.field]\"\r\n [(from)]=\"externalFilter[item.field].from\" [(to)]=\"externalFilter[item.field].to\" [min]=\"item.minDate\"\r\n [max]=\"item.maxDate\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-date-range>\r\n </div>\r\n </ng-template>\r\n <sd-popup-filter [filterRegister]=\"filterRegister\" [columns]=\"columns\"\r\n [externalFilters]=\"externalFilters\" [filterDefs]=\"filterDefs\">\r\n </sd-popup-filter>\r\n </ng-template>\r\n</ng-container>",
221
+ changeDetection: ChangeDetectionStrategy.OnPush,
222
+ styles: [":host{display:block;padding-bottom:10px;padding-left:0;padding-right:0}:host ::ng-deep .mat-form-field-wrapper{padding-bottom:0}"]
223
+ },] }
224
+ ];
225
+ SdGridFilter.ctorParameters = () => [
226
+ { type: ChangeDetectorRef },
227
+ { type: DeviceDetectorService }
228
+ ];
229
+ SdGridFilter.propDecorators = {
230
+ popupFilter: [{ type: ViewChild, args: [SdPopupFilter,] }],
231
+ _filter: [{ type: Input, args: ['filter',] }],
232
+ columns: [{ type: Input }],
233
+ _externalFilters: [{ type: Input, args: ['externalFilters',] }],
234
+ filterDefs: [{ type: Input }],
235
+ _filterRegister: [{ type: Input, args: ['filterRegister',] }]
236
+ };
237
+
238
+ class SdMaterialFilterDefDirective {
239
+ constructor(templateRef) {
240
+ this.templateRef = templateRef;
241
+ }
242
+ set showing(val) {
243
+ this.defaultShowing = (val === '') || val;
244
+ }
245
+ }
246
+ SdMaterialFilterDefDirective.decorators = [
247
+ { type: Directive, args: [{
248
+ selector: '[sdMaterialFilterDef]'
249
+ },] }
250
+ ];
251
+ SdMaterialFilterDefDirective.ctorParameters = () => [
252
+ { type: TemplateRef }
253
+ ];
254
+ SdMaterialFilterDefDirective.propDecorators = {
255
+ sdMaterialFilterDef: [{ type: Input }],
256
+ showing: [{ type: Input, args: ['defaultShowing',] }]
257
+ };
258
+
259
+ class SdMaterialSubInformationDefDirective {
260
+ constructor(templateRef) {
261
+ this.templateRef = templateRef;
262
+ }
263
+ }
264
+ SdMaterialSubInformationDefDirective.decorators = [
265
+ { type: Directive, args: [{
266
+ selector: '[sdMaterialSubInformationDef]'
267
+ },] }
268
+ ];
269
+ SdMaterialSubInformationDefDirective.ctorParameters = () => [
270
+ { type: TemplateRef }
271
+ ];
272
+
273
+ class SdMaterialFooterDefDirective {
274
+ constructor(templateRef) {
275
+ this.templateRef = templateRef;
276
+ }
277
+ }
278
+ SdMaterialFooterDefDirective.decorators = [
279
+ { type: Directive, args: [{
280
+ selector: '[sdMaterialFooterDef]'
281
+ },] }
282
+ ];
283
+ SdMaterialFooterDefDirective.ctorParameters = () => [
284
+ { type: TemplateRef }
285
+ ];
286
+ SdMaterialFooterDefDirective.propDecorators = {
287
+ sdMaterialFooterDef: [{ type: Input }]
288
+ };
289
+
290
+ class SdMaterialEmptyDataDefDirective {
291
+ constructor(templateRef) {
292
+ this.templateRef = templateRef;
293
+ }
294
+ }
295
+ SdMaterialEmptyDataDefDirective.decorators = [
296
+ { type: Directive, args: [{
297
+ selector: '[sdMaterialEmptyDataDef]'
298
+ },] }
299
+ ];
300
+ SdMaterialEmptyDataDefDirective.ctorParameters = () => [
301
+ { type: TemplateRef }
302
+ ];
303
+
304
+ var _COLUMNS, _cache, _getKey, _default, _load, _get, _set, _remove;
305
+ class SdTableConfigurationService {
306
+ constructor(settingService, gridMaterialConfiguration) {
307
+ this.settingService = settingService;
308
+ this.gridMaterialConfiguration = gridMaterialConfiguration;
309
+ _COLUMNS.set(this, {
310
+ EDITORVALIDATION: 'sdEditorValidation',
311
+ EDITOR: 'sdEditor',
312
+ SUBINFORMATION: 'sdSubInformationAction',
313
+ COMMAND: 'sdCommand',
314
+ SELECTION: 'sdSelection',
315
+ GROUP: 'sdGroup',
316
+ });
317
+ _cache.set(this, {});
318
+ this.init = (key, gridOption) => {
319
+ if (!__classPrivateFieldGet(this, _cache)[key]) {
320
+ const subject = new Subject();
321
+ __classPrivateFieldGet(this, _cache)[key] = {
322
+ load: __classPrivateFieldGet(this, _load).call(this, gridOption, subject),
323
+ get: __classPrivateFieldGet(this, _get).call(this, gridOption),
324
+ set: (configuration) => {
325
+ configuration = __classPrivateFieldGet(this, _set).call(this, gridOption, configuration);
326
+ subject.next(Object.assign({}, configuration));
327
+ return configuration;
328
+ },
329
+ remove: () => {
330
+ __classPrivateFieldGet(this, _remove).call(this, gridOption)();
331
+ subject.next(__classPrivateFieldGet(this, _default).call(this, gridOption));
332
+ },
333
+ observer: subject,
334
+ };
335
+ }
336
+ return __classPrivateFieldGet(this, _cache)[key];
337
+ };
338
+ _getKey.set(this, (gridOption) => {
339
+ var _a, _b;
340
+ const prefix = 'c9e94836-6ace-4aeb-b148-4f0be63589ee';
341
+ if (!((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.key) && !(gridOption === null || gridOption === void 0 ? void 0 : gridOption.key)) {
342
+ return null;
343
+ }
344
+ return hash__default({
345
+ prefix,
346
+ key: ((_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.key) || !(gridOption === null || gridOption === void 0 ? void 0 : gridOption.key),
347
+ });
348
+ });
349
+ _default.set(this, (gridOption) => {
350
+ var _a;
351
+ const columns = ((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.columns) === null || _a === void 0 ? void 0 : _a.filter(e => !e.hidden).map(e => ({
352
+ origin: {
353
+ field: e.field,
354
+ title: e.title,
355
+ width: e.width,
356
+ invisible: e.invisible,
357
+ },
358
+ invisible: e.invisible,
359
+ fixed: false,
360
+ }))) || [];
361
+ return {
362
+ columns,
363
+ };
364
+ });
365
+ _load.set(this, (gridOption, subject) => {
366
+ return () => __awaiter(this, void 0, void 0, function* () {
367
+ const get = __classPrivateFieldGet(this, _get).call(this, gridOption);
368
+ const configuration = yield get();
369
+ subject.next(Object.assign({}, configuration));
370
+ });
371
+ });
372
+ _get.set(this, (gridOption) => {
373
+ return () => __awaiter(this, void 0, void 0, function* () {
374
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
375
+ if (!key) {
376
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
377
+ }
378
+ const { columns, config } = gridOption;
379
+ let configuration;
380
+ if ((config === null || config === void 0 ? void 0 : config.storage) === 'server') {
381
+ const { get, remove } = this.settingService.createServer(key, {
382
+ args: config === null || config === void 0 ? void 0 : config.args,
383
+ });
384
+ configuration = yield get().catch(() => undefined);
385
+ if (!(configuration === null || configuration === void 0 ? void 0 : configuration.columns)) {
386
+ remove().catch(console.error);
387
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
388
+ }
389
+ }
390
+ else {
391
+ const { get, remove } = this.settingService.create(key, {
392
+ type: config === null || config === void 0 ? void 0 : config.storage,
393
+ args: config === null || config === void 0 ? void 0 : config.args,
394
+ });
395
+ configuration = get();
396
+ if (!(configuration === null || configuration === void 0 ? void 0 : configuration.columns)) {
397
+ remove();
398
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
399
+ }
400
+ }
401
+ configuration.columns = configuration.columns.filter(column => columns.some(e => !e.hidden && e.field === column.origin.field));
402
+ // Thêm những column mới vào storage nếu có
403
+ columns.forEach(column => {
404
+ const col = configuration.columns.find(e => { var _a; return ((_a = e.origin) === null || _a === void 0 ? void 0 : _a.field) === column.field; });
405
+ if (!col) {
406
+ configuration.columns.push({
407
+ origin: {
408
+ field: column.field,
409
+ title: column.title,
410
+ width: column.width,
411
+ invisible: column.invisible,
412
+ },
413
+ invisible: column.invisible,
414
+ fixed: false,
415
+ });
416
+ }
417
+ else {
418
+ col.origin = {
419
+ field: column.field,
420
+ title: column.title,
421
+ width: column.width,
422
+ invisible: column.invisible,
423
+ };
424
+ }
425
+ });
426
+ return configuration;
427
+ });
428
+ });
429
+ _set.set(this, (gridOption, configuration) => {
430
+ var _a, _b, _c, _d;
431
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
432
+ if (key) {
433
+ if (((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.storage) === 'server') {
434
+ const { set } = this.settingService.createServer(key, {
435
+ args: (_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.args,
436
+ });
437
+ set(configuration);
438
+ }
439
+ else {
440
+ const { set } = this.settingService.create(key, {
441
+ type: (_c = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _c === void 0 ? void 0 : _c.storage,
442
+ args: (_d = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _d === void 0 ? void 0 : _d.args,
443
+ });
444
+ set(configuration);
445
+ }
446
+ }
447
+ return JSON.parse(JSON.stringify(configuration));
448
+ });
449
+ _remove.set(this, (gridOption) => {
450
+ return () => {
451
+ var _a, _b, _c, _d;
452
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
453
+ if (key) {
454
+ if (((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.storage) === 'server') {
455
+ const { remove } = this.settingService.createServer(key, {
456
+ args: (_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.args,
457
+ });
458
+ remove();
459
+ }
460
+ else {
461
+ const { remove } = this.settingService.create(key, {
462
+ type: (_c = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _c === void 0 ? void 0 : _c.storage,
463
+ args: (_d = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _d === void 0 ? void 0 : _d.args,
464
+ });
465
+ remove();
466
+ }
467
+ }
468
+ };
469
+ });
470
+ // get = async (gridOption: SdGridMaterialOption): Promise<SdGridConfiguration> => {
471
+ // if (!gridOption?.key) {
472
+ // return this.#getDefaultConfiguration(gridOption);
473
+ // }
474
+ // const { key, columns } = gridOption;
475
+ // const configuration: SdGridConfiguration = await this.settingService.get(this.#getKey(key)).catch(() => undefined);
476
+ // if (!configuration?.columns) {
477
+ // this.settingService.remove(this.#getKey(key)).catch(console.error);
478
+ // return this.#getDefaultConfiguration(gridOption);
479
+ // }
480
+ // configuration.columns = configuration.columns
481
+ // .filter(column => columns.some(e => !e.hidden && e.field === column.origin.field));
482
+ // // Thêm những column mới vào storage nếu có
483
+ // columns.forEach(column => {
484
+ // const col = configuration.columns.find(e => e.origin?.field === column.field);
485
+ // if (!col) {
486
+ // configuration.columns.push({
487
+ // origin: {
488
+ // field: column.field,
489
+ // title: column.title,
490
+ // width: column.width,
491
+ // invisible: column.invisible,
492
+ // },
493
+ // invisible: column.invisible,
494
+ // fixed: false
495
+ // });
496
+ // } else {
497
+ // col.origin = {
498
+ // field: column.field,
499
+ // title: column.title,
500
+ // width: column.width,
501
+ // invisible: column.invisible
502
+ // };
503
+ // }
504
+ // });
505
+ // return configuration;
506
+ // }
507
+ // set = async (key: string, configuration: SdGridConfiguration): Promise<SdGridConfiguration> => {
508
+ // if (key) {
509
+ // this.settingService.set(this.#getKey(key), configuration);
510
+ // }
511
+ // return configuration;
512
+ // }
513
+ // remove = (key: string) => {
514
+ // if (key) {
515
+ // this.settingService.remove(this.#getKey(key));
516
+ // }
517
+ // }
518
+ this.generateConfigurationResult = (configuration, gridOption, sdSubInformation) => {
519
+ var _a, _b;
520
+ const result = {
521
+ column: {},
522
+ fixedColumn: {},
523
+ firstColumns: [],
524
+ secondColumns: [],
525
+ firstHeaders: [],
526
+ secondHeaders: [],
527
+ displayedColumns: [],
528
+ displayedFooters: [],
529
+ multipleHeader: false,
530
+ };
531
+ const { selector, commands, group } = gridOption || {};
532
+ if (selector === null || selector === void 0 ? void 0 : selector.visible) {
533
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).SELECTION);
534
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).SELECTION);
535
+ }
536
+ if (commands === null || commands === void 0 ? void 0 : commands.length) {
537
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).COMMAND);
538
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).COMMAND);
539
+ }
540
+ if ((_a = group === null || group === void 0 ? void 0 : group.fields) === null || _a === void 0 ? void 0 : _a.length) {
541
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).GROUP);
542
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).GROUP);
543
+ }
544
+ (_b = configuration === null || configuration === void 0 ? void 0 : configuration.columns) === null || _b === void 0 ? void 0 : _b.filter(col => !col.invisible).forEach(col => {
545
+ var _a;
546
+ const column = gridOption === null || gridOption === void 0 ? void 0 : gridOption.columns.find(e => e.field === col.origin.field);
547
+ if (column) {
548
+ result.column[col.origin.field] = {
549
+ title: col.title || col.origin.title,
550
+ width: col.width || col.origin.width,
551
+ };
552
+ if (col.fixed) {
553
+ result.fixedColumn[col.origin.field] = {
554
+ title: col.title || col.origin.title,
555
+ width: col.width || col.origin.width,
556
+ };
557
+ }
558
+ result.firstColumns.push(Object.assign(Object.assign({}, column), { title: col.title || col.origin.title, width: col.width || col.origin.width }));
559
+ result.firstHeaders.push(col.origin.field);
560
+ result.displayedColumns.push(col.origin.field);
561
+ if (column.type === 'children') {
562
+ (_a = column.children) === null || _a === void 0 ? void 0 : _a.forEach(childColumn => {
563
+ result.secondColumns.push(childColumn);
564
+ result.secondHeaders.push(childColumn.field);
565
+ result.displayedColumns.push(childColumn.field);
566
+ });
567
+ }
568
+ }
569
+ });
570
+ if (sdSubInformation === null || sdSubInformation === void 0 ? void 0 : sdSubInformation.templateRef) {
571
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
572
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
573
+ }
574
+ result.multipleHeader = result.secondHeaders.length > 0;
575
+ // Sub infomation không thể có footer
576
+ result.displayedFooters = result.displayedColumns.filter(val => val !== __classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
577
+ return result;
578
+ };
579
+ }
580
+ }
581
+ _COLUMNS = new WeakMap(), _cache = new WeakMap(), _getKey = new WeakMap(), _default = new WeakMap(), _load = new WeakMap(), _get = new WeakMap(), _set = new WeakMap(), _remove = new WeakMap();
582
+ SdTableConfigurationService.decorators = [
583
+ { type: Injectable }
584
+ ];
585
+ SdTableConfigurationService.ctorParameters = () => [
586
+ { type: SdSettingService },
587
+ { type: undefined, decorators: [{ type: Inject, args: [TABLE_CONFIG,] }, { type: Optional }] }
588
+ ];
589
+
590
+ const MapToSdTableItem = (item) => ({
591
+ current: JSON.parse(JSON.stringify(item)),
592
+ origin: item,
593
+ meta: {
594
+ id: hash(item),
595
+ expand: {
596
+ isExpanding: false,
597
+ isExpanded: false,
598
+ },
599
+ group: {},
600
+ selector: { actions: [], isSelected: false, selectable: false },
601
+ },
602
+ });
603
+
604
+ var _prefix, _cache$1;
605
+ class SdColumnValuesPipe {
606
+ constructor() {
607
+ _prefix.set(this, 'a1e67660-8aa2-4c11-b02d-71a32188719f');
608
+ _cache$1.set(this, {});
609
+ this.transform = (value, column) => __awaiter(this, void 0, void 0, function* () {
610
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
611
+ if (column.type !== 'values' || !((_a = column.option) === null || _a === void 0 ? void 0 : _a.items) || !((_b = column.option) === null || _b === void 0 ? void 0 : _b.valueField) || !((_c = column.option) === null || _c === void 0 ? void 0 : _c.displayField)) {
612
+ return value;
613
+ }
614
+ const _l = column.option, { items, valueField, displayField, selection } = _l, remain = __rest(_l, ["items", "valueField", "displayField", "selection"]);
615
+ const key = hash__default({
616
+ prefix: __classPrivateFieldGet(this, _prefix),
617
+ valueField,
618
+ displayField,
619
+ selection,
620
+ remain,
621
+ value
622
+ });
623
+ const isMultible = ['MULTIPLE', 'MULTIPLEAUTOCOMPLETE', 'MULTIPLE_EDITOR', 'MULTIPLEAUTOCOMPLETE_EDITOR'].includes(selection);
624
+ if (typeof (items) === 'function') {
625
+ if (!__classPrivateFieldGet(this, _cache$1)[key]) {
626
+ const values = yield items(value, true);
627
+ let result = '';
628
+ if (isMultible && Array.isArray(value)) {
629
+ result = ((_e = (_d = values === null || values === void 0 ? void 0 : values.filter(e => value === null || value === void 0 ? void 0 : value.includes(e === null || e === void 0 ? void 0 : e[valueField]))) === null || _d === void 0 ? void 0 : _d.map(e => e === null || e === void 0 ? void 0 : e[displayField])) === null || _e === void 0 ? void 0 : _e.join(', ')) || (value === null || value === void 0 ? void 0 : value.join(', '));
630
+ }
631
+ else {
632
+ result = ((_f = values === null || values === void 0 ? void 0 : values.find(e => (e === null || e === void 0 ? void 0 : e[valueField]) === value)) === null || _f === void 0 ? void 0 : _f[displayField]) || value;
633
+ }
634
+ __classPrivateFieldGet(this, _cache$1)[key] = {
635
+ result
636
+ };
637
+ }
638
+ }
639
+ else {
640
+ if (!__classPrivateFieldGet(this, _cache$1)[key]) {
641
+ let result = '';
642
+ if (isMultible && Array.isArray(value)) {
643
+ result = (_j = (_h = (_g = items === null || items === void 0 ? void 0 : items.filter(e => value === null || value === void 0 ? void 0 : value.includes(e === null || e === void 0 ? void 0 : e[valueField]))) === null || _g === void 0 ? void 0 : _g.map(e => e === null || e === void 0 ? void 0 : e[displayField])) === null || _h === void 0 ? void 0 : _h.join(', ')) !== null && _j !== void 0 ? _j : value === null || value === void 0 ? void 0 : value.join(', ');
644
+ }
645
+ else {
646
+ result = ((_k = items === null || items === void 0 ? void 0 : items.find(e => (e === null || e === void 0 ? void 0 : e[valueField]) === value)) === null || _k === void 0 ? void 0 : _k[displayField]) || value;
647
+ }
648
+ __classPrivateFieldGet(this, _cache$1)[key] = {
649
+ result
650
+ };
651
+ }
652
+ }
653
+ return __classPrivateFieldGet(this, _cache$1)[key].result;
654
+ });
655
+ }
656
+ }
657
+ _prefix = new WeakMap(), _cache$1 = new WeakMap();
658
+ SdColumnValuesPipe.decorators = [
659
+ { type: Pipe, args: [{
660
+ name: 'columnValues'
661
+ },] }
662
+ ];
663
+
664
+ var _filterConfiguration, _filterValue, _cache$2, _defaultConfiguration, _defaultValue, _initConfiguration, _initValue;
665
+ class SdTableFilterService {
666
+ constructor(settingService) {
667
+ this.settingService = settingService;
668
+ _filterConfiguration.set(this, 'GRID-FILTER-CONFIGURATION');
669
+ _filterValue.set(this, 'GRID-FILTER-VALUE');
670
+ _cache$2.set(this, {});
671
+ this.register = (filter, args) => {
672
+ let cacheSession = false;
673
+ const { id, columns, externalFilters } = args;
674
+ const tempKey = hash__default({
675
+ id,
676
+ columns: (columns === null || columns === void 0 ? void 0 : columns.map(e => e.field).filter(field => !!field)) || [],
677
+ externalFilters: (externalFilters === null || externalFilters === void 0 ? void 0 : externalFilters.map(e => e.field).filter(field => !!field)) || [],
678
+ });
679
+ const key = (filter === null || filter === void 0 ? void 0 : filter.key) || tempKey;
680
+ if (!(filter === null || filter === void 0 ? void 0 : filter.key)) {
681
+ cacheSession = true; // Nếu không có key thì chỉ lưu theo session
682
+ }
683
+ if (!__classPrivateFieldGet(this, _cache$2)[key]) {
684
+ // Setting của filter configuration
685
+ const filterConfiguration = this.settingService.create({
686
+ prefix: __classPrivateFieldGet(this, _filterConfiguration),
687
+ key,
688
+ }, {
689
+ default: __classPrivateFieldGet(this, _defaultConfiguration).call(this, args),
690
+ type: cacheSession ? 'session' : undefined,
691
+ });
692
+ // Lấy giá trị configuration merge với giá trị defaultShowing của args nếu như args có thay đổi
693
+ filterConfiguration.set(__classPrivateFieldGet(this, _initConfiguration).call(this, args, filterConfiguration.get()));
694
+ // Setting của filter value
695
+ const filterValue = this.settingService.create({
696
+ prefix: __classPrivateFieldGet(this, _filterValue),
697
+ key: !(filter === null || filter === void 0 ? void 0 : filter.cacheFilter) ? tempKey : key,
698
+ }, {
699
+ default: __classPrivateFieldGet(this, _defaultValue).call(this, args),
700
+ type: cacheSession || !(filter === null || filter === void 0 ? void 0 : filter.cacheFilter) ? 'session' : undefined,
701
+ });
702
+ // Lấy giá trị value merge với giá trị default của args nếu như args có thay đổi
703
+ filterValue.set(__classPrivateFieldGet(this, _initValue).call(this, args, filterValue.get()));
704
+ __classPrivateFieldGet(this, _cache$2)[key] = {
705
+ configuration: {
706
+ get: () => {
707
+ return filterConfiguration.get();
708
+ },
709
+ set: (configuration) => {
710
+ const { inlineColumn, inlineExternal, inlineFilterDef } = configuration;
711
+ filterConfiguration.set({
712
+ inlineColumn,
713
+ inlineExternal,
714
+ inlineFilterDef,
715
+ });
716
+ return {
717
+ inlineColumn,
718
+ inlineExternal,
719
+ inlineFilterDef,
720
+ };
721
+ },
722
+ remove: () => {
723
+ filterConfiguration.set(__classPrivateFieldGet(this, _defaultConfiguration).call(this, args));
724
+ },
725
+ observer: filterConfiguration.observer.pipe(startWith(filterConfiguration.get()),
726
+ // Sử dụng mặc định nếu bị reset
727
+ map(configuration => configuration || __classPrivateFieldGet(this, _defaultConfiguration).call(this, args))),
728
+ },
729
+ value: {
730
+ get: () => {
731
+ return filterValue.get();
732
+ },
733
+ set: (value) => {
734
+ const keys = Object.keys(value || {});
735
+ const current = filterValue.get();
736
+ const { columnOperator, columnFilter, externalFilter, filterDef, notReload } = current;
737
+ const updatedFilter = {
738
+ // Filter column
739
+ columnOperator: keys.includes('columnOperator') ? (value === null || value === void 0 ? void 0 : value.columnOperator) || {} : columnOperator,
740
+ columnFilter: keys.includes('columnFilter') ? (value === null || value === void 0 ? void 0 : value.columnFilter) || {} : columnFilter,
741
+ // Filter external
742
+ externalFilter: keys.includes('externalFilter') ? (value === null || value === void 0 ? void 0 : value.externalFilter) || {} : externalFilter,
743
+ // Filter def
744
+ filterDef: keys.includes('filterDef') ? (value === null || value === void 0 ? void 0 : value.filterDef) || {} : filterDef,
745
+ // Force
746
+ notReload: !!notReload,
747
+ };
748
+ filterValue.set(updatedFilter);
749
+ return updatedFilter;
750
+ },
751
+ remove: () => {
752
+ filterValue.set(__classPrivateFieldGet(this, _defaultValue).call(this, args));
753
+ },
754
+ observer: filterValue.observer.pipe(startWith(filterValue.get()),
755
+ // Sử dụng mặc định nếu bị reset
756
+ map(value => value || __classPrivateFieldGet(this, _defaultValue).call(this, args))),
757
+ },
758
+ };
759
+ }
760
+ return __classPrivateFieldGet(this, _cache$2)[key];
761
+ };
762
+ _defaultConfiguration.set(this, (args) => {
763
+ var _a;
764
+ const { columns, externalFilters, filterDefs } = args;
765
+ const inlineColumn = {};
766
+ const inlineExternal = {};
767
+ const inlineFilterDef = {};
768
+ // Filter column
769
+ for (const item of columns || []) {
770
+ inlineColumn[item.field] = (_a = item === null || item === void 0 ? void 0 : item.filter) === null || _a === void 0 ? void 0 : _a.defaultShowing;
771
+ }
772
+ // Filter external
773
+ for (const item of externalFilters || []) {
774
+ inlineExternal[item.field] = item === null || item === void 0 ? void 0 : item.defaultShowing;
775
+ }
776
+ // Filter def
777
+ for (const item of filterDefs || []) {
778
+ inlineFilterDef[item.sdMaterialFilterDef] = item === null || item === void 0 ? void 0 : item.defaultShowing;
779
+ }
780
+ return {
781
+ // Filter column
782
+ inlineColumn,
783
+ // Filter external
784
+ inlineExternal,
785
+ // Filter def
786
+ inlineFilterDef,
787
+ };
788
+ });
789
+ _defaultValue.set(this, (args) => {
790
+ var _a;
791
+ const columnFilter = {};
792
+ const externalFilter = {};
793
+ const filterDef = {};
794
+ const { columns, externalFilters, filterDefs } = args;
795
+ // Filter column
796
+ for (const item of columns || []) {
797
+ columnFilter[item.field] = (_a = item === null || item === void 0 ? void 0 : item.filter) === null || _a === void 0 ? void 0 : _a.default;
798
+ }
799
+ // Filter external
800
+ for (const item of externalFilters || []) {
801
+ externalFilter[item.field] = item === null || item === void 0 ? void 0 : item.default;
802
+ }
803
+ // Filter def
804
+ for (const item of filterDefs || []) {
805
+ filterDef[item.sdMaterialFilterDef] = undefined;
806
+ }
807
+ return {
808
+ // Filter column
809
+ columnFilter,
810
+ // Filter external
811
+ externalFilter,
812
+ // Filter def
813
+ filterDef,
814
+ };
815
+ });
816
+ _initConfiguration.set(this, (args, configuration) => {
817
+ var _a, _b, _c, _d, _e, _f, _g;
818
+ const { columns, externalFilters, filterDefs } = args;
819
+ const inlineColumn = {};
820
+ const inlineExternal = {};
821
+ const inlineFilterDef = {};
822
+ // Filter column
823
+ for (const item of columns || []) {
824
+ inlineColumn[item.field] = (_b = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.inlineColumn) === null || _a === void 0 ? void 0 : _a[item.field]) !== null && _b !== void 0 ? _b : (_c = item === null || item === void 0 ? void 0 : item.filter) === null || _c === void 0 ? void 0 : _c.defaultShowing;
825
+ }
826
+ // Filter external
827
+ for (const item of externalFilters || []) {
828
+ inlineExternal[item.field] = (_e = (_d = configuration === null || configuration === void 0 ? void 0 : configuration.inlineExternal) === null || _d === void 0 ? void 0 : _d[item.field]) !== null && _e !== void 0 ? _e : item === null || item === void 0 ? void 0 : item.defaultShowing;
829
+ }
830
+ // Filter def
831
+ for (const item of filterDefs || []) {
832
+ inlineFilterDef[item.sdMaterialFilterDef] = (_g = (_f = configuration === null || configuration === void 0 ? void 0 : configuration.inlineFilterDef) === null || _f === void 0 ? void 0 : _f[item.sdMaterialFilterDef]) !== null && _g !== void 0 ? _g : item === null || item === void 0 ? void 0 : item.defaultShowing;
833
+ }
834
+ return {
835
+ // Filter column
836
+ inlineColumn,
837
+ // Filter external
838
+ inlineExternal,
839
+ // Filter def
840
+ inlineFilterDef,
841
+ };
842
+ });
843
+ _initValue.set(this, (args, value) => {
844
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
845
+ const columnFilter = {};
846
+ const externalFilter = {};
847
+ const filterDef = {};
848
+ const { columns, externalFilters, filterDefs } = args;
849
+ // Filter column
850
+ for (const item of columns || []) {
851
+ columnFilter[item.field] = (_b = (_a = value === null || value === void 0 ? void 0 : value.columnFilter) === null || _a === void 0 ? void 0 : _a[item.field]) !== null && _b !== void 0 ? _b : (_c = item === null || item === void 0 ? void 0 : item.filter) === null || _c === void 0 ? void 0 : _c.default;
852
+ }
853
+ // Filter external
854
+ for (const item of externalFilters || []) {
855
+ if (item.type === 'daterange') {
856
+ externalFilter[item.field] = {
857
+ from: (_f = (_e = (_d = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _d === void 0 ? void 0 : _d[item.field]) === null || _e === void 0 ? void 0 : _e.from) !== null && _f !== void 0 ? _f : (_g = item.default) === null || _g === void 0 ? void 0 : _g.from,
858
+ to: (_k = (_j = (_h = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _h === void 0 ? void 0 : _h[item.field]) === null || _j === void 0 ? void 0 : _j.to) !== null && _k !== void 0 ? _k : (_l = item.default) === null || _l === void 0 ? void 0 : _l.to,
859
+ };
860
+ }
861
+ else {
862
+ externalFilter[item.field] = (_o = (_m = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _m === void 0 ? void 0 : _m[item.field]) !== null && _o !== void 0 ? _o : item === null || item === void 0 ? void 0 : item.default;
863
+ }
864
+ }
865
+ // Filter def
866
+ for (const item of filterDefs || []) {
867
+ filterDef[item.sdMaterialFilterDef] = (_q = (_p = value === null || value === void 0 ? void 0 : value.filterDef) === null || _p === void 0 ? void 0 : _p[item.sdMaterialFilterDef]) !== null && _q !== void 0 ? _q : undefined;
868
+ }
869
+ return {
870
+ // Filter column
871
+ columnFilter,
872
+ // Filter external
873
+ externalFilter,
874
+ // Filter def
875
+ filterDef,
876
+ };
877
+ });
878
+ }
879
+ }
880
+ _filterConfiguration = new WeakMap(), _filterValue = new WeakMap(), _cache$2 = new WeakMap(), _defaultConfiguration = new WeakMap(), _defaultValue = new WeakMap(), _initConfiguration = new WeakMap(), _initValue = new WeakMap();
881
+ SdTableFilterService.decorators = [
882
+ { type: Injectable }
883
+ ];
884
+ SdTableFilterService.ctorParameters = () => [
885
+ { type: SdSettingService }
886
+ ];
887
+
888
+ var _gridId, _optionChanges, _localItems, _paginator, _sort, _subscription$1, _reload, _loadCompleted, _initCellDef, _initFilterDef, _initFooterDef, _filterExportInfo, _initConfiguration$1, _loadFilterRegister, _filterLocal, _getFilter, _load$1, _render, _exportedItems, _allColumns, _allExportedColumns, _onExport, _getExportColumns, _updateSelectedItems;
889
+ class SdTable {
890
+ constructor(ref, configuration, gridConfigurationService, exportService, notifyService, columnValuesPipe, gridFilterService) {
891
+ this.ref = ref;
892
+ this.configuration = configuration;
893
+ this.gridConfigurationService = gridConfigurationService;
894
+ this.exportService = exportService;
895
+ this.notifyService = notifyService;
896
+ this.columnValuesPipe = columnValuesPipe;
897
+ this.gridFilterService = gridFilterService;
898
+ _gridId.set(this, v4());
899
+ this.key = v4();
900
+ _optionChanges.set(this, new Subject());
901
+ _localItems.set(this, []);
902
+ this.items = [];
903
+ this.selectedItems = [];
904
+ // Loading
905
+ this.isLoading = false;
906
+ // Paginate
907
+ this.isHiddenPaginator = false;
908
+ _paginator.set(this, void 0);
909
+ // Sorting
910
+ _sort.set(this, void 0);
911
+ // Cell Def
912
+ this.sdCellDefs = new QueryList();
913
+ this.cellDef = {};
914
+ // Footer Def
915
+ this.sdFooterDefs = new QueryList();
916
+ this.footerDef = {};
917
+ this.hasFooter = false;
918
+ // Filter Def
919
+ this.sdFilterDefs = new QueryList();
920
+ this.filterDefs = [];
921
+ // Filter
922
+ this.columnOperator = {};
923
+ this.columnFilter = {};
924
+ // Subcription
925
+ _subscription$1.set(this, new Subscription());
926
+ _reload.set(this, new Subject());
927
+ this.isExporting = false;
928
+ this.isSelectAll = false;
929
+ this.exportTitle = 'Export';
930
+ _loadCompleted.set(this, false);
931
+ _initCellDef.set(this, () => {
932
+ this.cellDef = {};
933
+ for (const cellDef of this.sdCellDefs) {
934
+ if (cellDef.sdMaterialCellDef) {
935
+ this.cellDef[cellDef.sdMaterialCellDef] = cellDef;
936
+ }
937
+ }
938
+ });
939
+ _initFilterDef.set(this, () => {
940
+ this.filterDefs = [];
941
+ for (const filterDef of this.sdFilterDefs) {
942
+ this.filterDefs.push(filterDef);
943
+ }
944
+ });
945
+ _initFooterDef.set(this, () => {
946
+ this.footerDef = {};
947
+ this.hasFooter = false;
948
+ for (const footerDef of this.sdFooterDefs) {
949
+ if (footerDef.sdMaterialFooterDef) {
950
+ this.hasFooter = true;
951
+ this.footerDef[footerDef.sdMaterialFooterDef] = footerDef;
952
+ }
953
+ }
954
+ });
955
+ _filterExportInfo.set(this, (pageNumber, pageSize) => {
956
+ var _a, _b;
957
+ const { columnOperator, columnFilter, externalFilter, filterDef } = this.filterRegister.value.get();
958
+ return {
959
+ columnOperator: columnOperator || {},
960
+ rawColumnFilter: columnFilter || {},
961
+ rawExternalFilter: externalFilter || {},
962
+ rawFilterDef: filterDef || {},
963
+ orderBy: ((_a = __classPrivateFieldGet(this, _sort)) === null || _a === void 0 ? void 0 : _a.active) || '',
964
+ orderDirection: ((_b = __classPrivateFieldGet(this, _sort)) === null || _b === void 0 ? void 0 : _b.direction) || '',
965
+ pageNumber,
966
+ pageSize,
967
+ isExported: true,
968
+ };
969
+ });
970
+ _initConfiguration$1.set(this, (option) => {
971
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
972
+ // Init pagination
973
+ option.paginate = {
974
+ hidden: (_a = option === null || option === void 0 ? void 0 : option.paginate) === null || _a === void 0 ? void 0 : _a.hidden,
975
+ pageSize: (_f = (_c = (_b = option === null || option === void 0 ? void 0 : option.paginate) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : (_e = (_d = this.configuration) === null || _d === void 0 ? void 0 : _d.paginate) === null || _e === void 0 ? void 0 : _e.pageSize) !== null && _f !== void 0 ? _f : (_g = DEFAULT_TABLE_CONFIG.paginate) === null || _g === void 0 ? void 0 : _g.pageSize,
976
+ pages: (_m = (_j = (_h = option === null || option === void 0 ? void 0 : option.paginate) === null || _h === void 0 ? void 0 : _h.pages) !== null && _j !== void 0 ? _j : (_l = (_k = this.configuration) === null || _k === void 0 ? void 0 : _k.paginate) === null || _l === void 0 ? void 0 : _l.pages) !== null && _m !== void 0 ? _m : (_o = DEFAULT_TABLE_CONFIG.paginate) === null || _o === void 0 ? void 0 : _o.pages,
977
+ showFirstLastButtons: (_q = (_p = option === null || option === void 0 ? void 0 : option.paginate) === null || _p === void 0 ? void 0 : _p.showFirstLastButtons) !== null && _q !== void 0 ? _q : false,
978
+ };
979
+ for (const column of option.columns || []) {
980
+ if (((_s = (_r = column.filter) === null || _r === void 0 ? void 0 : _r.operator) === null || _s === void 0 ? void 0 : _s.enable) && !((_v = (_u = (_t = column.filter) === null || _t === void 0 ? void 0 : _t.operator) === null || _u === void 0 ? void 0 : _u.list) === null || _v === void 0 ? void 0 : _v.length)) {
981
+ if (column.type === 'string') {
982
+ column.filter.operator.list = ((_y = (_x = (_w = this.configuration) === null || _w === void 0 ? void 0 : _w.filter) === null || _x === void 0 ? void 0 : _x.operator) === null || _y === void 0 ? void 0 : _y.defaultListString) || [];
983
+ }
984
+ if (column.type === 'number') {
985
+ column.filter.operator.list = ((_1 = (_0 = (_z = this.configuration) === null || _z === void 0 ? void 0 : _z.filter) === null || _0 === void 0 ? void 0 : _0.operator) === null || _1 === void 0 ? void 0 : _1.defaultListNumber) || [];
986
+ }
987
+ if (column.type === 'values') {
988
+ column.filter.operator.list = ((_4 = (_3 = (_2 = this.configuration) === null || _2 === void 0 ? void 0 : _2.filter) === null || _3 === void 0 ? void 0 : _3.operator) === null || _4 === void 0 ? void 0 : _4.defaultListValues) || [];
989
+ }
990
+ if (column.type === 'date' || column.type === 'datetime') {
991
+ column.filter.operator.list = ((_7 = (_6 = (_5 = this.configuration) === null || _5 === void 0 ? void 0 : _5.filter) === null || _6 === void 0 ? void 0 : _6.operator) === null || _7 === void 0 ? void 0 : _7.defaultListDate) || [];
992
+ }
993
+ }
994
+ }
995
+ return option;
996
+ });
997
+ _loadFilterRegister.set(this, () => {
998
+ var _a, _b, _c, _d;
999
+ // Init filter
1000
+ if (this.gridOption) {
1001
+ if (!this.filterRegister) {
1002
+ this.filterRegister = this.gridFilterService.register((_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.filter, {
1003
+ id: __classPrivateFieldGet(this, _gridId),
1004
+ columns: (_b = this.gridOption) === null || _b === void 0 ? void 0 : _b.columns,
1005
+ externalFilters: (_d = (_c = this.gridOption) === null || _c === void 0 ? void 0 : _c.filter) === null || _d === void 0 ? void 0 : _d.externalFilters,
1006
+ filterDefs: this.filterDefs,
1007
+ });
1008
+ __classPrivateFieldGet(this, _subscription$1).add(this.filterRegister.value.observer
1009
+ .pipe(debounceTime(500), map(filterValue => {
1010
+ const { columnOperator, columnFilter, notReload } = filterValue;
1011
+ this.columnOperator = columnOperator;
1012
+ this.columnFilter = columnFilter;
1013
+ if (!notReload) {
1014
+ __classPrivateFieldGet(this, _paginator).pageIndex = 0;
1015
+ __classPrivateFieldGet(this, _reload).next({
1016
+ force: false,
1017
+ });
1018
+ }
1019
+ }))
1020
+ .subscribe());
1021
+ }
1022
+ }
1023
+ });
1024
+ _filterLocal.set(this, (localItems, filterInfo) => {
1025
+ const { columns } = this.gridOption;
1026
+ const { rawColumnFilter, orderBy, orderDirection, pageSize, pageNumber } = filterInfo;
1027
+ const items = localItems.filter(tableItem => {
1028
+ var _a, _b, _c, _d;
1029
+ const item = tableItem.current;
1030
+ for (const column of columns) {
1031
+ const { field, type } = column;
1032
+ const filterValue = (rawColumnFilter[field] || '').toString().trim().toLowerCase();
1033
+ const columnValue = (item[field] || '').toString().trim().toLowerCase();
1034
+ if (filterValue) {
1035
+ if (!columnValue && type !== 'datetime' && type !== 'date' && type !== 'time') {
1036
+ return false;
1037
+ }
1038
+ if (type === 'string') {
1039
+ if (columnValue.indexOf(filterValue) === -1) {
1040
+ return false;
1041
+ }
1042
+ }
1043
+ else if (type === 'values') {
1044
+ if (columnValue !== filterValue) {
1045
+ return false;
1046
+ }
1047
+ }
1048
+ else if (type === 'number') {
1049
+ const fValue = +filterValue.replace('>=', '').replace('<=', '').replace('>', '').replace('<', '');
1050
+ const cValue = +columnValue;
1051
+ if (fValue || fValue === 0) {
1052
+ if (!cValue && cValue !== 0) {
1053
+ return false;
1054
+ }
1055
+ if (filterValue.indexOf('>=') > -1 && cValue < fValue) {
1056
+ return false;
1057
+ }
1058
+ else if (filterValue.indexOf('<=') > -1 && cValue > fValue) {
1059
+ return false;
1060
+ }
1061
+ else if (filterValue.indexOf('<') > -1 && cValue >= fValue) {
1062
+ return false;
1063
+ }
1064
+ else if (filterValue.indexOf('>') > -1 && cValue <= fValue) {
1065
+ return false;
1066
+ }
1067
+ else if (cValue !== fValue) {
1068
+ return false;
1069
+ }
1070
+ }
1071
+ }
1072
+ else if (type === 'bool') {
1073
+ if (filterValue === '1' && columnValue !== '1' && columnValue !== 'true') {
1074
+ return false;
1075
+ }
1076
+ else if (filterValue === '0' && columnValue !== '0' && columnValue !== 'false') {
1077
+ return false;
1078
+ }
1079
+ }
1080
+ else if (type === 'datetime' || type === 'date' || type === 'time') {
1081
+ const from = (_b = (_a = rawColumnFilter[field]) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : rawColumnFilter[field];
1082
+ const to = (_d = (_c = rawColumnFilter[field]) === null || _c === void 0 ? void 0 : _c.to) !== null && _d !== void 0 ? _d : rawColumnFilter[field];
1083
+ const fromDate = Date.begin(from);
1084
+ const toDate = Date.end(to);
1085
+ if (fromDate || toDate) {
1086
+ if (!columnValue) {
1087
+ return false;
1088
+ }
1089
+ const columnTime = new Date(columnValue).getTime();
1090
+ const fromDateTime = (fromDate === null || fromDate === void 0 ? void 0 : fromDate.getTime()) || null;
1091
+ const toDateTime = (toDate === null || toDate === void 0 ? void 0 : toDate.getTime()) || null;
1092
+ if (fromDateTime && fromDateTime > columnTime) {
1093
+ return false;
1094
+ }
1095
+ if (toDateTime && columnTime > toDateTime) {
1096
+ return false;
1097
+ }
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+ return true;
1103
+ });
1104
+ // Sort
1105
+ if (orderBy && orderDirection) {
1106
+ const column = columns.find(e => e.field === orderBy);
1107
+ if (column) {
1108
+ const { type, field } = column;
1109
+ items.sort((tableItemCurrent, tableItemNext) => {
1110
+ const current = tableItemCurrent.current;
1111
+ const next = tableItemNext.current;
1112
+ if (type === 'number') {
1113
+ return (current[field] || 0) - (next[field] || 0);
1114
+ }
1115
+ if (type === 'date' || type === 'datetime' || type === 'time') {
1116
+ const d1 = new Date(current[field] || '').getTime();
1117
+ const d2 = new Date(current[field] || '').getTime();
1118
+ return d1 - d2;
1119
+ }
1120
+ const s1 = (current[field] || '').toString();
1121
+ const s2 = (next[field] || '').toString();
1122
+ if (s1 > s2) {
1123
+ return 1;
1124
+ }
1125
+ if (s1 < s2) {
1126
+ return -1;
1127
+ }
1128
+ return 0;
1129
+ });
1130
+ if (orderDirection === 'desc') {
1131
+ items.reverse();
1132
+ }
1133
+ }
1134
+ }
1135
+ return {
1136
+ items: items.filter((item, index) => {
1137
+ return index >= pageNumber * pageSize && index < (pageNumber + 1) * pageSize;
1138
+ }),
1139
+ total: items.length,
1140
+ };
1141
+ });
1142
+ _getFilter.set(this, () => {
1143
+ var _a, _b, _c, _d, _e, _f;
1144
+ const { columnOperator, columnFilter, externalFilter, filterDef } = this.filterRegister.value.get();
1145
+ return {
1146
+ columnOperator: columnOperator || {},
1147
+ rawColumnFilter: columnFilter || {},
1148
+ rawExternalFilter: externalFilter || {},
1149
+ rawFilterDef: filterDef || {},
1150
+ orderBy: ((_a = __classPrivateFieldGet(this, _sort)) === null || _a === void 0 ? void 0 : _a.active) || '',
1151
+ orderDirection: ((_b = __classPrivateFieldGet(this, _sort)) === null || _b === void 0 ? void 0 : _b.direction) || '',
1152
+ pageNumber: ((_c = __classPrivateFieldGet(this, _paginator)) === null || _c === void 0 ? void 0 : _c.pageIndex) || 0,
1153
+ pageSize: ((_d = __classPrivateFieldGet(this, _paginator)) === null || _d === void 0 ? void 0 : _d.pageSize) || ((_f = (_e = this.gridOption) === null || _e === void 0 ? void 0 : _e.paginate) === null || _f === void 0 ? void 0 : _f.pageSize) || 50,
1154
+ };
1155
+ });
1156
+ _load$1.set(this, (filterReq, force = true) => __awaiter(this, void 0, void 0, function* () {
1157
+ this.isLoading = true;
1158
+ if (this.gridOption.type === 'server') {
1159
+ const { items } = this.gridOption;
1160
+ const data = yield items(filterReq).catch(err => {
1161
+ this.notifyService.notify.warning('Có lỗi xảy ra');
1162
+ console.error(err);
1163
+ return {
1164
+ items: [],
1165
+ total: 0,
1166
+ };
1167
+ });
1168
+ this.isLoading = false;
1169
+ return {
1170
+ items: (data === null || data === void 0 ? void 0 : data.items.map(MapToSdTableItem)) || [],
1171
+ total: (data === null || data === void 0 ? void 0 : data.total) || 0,
1172
+ };
1173
+ }
1174
+ if (force) {
1175
+ const { items } = this.gridOption;
1176
+ const results = items();
1177
+ let data = [];
1178
+ if (results instanceof Promise) {
1179
+ data = yield results.catch(err => {
1180
+ this.notifyService.notify.warning('Có lỗi xảy ra');
1181
+ console.error(err);
1182
+ return [];
1183
+ });
1184
+ }
1185
+ else {
1186
+ data = results;
1187
+ }
1188
+ if (!Array.isArray(data)) {
1189
+ this.notifyService.notify.warning('Dữ liệu không phải là một mảng');
1190
+ data = [];
1191
+ }
1192
+ __classPrivateFieldSet(this, _localItems, data.map(MapToSdTableItem));
1193
+ this.isLoading = false;
1194
+ }
1195
+ return __classPrivateFieldGet(this, _filterLocal).call(this, __classPrivateFieldGet(this, _localItems), filterReq);
1196
+ }));
1197
+ _render.set(this, (args) => __awaiter(this, void 0, void 0, function* () {
1198
+ var _a, _b, _c, _d;
1199
+ (_a = this.sdScroll) === null || _a === void 0 ? void 0 : _a.scrollTop();
1200
+ this.items = (args === null || args === void 0 ? void 0 : args.items) || [];
1201
+ this.total = (args === null || args === void 0 ? void 0 : args.total) || 0;
1202
+ yield ((_d = (_c = (_b = this.gridOption) === null || _b === void 0 ? void 0 : _b.reload) === null || _c === void 0 ? void 0 : _c.onReload) === null || _d === void 0 ? void 0 : _d.call(_c, this.items));
1203
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1204
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1205
+ }));
1206
+ this.reload = (force = true) => __awaiter(this, void 0, void 0, function* () {
1207
+ var _e, _f;
1208
+ (_f = (_e = this.gridFilter) === null || _e === void 0 ? void 0 : _e.updateFilter) === null || _f === void 0 ? void 0 : _f.call(_e);
1209
+ const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this), force);
1210
+ __classPrivateFieldGet(this, _render).call(this, data);
1211
+ });
1212
+ _exportedItems.set(this, (pageNumber = 0, pageSize = 10000) => __awaiter(this, void 0, void 0, function* () {
1213
+ var _g, _h;
1214
+ if ((_g = this.gridOption.export) === null || _g === void 0 ? void 0 : _g.items) {
1215
+ // const exportedItems = this.gridOption.export?.items(this.#filterExportInfo(pageNumber, pageSize));
1216
+ let result = (_h = this.gridOption.export) === null || _h === void 0 ? void 0 : _h.items(__classPrivateFieldGet(this, _filterExportInfo).call(this, pageNumber, pageSize));
1217
+ if (Array.isArray(result)) {
1218
+ return result;
1219
+ }
1220
+ if (isObservable(result)) {
1221
+ result = result.toPromise();
1222
+ }
1223
+ if (isObservable(result)) {
1224
+ result = result.toPromise();
1225
+ }
1226
+ return yield result;
1227
+ }
1228
+ else {
1229
+ const filterInfo = __classPrivateFieldGet(this, _filterExportInfo).call(this, pageNumber, pageSize);
1230
+ if (this.gridOption.type === 'server') {
1231
+ let result = this.gridOption.items(filterInfo);
1232
+ return yield result;
1233
+ }
1234
+ else {
1235
+ let exportedItems = [];
1236
+ if (typeof this.gridOption.items === 'function') {
1237
+ const results = this.gridOption.items();
1238
+ if (results instanceof Promise) {
1239
+ exportedItems = yield results;
1240
+ }
1241
+ else {
1242
+ exportedItems = results;
1243
+ }
1244
+ }
1245
+ else {
1246
+ exportedItems = this.gridOption.items;
1247
+ }
1248
+ return __classPrivateFieldGet(this, _filterLocal).call(this, exportedItems, filterInfo);
1249
+ }
1250
+ }
1251
+ }));
1252
+ _allColumns.set(this, () => {
1253
+ const columns = [];
1254
+ this.gridOption.columns
1255
+ .filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })
1256
+ .forEach(column => {
1257
+ var _a;
1258
+ if (column.type === 'children') {
1259
+ (_a = column.children) === null || _a === void 0 ? void 0 : _a.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); }).forEach(childColumn => {
1260
+ columns.push(childColumn);
1261
+ });
1262
+ return;
1263
+ }
1264
+ columns.push(column);
1265
+ });
1266
+ return columns;
1267
+ });
1268
+ _allExportedColumns.set(this, () => {
1269
+ var _a, _b;
1270
+ return ((_b = (_a = this.gridOption.export) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })) || [];
1271
+ });
1272
+ _onExport.set(this, (isCSV) => __awaiter(this, void 0, void 0, function* () {
1273
+ var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1274
+ try {
1275
+ let columns = __classPrivateFieldGet(this, _getExportColumns).call(this);
1276
+ const pageSize = ((_k = (_j = this.gridOption) === null || _j === void 0 ? void 0 : _j.export) === null || _k === void 0 ? void 0 : _k.maxItemsPerRequest) || 1000;
1277
+ const batch = ((_m = (_l = this.gridOption) === null || _l === void 0 ? void 0 : _l.export) === null || _m === void 0 ? void 0 : _m.batch) || 1;
1278
+ let total = this.total;
1279
+ let pageNumber = 0;
1280
+ let exportItems = [];
1281
+ this.isExporting = true;
1282
+ const items = [];
1283
+ let promises = [];
1284
+ const handleData = () => __awaiter(this, void 0, void 0, function* () {
1285
+ var _u;
1286
+ const results = yield Promise.all(promises);
1287
+ promises = [];
1288
+ exportItems = [];
1289
+ for (const result of results) {
1290
+ if ('items' in result) {
1291
+ exportItems = [...exportItems, ...result.items];
1292
+ total = result.total;
1293
+ }
1294
+ else {
1295
+ exportItems = [...exportItems, ...result];
1296
+ }
1297
+ }
1298
+ if ((_u = this.gridOption.export) === null || _u === void 0 ? void 0 : _u.mapping) {
1299
+ const results = this.gridOption.export.mapping(exportItems);
1300
+ if (results instanceof Promise) {
1301
+ exportItems = yield results;
1302
+ }
1303
+ else {
1304
+ exportItems = results;
1305
+ }
1306
+ }
1307
+ const totalPage = total / pageSize;
1308
+ const percent = Math.round(((pageNumber - 1) * 100.0) / totalPage);
1309
+ this.exportTitle = `Exporting...${percent}%`;
1310
+ const allColumns = __classPrivateFieldGet(this, _allColumns).call(this);
1311
+ const allExportedColumns = __classPrivateFieldGet(this, _allExportedColumns).call(this);
1312
+ for (const item of exportItems) {
1313
+ const obj = {};
1314
+ const handle = (exportColumn) => __awaiter(this, void 0, void 0, function* () {
1315
+ var _v, _w, _x;
1316
+ obj[exportColumn.field] = item[exportColumn.field];
1317
+ const column = allColumns.find(e => e.field === exportColumn.field);
1318
+ const exportedColumn = allExportedColumns.find(e => e.field === exportColumn.field);
1319
+ if (exportedColumn === null || exportedColumn === void 0 ? void 0 : exportedColumn.transform) {
1320
+ obj[exportedColumn.field] = exportedColumn.transform(item[exportedColumn.field], item);
1321
+ return;
1322
+ }
1323
+ if (!column) {
1324
+ return;
1325
+ }
1326
+ if (column.type === 'children') {
1327
+ column === null || column === void 0 ? void 0 : column.children.forEach(childColumn => handle(childColumn));
1328
+ return;
1329
+ }
1330
+ if (!columns.some(e => e.field === column.field)) {
1331
+ return;
1332
+ }
1333
+ if (column.transform) {
1334
+ const transform = column.transform(item[column.field], item, {
1335
+ isExport: true,
1336
+ });
1337
+ if (transform instanceof Promise) {
1338
+ obj[column.field] = yield transform;
1339
+ }
1340
+ else {
1341
+ obj[column.field] = transform;
1342
+ }
1343
+ obj[column.field] = (_v = obj[column.field]) !== null && _v !== void 0 ? _v : '';
1344
+ }
1345
+ else if (item[column.field] === undefined || item[column.field] === null || item[column.field] === '') {
1346
+ obj[column.field] = '';
1347
+ }
1348
+ else if (column.type === 'string' || column.type === 'number') {
1349
+ // Nếu cell là string hoặc number thì gán bằng chính nó
1350
+ obj[column.field] = item[column.field];
1351
+ }
1352
+ else if (column.type === 'bool') {
1353
+ // Nếu là bool thì gán bằng giá trị trueValue và falseValue (nếu có), mặc định là TRUE/FALSE
1354
+ if (item[column.field]) {
1355
+ obj[column.field] = ((_w = column.option) === null || _w === void 0 ? void 0 : _w.displayOnTrue) || 'True';
1356
+ }
1357
+ else if (obj[column.field] !== undefined && obj[column.field] !== null) {
1358
+ obj[column.field] = ((_x = column.option) === null || _x === void 0 ? void 0 : _x.displayOnFalse) || 'False';
1359
+ }
1360
+ }
1361
+ else if (column.type === 'date') {
1362
+ let date = item[column.field];
1363
+ const { transformDate } = column;
1364
+ if (transformDate) {
1365
+ date = transformDate(date, item);
1366
+ }
1367
+ // Nếu là date thì convert theo đúng format
1368
+ obj[column.field] = Date.toFormat(date, 'dd/MM/yyyy');
1369
+ }
1370
+ else if (column.type === 'datetime') {
1371
+ let date = item[column.field];
1372
+ const { transformDate } = column;
1373
+ if (transformDate) {
1374
+ date = transformDate(date, item);
1375
+ }
1376
+ // Nếu là datetime thì convert theo đúng format
1377
+ obj[column.field] = Date.toFormat(date, 'dd/MM/yyyy HH:mm');
1378
+ }
1379
+ else if (column.type === 'time') {
1380
+ let date = item[column.field];
1381
+ const { transformDate } = column;
1382
+ if (transformDate) {
1383
+ date = transformDate(date, item);
1384
+ }
1385
+ // Nếu là time thì convert theo đúng format
1386
+ obj[column.field] = Date.toFormat(date, 'HH:mm');
1387
+ }
1388
+ else if (column.type === 'values') {
1389
+ // Nếu là values thì lấy giá trị của value được chọn
1390
+ obj[column.field] = yield this.columnValuesPipe.transform(item[column.field], column);
1391
+ }
1392
+ else {
1393
+ obj[column.field] = item[column.field];
1394
+ }
1395
+ });
1396
+ // this.gridOption.columns.forEach(handle);
1397
+ for (const exportColumn of columns) {
1398
+ yield handle(exportColumn);
1399
+ }
1400
+ items.push(obj);
1401
+ }
1402
+ });
1403
+ while (pageNumber * pageSize < total) {
1404
+ promises.push(__classPrivateFieldGet(this, _exportedItems).call(this, pageNumber, pageSize));
1405
+ pageNumber++;
1406
+ if (promises.length < batch) {
1407
+ continue;
1408
+ }
1409
+ yield handleData();
1410
+ }
1411
+ if (promises.length > 0) {
1412
+ yield handleData();
1413
+ }
1414
+ if (isCSV) {
1415
+ yield this.exportService.exportCSV({
1416
+ columns,
1417
+ items,
1418
+ fileName: (_p = (_o = this.gridOption) === null || _o === void 0 ? void 0 : _o.export) === null || _p === void 0 ? void 0 : _p.fileName,
1419
+ });
1420
+ return;
1421
+ }
1422
+ const sheets = [];
1423
+ if (Array.isArray((_r = (_q = this.gridOption) === null || _q === void 0 ? void 0 : _q.export) === null || _r === void 0 ? void 0 : _r.sheets)) {
1424
+ for (const sheet of this.gridOption.export.sheets) {
1425
+ if (sheet.name && sheet.items && sheet.fields) {
1426
+ if (Array.isArray(sheet.items)) {
1427
+ sheets.push({
1428
+ name: sheet.name,
1429
+ items: sheet.items,
1430
+ fields: sheet.fields,
1431
+ });
1432
+ }
1433
+ else {
1434
+ sheets.push({
1435
+ name: sheet.name,
1436
+ items: yield sheet.items(),
1437
+ fields: sheet.fields,
1438
+ });
1439
+ }
1440
+ }
1441
+ }
1442
+ }
1443
+ yield this.exportService.export({
1444
+ columns,
1445
+ items,
1446
+ fileName: (_t = (_s = this.gridOption) === null || _s === void 0 ? void 0 : _s.export) === null || _t === void 0 ? void 0 : _t.fileName,
1447
+ sheets,
1448
+ });
1449
+ return;
1450
+ }
1451
+ finally {
1452
+ this.isExporting = false;
1453
+ this.exportTitle = `Export`;
1454
+ this.ref.detectChanges();
1455
+ }
1456
+ }));
1457
+ _getExportColumns.set(this, () => {
1458
+ var _a, _b;
1459
+ const columns = [
1460
+ ...this.gridOption.columns.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); }),
1461
+ ...(((_b = (_a = this.gridOption.export) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })) || []),
1462
+ ];
1463
+ return columns;
1464
+ });
1465
+ this.exportExcel = () => {
1466
+ __classPrivateFieldGet(this, _onExport).call(this);
1467
+ };
1468
+ this.exportCSV = () => {
1469
+ __classPrivateFieldGet(this, _onExport).call(this, true);
1470
+ };
1471
+ this.onFilterChange = () => {
1472
+ var _a, _b, _c, _d;
1473
+ (_b = (_a = this.gridFilter) === null || _a === void 0 ? void 0 : _a.updateFilter) === null || _b === void 0 ? void 0 : _b.call(_a);
1474
+ if ((_d = (_c = this.gridOption) === null || _c === void 0 ? void 0 : _c.filter) === null || _d === void 0 ? void 0 : _d.inlineColumn) {
1475
+ this.filterRegister.value.set({
1476
+ columnOperator: this.columnOperator,
1477
+ columnFilter: this.columnFilter,
1478
+ });
1479
+ }
1480
+ else {
1481
+ this.filterRegister.value.set({});
1482
+ }
1483
+ };
1484
+ this.onExpand = (rowData) => __awaiter(this, void 0, void 0, function* () {
1485
+ var _y, _z, _0, _1, _2;
1486
+ if ((_y = this.gridOption.expand) === null || _y === void 0 ? void 0 : _y.always) {
1487
+ return;
1488
+ }
1489
+ if (rowData.meta.expand.isExpanding) {
1490
+ return;
1491
+ }
1492
+ if (rowData.meta.expand.isExpanded) {
1493
+ rowData.meta.expand.isExpanded = false;
1494
+ return;
1495
+ }
1496
+ const data = (_1 = (_0 = (_z = this.gridOption) === null || _z === void 0 ? void 0 : _z.expand) === null || _0 === void 0 ? void 0 : _0.onExpand) === null || _1 === void 0 ? void 0 : _1.call(_0, rowData.current);
1497
+ if (!((_2 = this.gridOption.expand) === null || _2 === void 0 ? void 0 : _2.multiple)) {
1498
+ this.items.forEach(item => (item.meta.expand.isExpanding = item.meta.expand.isExpanded = false));
1499
+ }
1500
+ if (data instanceof Promise) {
1501
+ rowData.meta.expand.isExpanding = true;
1502
+ data
1503
+ .then(res => {
1504
+ rowData.meta.expand.data = res;
1505
+ rowData.meta.expand.isExpanded = true;
1506
+ })
1507
+ .finally(() => (rowData.meta.expand.isExpanding = false));
1508
+ }
1509
+ else {
1510
+ rowData.meta.expand.data = data;
1511
+ rowData.meta.expand.isExpanded = true;
1512
+ }
1513
+ });
1514
+ this.onSelect = (rowData) => {
1515
+ var _a, _b, _c, _d, _e, _f, _g;
1516
+ if ((_b = (_a = rowData.meta.group) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) {
1517
+ rowData.meta.group.items.forEach(e => (e.meta.selector.isSelected = rowData.meta.selector.isSelected));
1518
+ (_d = (_c = this.gridOption.selector) === null || _c === void 0 ? void 0 : _c.onSelect) === null || _d === void 0 ? void 0 : _d.call(_c, rowData.current, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1519
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1520
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1521
+ }
1522
+ else {
1523
+ if ((_e = this.gridOption.selector) === null || _e === void 0 ? void 0 : _e.single) {
1524
+ this.items.filter(e => e !== rowData).forEach(e => (e.meta.selector.isSelected = false));
1525
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1526
+ return;
1527
+ }
1528
+ (_g = (_f = this.gridOption.selector) === null || _f === void 0 ? void 0 : _f.onSelect) === null || _g === void 0 ? void 0 : _g.call(_f, rowData.current, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1529
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1530
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1531
+ }
1532
+ };
1533
+ this.onSelectAll = () => {
1534
+ var _a, _b, _c;
1535
+ (_a = this.items) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1536
+ var _a, _b, _c, _d;
1537
+ if (e.meta.selector.selectable && (!((_c = (_b = (_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.selector) === null || _b === void 0 ? void 0 : _b.actions) === null || _c === void 0 ? void 0 : _c.length) || ((_d = e.meta.selector.actions) === null || _d === void 0 ? void 0 : _d.length))) {
1538
+ e.meta.selector.isSelected = this.isSelectAll;
1539
+ }
1540
+ });
1541
+ (_c = (_b = this.gridOption.selector) === null || _b === void 0 ? void 0 : _b.onSelectAll) === null || _c === void 0 ? void 0 : _c.call(_b, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1542
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1543
+ };
1544
+ this.onClearSelection = (items) => {
1545
+ items = items || this.items;
1546
+ this.isSelectAll = false;
1547
+ items === null || items === void 0 ? void 0 : items.forEach(e => (e.meta.selector.isSelected = false));
1548
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1549
+ };
1550
+ _updateSelectedItems.set(this, () => {
1551
+ this.selectedItems = this.items.filter(item => item.meta.selector.isSelected).map(item => item.current);
1552
+ this.ref.detectChanges();
1553
+ });
1554
+ this.clearFilter = () => {
1555
+ this.filterRegister.value.remove();
1556
+ };
1557
+ this.setFilter = (args) => {
1558
+ var _a, _b;
1559
+ const { columnFilter, externalFilter, filterDef } = args || {};
1560
+ if (((_b = (_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.inlineColumn) && columnFilter) {
1561
+ this.columnFilter = columnFilter;
1562
+ }
1563
+ this.filterRegister.value.set({
1564
+ columnFilter,
1565
+ externalFilter,
1566
+ filterDef,
1567
+ });
1568
+ };
1569
+ this.detectChanges = () => this.ref.detectChanges();
1570
+ }
1571
+ set _gridFilter(gridFilter) {
1572
+ if (gridFilter && this.gridFilter !== gridFilter) {
1573
+ this.gridFilter = gridFilter;
1574
+ // this.#subscription.add(gridFilter.filterChange.pipe(
1575
+ // filter(reload => reload),
1576
+ // debounceTime(500),
1577
+ // map(() => {
1578
+ // this.#paginator.pageIndex = 0;
1579
+ // this.#reload.next({
1580
+ // force: false,
1581
+ // source: 'FILTER'
1582
+ // });
1583
+ // }),
1584
+ // ).subscribe());
1585
+ }
1586
+ }
1587
+ set option(option) {
1588
+ if (option) {
1589
+ option = __classPrivateFieldGet(this, _initConfiguration$1).call(this, option);
1590
+ this.gridOption = option;
1591
+ __classPrivateFieldSet(this, _loadCompleted, false);
1592
+ const configuration = this.gridConfigurationService.init(this.key, this.gridOption);
1593
+ this.gridConfigurationObserver = configuration.observer;
1594
+ configuration.load();
1595
+ __classPrivateFieldGet(this, _optionChanges).next(this.gridOption);
1596
+ }
1597
+ }
1598
+ set paginator(paginator) {
1599
+ if (paginator && __classPrivateFieldGet(this, _paginator) !== paginator) {
1600
+ __classPrivateFieldSet(this, _paginator, paginator);
1601
+ __classPrivateFieldGet(this, _subscription$1).add(paginator.page
1602
+ .pipe(map(() => {
1603
+ __classPrivateFieldGet(this, _reload).next({
1604
+ force: false,
1605
+ });
1606
+ }))
1607
+ .subscribe());
1608
+ }
1609
+ }
1610
+ set sort(sort) {
1611
+ if (sort && __classPrivateFieldGet(this, _sort) !== sort) {
1612
+ __classPrivateFieldSet(this, _sort, sort);
1613
+ __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange
1614
+ .pipe(map(() => {
1615
+ __classPrivateFieldGet(this, _reload).next({
1616
+ force: false,
1617
+ });
1618
+ }))
1619
+ .subscribe());
1620
+ }
1621
+ }
1622
+ ngOnInit() {
1623
+ __classPrivateFieldGet(this, _initCellDef).call(this);
1624
+ }
1625
+ ngAfterViewInit() {
1626
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _reload).pipe(debounceTime(200), switchMap((data) => __awaiter(this, void 0, void 0, function* () {
1627
+ const filterInfo = __classPrivateFieldGet(this, _getFilter).call(this);
1628
+ const result = yield __classPrivateFieldGet(this, _load$1).call(this, filterInfo, !__classPrivateFieldGet(this, _loadCompleted) || data.force);
1629
+ __classPrivateFieldSet(this, _loadCompleted, true);
1630
+ return result;
1631
+ })))
1632
+ .subscribe(__classPrivateFieldGet(this, _render)));
1633
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdCellDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initCellDef)));
1634
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdFooterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFooterDef)));
1635
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdFilterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFilterDef)));
1636
+ __classPrivateFieldGet(this, _subscription$1).add(combineLatest([
1637
+ __classPrivateFieldGet(this, _optionChanges).pipe(startWith(this.gridOption)),
1638
+ this.sdFilterDefs.changes.pipe(startWith(this.filterDefs)),
1639
+ ]).subscribe(() => {
1640
+ __classPrivateFieldGet(this, _loadFilterRegister).call(this);
1641
+ }));
1642
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _optionChanges).subscribe(() => {
1643
+ if (this.filterRegister) {
1644
+ __classPrivateFieldGet(this, _reload).next({
1645
+ force: true,
1646
+ });
1647
+ }
1648
+ }));
1649
+ this.ref.detectChanges();
1650
+ }
1651
+ ngOnDestroy() {
1652
+ __classPrivateFieldGet(this, _subscription$1).unsubscribe();
1653
+ }
1654
+ get gridItems() {
1655
+ return this.items.map(item => item.current);
1656
+ }
1657
+ }
1658
+ _gridId = new WeakMap(), _optionChanges = new WeakMap(), _localItems = new WeakMap(), _paginator = new WeakMap(), _sort = new WeakMap(), _subscription$1 = new WeakMap(), _reload = new WeakMap(), _loadCompleted = new WeakMap(), _initCellDef = new WeakMap(), _initFilterDef = new WeakMap(), _initFooterDef = new WeakMap(), _filterExportInfo = new WeakMap(), _initConfiguration$1 = new WeakMap(), _loadFilterRegister = new WeakMap(), _filterLocal = new WeakMap(), _getFilter = new WeakMap(), _load$1 = new WeakMap(), _render = new WeakMap(), _exportedItems = new WeakMap(), _allColumns = new WeakMap(), _allExportedColumns = new WeakMap(), _onExport = new WeakMap(), _getExportColumns = new WeakMap(), _updateSelectedItems = new WeakMap();
1659
+ SdTable.decorators = [
1660
+ { type: Component, args: [{
1661
+ selector: 'sd-table',
1662
+ template: "<ng-container *ngIf=\"gridConfigurationObserver | async as gridConfiguration\">\r\n <ng-container *ngIf=\"gridConfiguration | sdGridConfigurationResult : gridOption : sdSubInformation as configuration\">\r\n <sd-grid-filter\r\n *ngIf=\"!gridOption.filter?.disabled && filterRegister\"\r\n [filterRegister]=\"filterRegister\"\r\n [filter]=\"gridOption?.filter\"\r\n [columns]=\"configuration.firstColumns\"\r\n [externalFilters]=\"gridOption?.filter?.externalFilters\"\r\n [filterDefs]=\"filterDefs\"\r\n #gridFilter>\r\n </sd-grid-filter>\r\n <ng-container *ngIf=\"items | sdGroup : gridOption; $implicit as groupedItems\">\r\n <div class=\"c-container\">\r\n <div class=\"c-loading\" *ngIf=\"isLoading\">\r\n <mat-spinner *ngIf=\"isLoading\"></mat-spinner>\r\n </div>\r\n <ng-container>\r\n <div\r\n class=\"c-table\"\r\n sdScroll\r\n [ngStyle]=\"{\r\n 'max-height': gridOption?.style?.maxHeight,\r\n 'min-height': gridOption?.style?.minHeight\r\n }\">\r\n <table\r\n *ngIf=\"items?.length; else elseEmpty\"\r\n mat-table\r\n [dataSource]=\"groupedItems\"\r\n matSort\r\n [matSortDisabled]=\"!gridOption.sort?.enable\"\r\n multiTemplateDataRows>\r\n <ng-container matColumnDef=\"sdSubInformation\" sticky>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"configuration.displayedColumns.length\">\r\n <ng-container *ngIf=\"sdSubInformation?.templateRef\">\r\n <ng-container *ngIf=\"gridOption?.expand?.always; else useExpandCollapse\">\r\n <ng-container *ngTemplateOutlet=\"sdSubInformation.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n <ng-template #useExpandCollapse>\r\n <div [@detailExpand]=\"item.isExpanded ? 'expanded' : 'collapsed'\">\r\n <ng-container *ngIf=\"item.isExpanded\">\r\n <ng-container *ngTemplateOutlet=\"sdSubInformation.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-template>\r\n </ng-container>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSubInformationAction\" stickyEnd>\r\n <th\r\n class=\"p-0\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 1px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td mat-cell *matCellDef=\"let element\">\r\n <button\r\n *ngIf=\"!element.isExpanding && !gridOption?.expand?.always\"\r\n mat-icon-button\r\n aria-label=\"Expand & Collapse\"\r\n (click)=\"onExpand(element)\">\r\n <mat-icon *ngIf=\"!element.isExpanded\">expand_more</mat-icon>\r\n <mat-icon *ngIf=\"element.isExpanded\">expand_less</mat-icon>\r\n </button>\r\n <div *ngIf=\"element.isExpanding\" class=\"lds-ring\">\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n </div>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSelection\" sticky>\r\n <th\r\n class=\"text-center px-15\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\">\r\n <ng-container *ngIf=\"items | selectionVisibleSelectAll : gridOption?.selector | async\">\r\n <mat-checkbox\r\n *ngIf=\"!gridOption.selector?.single\"\r\n class=\"c-selection\"\r\n color=\"primary\"\r\n [(ngModel)]=\"isSelectAll\"\r\n (change)=\"onSelectAll()\">\r\n </mat-checkbox>\r\n </ng-container>\r\n </th>\r\n <td class=\"text-center px-15\" mat-cell *matCellDef=\"let item\" style=\"min-width: 50px; max-width: 50px\">\r\n <ng-container *ngIf=\"item | selectionVisible : gridOption?.selector\">\r\n <mat-checkbox\r\n class=\"c-selection\"\r\n color=\"primary\"\r\n [(ngModel)]=\"item.isSelected\"\r\n (change)=\"onSelect(item)\"\r\n [disabled]=\"selectedItems | selectionDisable : item : gridOption?.selector\">\r\n </mat-checkbox>\r\n </ng-container>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdCommand\">\r\n <th\r\n class=\"px-8 py-8\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"px-8\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-command [commands]=\"gridOption.commands\" [item]=\"item\"></sd-desktop-command>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdGroup\">\r\n <th mat-header-cell *matHeaderCellDef class=\"px-8 py-8\" [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"!item?.sdGroup ? 1 : configuration.displayedColumns.length\">\r\n <div [innerHtml]=\"item?.sdGroup?.htmlTemplate | safeHtml\"></div>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.firstColumns; let i = index\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n cdkDrag\r\n class=\"px-8 py-8 c-th\"\r\n [ngStyle]=\"{ 'min-width': configuration.firstColumns[i].width }\"\r\n [attr.rowspan]=\"configuration.multipleHeader && column.type !== 'children-col' ? 2 : 1\"\r\n [attr.colspan]=\"column.type === 'children-col' ? column.children?.length : 1\">\r\n <div>\r\n <div\r\n aria-hidden=\"false\"\r\n role=\"presentation\"\r\n mat-sort-header\r\n [disabled]=\"!column.sortable || column.type === 'children-col'\"\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"configuration.firstColumns[i].titleHtml || configuration.firstColumns[i].title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn && columnOperator\"\r\n [value]=\"columnFilter[column.field]\"\r\n [(inlineOperator)]=\"columnOperator[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\">\r\n </sd-column-inline-filter>\r\n </div>\r\n </th>\r\n <td class=\"c-td px-0\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-cell\r\n class=\"d-block px-8\"\r\n *ngIf=\"!item?.sdGroup\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [value]=\"item[column.field]\"\r\n [column]=\"column\"\r\n [item]=\"item\"\r\n [idx]=\"i\"\r\n [cellDef]=\"cellDef\"\r\n [gridOption]=\"gridOption\">\r\n </sd-desktop-cell>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef>\r\n <ng-container *ngIf=\"footerDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"footerDef[column.field].templateRef; context: { items: items, column: column }\">\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n <ng-container *ngFor=\"let column of configuration.secondColumns; let i = index\" [matColumnDef]=\"column.field\">\r\n <th mat-header-cell *matHeaderCellDef mat-sort-header class=\"c-th px-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn && columnOperator\"\r\n [value]=\"columnFilter[column.field]\"\r\n [(inlineOperator)]=\"columnOperator[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\">\r\n </sd-column-inline-filter>\r\n </div>\r\n </th>\r\n <td class=\"c-td px-0\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-cell\r\n class=\"d-block px-8\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [value]=\"item[column.field]\"\r\n [column]=\"column\"\r\n [item]=\"item\"\r\n [idx]=\"i\"\r\n [cellDef]=\"cellDef\"\r\n [gridOption]=\"gridOption\">\r\n </sd-desktop-cell>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef>\r\n <ng-container *ngIf=\"footerDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"footerDef[column.field].templateRef; context: { items: items, column: column }\">\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n <tr class=\"c-first-header\" mat-header-row *matHeaderRowDef=\"configuration.firstHeaders; sticky: true\"></tr>\r\n <ng-container *ngIf=\"configuration.secondHeaders?.length\">\r\n <tr class=\"c-second-header\" mat-header-row *matHeaderRowDef=\"configuration.secondHeaders; sticky: true\"></tr>\r\n </ng-container>\r\n <tr\r\n mat-row\r\n *matRowDef=\"let row; columns: configuration.displayedColumns\"\r\n matRipple\r\n class=\"c-row\"\r\n [class.selected]=\"row.isSelected\"></tr>\r\n\r\n <tr mat-row *matRowDef=\"let row; columns: ['sdSubInformation']\" class=\"c-detail-row\"></tr>\r\n <ng-container *ngIf=\"hasFooter && configuration.displayedFooters?.length\">\r\n <tr mat-footer-row *matFooterRowDef=\"configuration.displayedFooters; sticky: true\"></tr>\r\n </ng-container>\r\n </table>\r\n <ng-template #elseEmpty>\r\n <table mat-table [dataSource]=\"[{}]\">\r\n <ng-container matColumnDef=\"sdSelection\" sticky>\r\n <th\r\n class=\"px-15\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdCommand\">\r\n <th\r\n class=\"px-8\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSubInformationAction\">\r\n <th\r\n class=\"p-0\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 1px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdEmpty\">\r\n <td class=\"c-empty\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"configuration.displayedColumns.length\">\r\n <ng-container *ngIf=\"sdEmptyData?.templateRef; else sdEmptyDataNoRef\">\r\n <ng-container *ngTemplateOutlet=\"sdEmptyData.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n <ng-template #sdEmptyDataNoRef>\r\n <mat-icon fontSet=\"material-icons-outlined\">leaderboard</mat-icon>\r\n </ng-template>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdGroup\">\r\n <th mat-header-cell *matHeaderCellDef class=\"px-8 py-8\" [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\"></td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.columns\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th mat-header-cell *matHeaderCellDef class=\"c-th px-8 py-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n </th>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.firstColumns; let i = index\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n class=\"c-th px-8 py-8\"\r\n [ngStyle]=\"{ 'min-width': configuration.firstColumns[i].width }\"\r\n [attr.rowspan]=\"configuration.multipleHeader && column.type !== 'children-col' ? 2 : 1\"\r\n [attr.colspan]=\"column.type === 'children-col' ? column.children?.length : 1\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"configuration.firstColumns[i].titleHtml || configuration.firstColumns[i].title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn && columnOperator\"\r\n [value]=\"columnFilter[column.field]\"\r\n [(inlineOperator)]=\"columnOperator[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\">\r\n </sd-column-inline-filter>\r\n </div>\r\n </th>\r\n </ng-container>\r\n <ng-container *ngFor=\"let column of configuration.secondColumns\" [matColumnDef]=\"column.field\">\r\n <th mat-header-cell *matHeaderCellDef class=\"c-th px-8 py-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn\"\r\n [value]=\"columnFilter[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\"></sd-column-inline-filter>\r\n </div>\r\n </th>\r\n </ng-container>\r\n <tr class=\"c-first-header\" mat-header-row *matHeaderRowDef=\"configuration.firstHeaders; sticky: true\"></tr>\r\n <tr class=\"c-second-header\" mat-header-row *matHeaderRowDef=\"configuration.secondHeaders; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['sdEmpty']\"></tr>\r\n </table>\r\n </ng-template>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-paginator\">\r\n <div class=\"c-action\">\r\n <sd-button\r\n *ngIf=\"gridFilter && !gridOption.filter?.inlineColumn\"\r\n class=\"mr-10\"\r\n [title]=\"'Filter' | sdTranslate\"\r\n icon=\"filter_alt\"\r\n size=\"sm\"\r\n (action)=\"gridFilter.open()\"\r\n type=\"link\">\r\n </sd-button>\r\n <sd-button\r\n *ngIf=\"gridOption.reload?.visible\"\r\n class=\"mr-10\"\r\n [title]=\"'Reload' | sdTranslate\"\r\n icon=\"refresh\"\r\n size=\"sm\"\r\n (action)=\"reload()\"\r\n [disabled]=\"!items?.length\"\r\n type=\"link\">\r\n </sd-button>\r\n <ng-container *ngIf=\"gridOption.export?.visible && items?.length\">\r\n <ng-container *ngIf=\"isExporting; else unExporting\">\r\n <sd-button class=\"mr-10\" [loading]=\"isExporting\" [title]=\"exportTitle | sdTranslate\" icon=\"get_app\" size=\"sm\" type=\"link\">\r\n </sd-button>\r\n </ng-container>\r\n <ng-template #unExporting>\r\n <sd-button\r\n class=\"mr-10\"\r\n [title]=\"exportTitle | sdTranslate\"\r\n icon=\"get_app\"\r\n size=\"sm\"\r\n [matMenuTriggerFor]=\"menu\"\r\n type=\"link\">\r\n </sd-button>\r\n </ng-template>\r\n\r\n <mat-menu #menu=\"matMenu\">\r\n <button mat-menu-item (click)=\"exportExcel()\" type=\"button\">\r\n <mat-icon fontSet=\"material-icons-outlined\">file_download</mat-icon>\r\n <span> Xu\u1EA5t excel</span>\r\n </button>\r\n <button mat-menu-item (click)=\"exportCSV()\" type=\"button\">\r\n <mat-icon fontSet=\"material-icons-outlined\">file_download</mat-icon>\r\n <span> Xu\u1EA5t CSV</span>\r\n </button>\r\n </mat-menu>\r\n </ng-container>\r\n <sd-button\r\n *ngIf=\"gridOption.config?.visible\"\r\n class=\"mr-10\"\r\n [title]=\"'Configure' | sdTranslate\"\r\n icon=\"settings\"\r\n size=\"sm\"\r\n (action)=\"popupGridConfiguration.open()\"\r\n type=\"link\">\r\n </sd-button>\r\n </div>\r\n <mat-paginator\r\n [class.d-none]=\"gridOption.paginate?.hidden\"\r\n [length]=\"total\"\r\n [pageSize]=\"gridOption.paginate?.pageSize\"\r\n [pageSizeOptions]=\"gridOption.paginate?.pages\"\r\n [showFirstLastButtons]=\"gridOption.paginate?.showFirstLastButtons\"></mat-paginator>\r\n </div>\r\n </div>\r\n <sd-grid-quick-action [gridOption]=\"gridOption\" [selectedItems]=\"selectedItems\" (clear)=\"onClearSelection(groupedItems)\">\r\n </sd-grid-quick-action>\r\n <sd-popup-grid-configuration [gridOption]=\"gridOption\" [key]=\"key\" #popupGridConfiguration> </sd-popup-grid-configuration>\r\n </ng-container>\r\n </ng-container>\r\n</ng-container>\r\n",
1663
+ changeDetection: ChangeDetectionStrategy.OnPush,
1664
+ animations: [
1665
+ trigger('detailExpand', [
1666
+ state('collapsed', style({ height: '0', minHeight: '0', visibility: 'hidden' })),
1667
+ state('expanded', style({ height: '*', visibility: 'visible' })),
1668
+ transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
1669
+ ]),
1670
+ ],
1671
+ styles: [".text-black400{color:#757575}:host{display:flex;flex-direction:column;height:100%;overflow:auto}:host .c-container{display:flex;flex:1;flex-direction:column;min-height:200px;position:relative}:host .c-container .c-table{flex:1;min-height:300px;position:relative}:host .c-container .c-table table{border-collapse:separate;width:100%}:host .c-container .c-table table tr.c-first-header.mat-header-row,:host .c-container .c-table table tr.c-second-header.mat-header-row{height:40px}:host .c-container .c-table table tr.c-detail-row{height:0}:host .c-container .c-table table tr.c-row.activated{background-color:#e5ecff}:host .c-container .c-table table tr.c-row.selected{background-color:#eef2ff}:host .c-container .c-table table tr.c-row:not(.selected):not(.activated):hover{background-color:#f5f5f5}:host .c-container .c-table table tr.c-row td{border-bottom-width:0}:host .c-container .c-table table tr.c-row.c-expandable{cursor:pointer}:host .c-container .c-table table tr.c-row.c-expandable:hover{background:#f5f5f5}:host .c-container .c-table table th.mat-header-cell{background-color:#f2f3f4;border-bottom:0!important}:host .c-container .c-table table td.mat-cell,:host .c-container .c-table table td.mat-footer-cell,:host .c-container .c-table table th.mat-header-cell{border-bottom-color:#f2f2f2!important}:host .c-container .c-table .c-th{color:#212121;font-size:14px;font-weight:500;line-height:20px;vertical-align:middle}:host .c-container .c-table .c-td:first{padding-left:10px}:host .c-container .c-loading{align-items:center;background:rgba(0,0,0,.15);bottom:56px;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0;z-index:2}:host .c-container .c-paginator{align-items:center;background-color:#fff;display:flex;flex-direction:row;justify-content:space-between}:host .c-container .c-paginator .c-action{padding:5px}:host .c-container .c-empty{background-color:#fff;border:none!important;text-align:center}:host .c-container .c-empty mat-icon{font-size:150px;height:auto;margin-bottom:30px;margin-top:30px;opacity:.2;width:auto}:host button.c-btn-add{background-color:#fff;box-shadow:0 2px 4px rgba(47,49,54,.16)}:host mat-icon.c-icon{color:rgba(0,0,0,.54)!important}:host mat-icon.c-icon-add{color:#2962ff!important}:host .lds-ring{display:inline-block;height:40px;position:relative;width:40px}:host .lds-ring div{-webkit-animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border:4px solid transparent;border-radius:50%;border-top-color:#cef;box-sizing:border-box;display:block;height:32px;margin:4px;position:absolute;width:32px}:host .lds-ring div:first-child{-webkit-animation-delay:-.45s;animation-delay:-.45s}:host .lds-ring div:nth-child(2){-webkit-animation-delay:-.3s;animation-delay:-.3s}:host .lds-ring div:nth-child(3){-webkit-animation-delay:-.15s;animation-delay:-.15s}@-webkit-keyframes lds-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes lds-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}:host ::ng-deep .mat-sort-header-content{display:block;text-align:left;width:100%}:host ::ng-deep .mat-select-arrow{color:#a6a6a6}:host ::ng-deep .mat-sort-header-disabled{background-image:none!important;cursor:default!important;padding-right:0!important}:host ::ng-deep .mat-sort-header-container{align-items:start!important}:host ::ng-deep .mat-sort-header-arrow{margin-top:4px!important}:host ::ng-deep .mat-sort-header{cursor:pointer}:host ::ng-deep .mat-sort-header[aria-sort]{background-position:center right 0;background-repeat:no-repeat;background-size:16px 16px;cursor:pointer;padding-right:24px}:host ::ng-deep .mat-sort-header[aria-sort=none]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z'/%3E%3C/svg%3E\")}:host ::ng-deep .mat-sort-header[aria-sort=ascending]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z'/%3E%3C/svg%3E\")}:host ::ng-deep .mat-sort-header[aria-sort=descending]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z'/%3E%3C/svg%3E\")}"]
1672
+ },] }
1673
+ ];
1674
+ SdTable.ctorParameters = () => [
1675
+ { type: ChangeDetectorRef },
1676
+ { type: undefined, decorators: [{ type: Inject, args: [TABLE_CONFIG,] }, { type: Optional }] },
1677
+ { type: SdTableConfigurationService },
1678
+ { type: SdExportService },
1679
+ { type: SdNotifyService },
1680
+ { type: SdColumnValuesPipe },
1681
+ { type: SdTableFilterService }
1682
+ ];
1683
+ SdTable.propDecorators = {
1684
+ sdScroll: [{ type: ViewChild, args: [SdScrollDirective,] }],
1685
+ quickAction: [{ type: ViewChild, args: [SdQuickAction,] }],
1686
+ _gridFilter: [{ type: ViewChild, args: [SdGridFilter,] }],
1687
+ option: [{ type: Input }],
1688
+ paginator: [{ type: ViewChild, args: [MatPaginator,] }],
1689
+ sort: [{ type: ViewChild, args: [MatSort,] }],
1690
+ sdSubInformation: [{ type: ContentChild, args: [SdMaterialSubInformationDefDirective,] }],
1691
+ sdEmptyData: [{ type: ContentChild, args: [SdMaterialEmptyDataDefDirective,] }],
1692
+ sdCellDefs: [{ type: ContentChildren, args: [SdMaterialCellDefDirective,] }],
1693
+ sdFooterDefs: [{ type: ContentChildren, args: [SdMaterialFooterDefDirective,] }],
1694
+ sdFilterDefs: [{ type: ContentChildren, args: [SdMaterialFilterDefDirective,] }]
1695
+ };
1696
+
1697
+ class SdCommandFilterPipe {
1698
+ transform(item, commands) {
1699
+ return __awaiter(this, void 0, void 0, function* () {
1700
+ const results = [];
1701
+ if (!commands) {
1702
+ return results;
1703
+ }
1704
+ for (const command of commands) {
1705
+ let flag = false;
1706
+ const { hidden } = command;
1707
+ if (hidden === undefined) {
1708
+ flag = true;
1709
+ }
1710
+ else if (typeof (hidden) === 'boolean') {
1711
+ if (!hidden) {
1712
+ flag = true;
1713
+ }
1714
+ }
1715
+ else {
1716
+ const isHidden = hidden(item);
1717
+ if (isHidden instanceof Promise) {
1718
+ if (!(yield isHidden)) {
1719
+ flag = true;
1720
+ }
1721
+ }
1722
+ else {
1723
+ if (!isHidden) {
1724
+ flag = true;
1725
+ }
1726
+ }
1727
+ }
1728
+ if (flag) {
1729
+ if ('children' in command) {
1730
+ const children = [];
1731
+ for (const childCommand of command.children) {
1732
+ const { hidden } = childCommand;
1733
+ if (hidden === undefined) {
1734
+ children.push(childCommand);
1735
+ }
1736
+ else if (typeof (hidden) === 'boolean') {
1737
+ if (!hidden) {
1738
+ children.push(childCommand);
1739
+ }
1740
+ }
1741
+ else {
1742
+ const isHidden = hidden(item);
1743
+ if (isHidden instanceof Promise) {
1744
+ if (!(yield isHidden)) {
1745
+ children.push(childCommand);
1746
+ }
1747
+ }
1748
+ else {
1749
+ if (!isHidden) {
1750
+ children.push(childCommand);
1751
+ }
1752
+ }
1753
+ }
1754
+ }
1755
+ if (children.length > 0) {
1756
+ results.push(Object.assign(Object.assign({}, command), { children }));
1757
+ }
1758
+ }
1759
+ else {
1760
+ results.push(command);
1761
+ }
1762
+ }
1763
+ }
1764
+ return results;
1765
+ });
1766
+ }
1767
+ }
1768
+ SdCommandFilterPipe.decorators = [
1769
+ { type: Pipe, args: [{
1770
+ name: 'commandFilter'
1771
+ },] }
1772
+ ];
1773
+
1774
+ class SdCommandDisablePipe {
1775
+ transform(item, command) {
1776
+ if (!(command === null || command === void 0 ? void 0 : command.disabled)) {
1777
+ return false;
1778
+ }
1779
+ if (typeof (command.disabled) === 'boolean') {
1780
+ return command.disabled;
1781
+ }
1782
+ return command.disabled(item);
1783
+ }
1784
+ }
1785
+ SdCommandDisablePipe.decorators = [
1786
+ { type: Pipe, args: [{
1787
+ name: 'commandDisable'
1788
+ },] }
1789
+ ];
1790
+
1791
+ class SdCommandIconPipe {
1792
+ transform(command, item) {
1793
+ if (!(command === null || command === void 0 ? void 0 : command.icon)) {
1794
+ return '';
1795
+ }
1796
+ if (typeof (command.icon) === 'string') {
1797
+ return command.icon;
1798
+ }
1799
+ return command.icon(item);
1800
+ }
1801
+ }
1802
+ SdCommandIconPipe.decorators = [
1803
+ { type: Pipe, args: [{
1804
+ name: 'commandIcon'
1805
+ },] }
1806
+ ];
1807
+
1808
+ class SdCommandTitlePipe {
1809
+ transform(command, item) {
1810
+ if (!(command === null || command === void 0 ? void 0 : command.title)) {
1811
+ return '';
1812
+ }
1813
+ if (typeof (command.title) === 'string') {
1814
+ return command.title;
1815
+ }
1816
+ return command.title(item);
1817
+ }
1818
+ }
1819
+ SdCommandTitlePipe.decorators = [
1820
+ { type: Pipe, args: [{
1821
+ name: 'commandTitle'
1822
+ },] }
1823
+ ];
1824
+
1825
+ class SdColumnHtmlTemplatePipe {
1826
+ constructor(deviceService) {
1827
+ this.isMobileOrTablet = false;
1828
+ this.isMobileOrTablet = !deviceService.isDesktop();
1829
+ }
1830
+ transform(value, rowData, column) {
1831
+ if (typeof (column === null || column === void 0 ? void 0 : column.htmlTemplate) !== 'function') {
1832
+ return value;
1833
+ }
1834
+ return column === null || column === void 0 ? void 0 : column.htmlTemplate(value, rowData, this.isMobileOrTablet);
1835
+ }
1836
+ }
1837
+ SdColumnHtmlTemplatePipe.decorators = [
1838
+ { type: Pipe, args: [{
1839
+ name: 'columnHtmlTemplate'
1840
+ },] }
1841
+ ];
1842
+ SdColumnHtmlTemplatePipe.ctorParameters = () => [
1843
+ { type: DeviceDetectorService }
1844
+ ];
1845
+
1846
+ class SdDesktopCellView {
1847
+ constructor() { }
1848
+ }
1849
+ SdDesktopCellView.decorators = [
1850
+ { type: Component, args: [{
1851
+ selector: 'sd-desktop-cell-view',
1852
+ template: "<ng-container *ngIf=\"item.current[column.field] | cellView : item : column : gridOption | async as view\">\r\n <ng-container *ngIf=\"view.display.hasHtml; else useValue\">\r\n <div\r\n *ngIf=\"view.click\"\r\n (click)=\"view.click()\"\r\n class=\"text-break cursor-pointer\"\r\n [matTooltip]=\"view.tooltip\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [innerHTML]=\"view.display.html | safeHtml\"></div>\r\n <div\r\n *ngIf=\"!view.click\"\r\n class=\"text-break\"\r\n [matTooltip]=\"view.tooltip\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [innerHTML]=\"view.display.html | safeHtml\"></div>\r\n </ng-container>\r\n <ng-template #useValue>\r\n <ng-container *ngIf=\"!!view.badge; else noBadge\">\r\n <sd-badge\r\n *ngIf=\"view.display.value\"\r\n [type]=\"view.badge.type\"\r\n [title]=\"view.display.value\"\r\n [color]=\"view.badge.color\"\r\n [icon]=\"view.badge.icon\"\r\n [tooltip]=\"view.tooltip\"\r\n (sdClick)=\"!!view.click && view.click()\"></sd-badge>\r\n </ng-container>\r\n <ng-template #noBadge>\r\n <div\r\n class=\"text-break\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [matTooltip]=\"view.tooltip\">\r\n <a *ngIf=\"!!view.click\" href=\"javascript:;\" (click)=\"view.click()\">{{ view.display.value }}</a>\r\n <ng-container *ngIf=\"!view.click\">{{ view.display.value }} </ng-container>\r\n </div>\r\n </ng-template>\r\n </ng-template>\r\n</ng-container>\r\n",
1853
+ changeDetection: ChangeDetectionStrategy.OnPush,
1854
+ styles: [".text-black400{color:#757575}.c-color-success{color:#4caf50}.c-color-danger{color:#f82c13}.c-image{-o-object-fit:contain;margin:5px 0;object-fit:contain}.c-img{font-size:30px;opacity:.5}.c-img.pointer:hover{opacity:.9}"]
1855
+ },] }
1856
+ ];
1857
+ SdDesktopCellView.ctorParameters = () => [];
1858
+ SdDesktopCellView.propDecorators = {
1859
+ sdId: [{ type: Input }],
1860
+ key: [{ type: Input }],
1861
+ column: [{ type: Input }],
1862
+ item: [{ type: Input }],
1863
+ gridOption: [{ type: Input }]
1864
+ };
1865
+
1866
+ class SdColumnTransformPipe {
1867
+ constructor(columnValuesPipe) {
1868
+ this.columnValuesPipe = columnValuesPipe;
1869
+ }
1870
+ transform(value, rowData, column, key) {
1871
+ var _a, _b;
1872
+ return __awaiter(this, void 0, void 0, function* () {
1873
+ if (column === null || column === void 0 ? void 0 : column.transform) {
1874
+ return column.transform(value, rowData);
1875
+ }
1876
+ if (column.type === 'values') {
1877
+ return yield this.columnValuesPipe.transform(value, column);
1878
+ }
1879
+ if (column.type === 'number' && Number.isNumber(value)) {
1880
+ return Number.toVNCurrency(value); // this.decimalPipe.transform(value, '1.0-2');
1881
+ }
1882
+ if (column.type === 'bool') {
1883
+ return value === true ? (((_a = column.option) === null || _a === void 0 ? void 0 : _a.displayOnTrue) || 'True') : (((_b = column.option) === null || _b === void 0 ? void 0 : _b.displayOnFalse) || 'False');
1884
+ }
1885
+ return value;
1886
+ });
1887
+ }
1888
+ }
1889
+ SdColumnTransformPipe.decorators = [
1890
+ { type: Pipe, args: [{
1891
+ name: 'columnTransform'
1892
+ },] }
1893
+ ];
1894
+ SdColumnTransformPipe.ctorParameters = () => [
1895
+ { type: SdColumnValuesPipe }
1896
+ ];
1897
+
1898
+ class SdFilterExternalPipe {
1899
+ transform(externalFilters, field) {
1900
+ const results = [];
1901
+ if (!externalFilters) {
1902
+ return results;
1903
+ }
1904
+ for (const filter of externalFilters) {
1905
+ results.push(filter);
1906
+ }
1907
+ return results.filter(e => !field || e.field === field);
1908
+ }
1909
+ }
1910
+ SdFilterExternalPipe.decorators = [
1911
+ { type: Pipe, args: [{
1912
+ name: 'sdFilterExternal'
1913
+ },] }
1914
+ ];
1915
+
1916
+ class SdFilterColumnPipe {
1917
+ transform(columns, field) {
1918
+ var _a, _b;
1919
+ const results = [];
1920
+ if (!columns) {
1921
+ return results;
1922
+ }
1923
+ for (const column of columns) {
1924
+ if (column.type === 'children') {
1925
+ for (const columnChildren of column === null || column === void 0 ? void 0 : column.children) {
1926
+ if (!((_a = columnChildren.filter) === null || _a === void 0 ? void 0 : _a.disabled)) {
1927
+ results.push(columnChildren);
1928
+ }
1929
+ }
1930
+ continue;
1931
+ }
1932
+ if (!((_b = column.filter) === null || _b === void 0 ? void 0 : _b.disabled)) {
1933
+ results.push(column);
1934
+ }
1935
+ }
1936
+ return results.filter(e => !field || e.field === field);
1937
+ }
1938
+ }
1939
+ SdFilterColumnPipe.decorators = [
1940
+ { type: Pipe, args: [{
1941
+ name: 'sdFilterColumn'
1942
+ },] }
1943
+ ];
1944
+
1945
+ var _isMobileOrTablet;
1946
+ class SdColumnChildrenFilterPipe {
1947
+ constructor(deviceService) {
1948
+ _isMobileOrTablet.set(this, false);
1949
+ __classPrivateFieldSet(this, _isMobileOrTablet, !deviceService.isDesktop());
1950
+ }
1951
+ transform(columns, item) {
1952
+ return columns.filter(column => {
1953
+ var _a, _b;
1954
+ const value = item === null || item === void 0 ? void 0 : item[column.field];
1955
+ const transformValue = (_a = column.transform) === null || _a === void 0 ? void 0 : _a.call(column, item[column.field], item);
1956
+ const templateValue = (_b = column.htmlTemplate) === null || _b === void 0 ? void 0 : _b.call(column, item[column.field], item, __classPrivateFieldGet(this, _isMobileOrTablet));
1957
+ return (value !== undefined && value !== null && value !== '')
1958
+ || (transformValue !== undefined && transformValue !== null && transformValue !== '')
1959
+ || (templateValue !== undefined && templateValue !== null && templateValue !== '');
1960
+ });
1961
+ }
1962
+ }
1963
+ _isMobileOrTablet = new WeakMap();
1964
+ SdColumnChildrenFilterPipe.decorators = [
1965
+ { type: Pipe, args: [{
1966
+ name: 'columnChildrenFilter'
1967
+ },] }
1968
+ ];
1969
+ SdColumnChildrenFilterPipe.ctorParameters = () => [
1970
+ { type: DeviceDetectorService }
1971
+ ];
1972
+
1973
+ class SdDesktopCommand {
1974
+ constructor() {
1975
+ this.commands = [];
1976
+ }
1977
+ }
1978
+ SdDesktopCommand.decorators = [
1979
+ { type: Component, args: [{
1980
+ selector: 'sd-desktop-command',
1981
+ template: "<ng-container *ngIf=\"item | commandFilter:commands | async; $implicit as filteredCommands\">\r\n <ng-container *ngFor=\"let command of filteredCommands\">\r\n <ng-container *ngIf=\"command?.click; else elseChildren\">\r\n <button (click)=\"command.click(item)\" [matTooltip]=\"command | commandTitle:item\" aria-hidden=\"true\"\r\n [disabled]=\"item | commandDisable:command\" mat-icon-button>\r\n <mat-icon class=\"c-icon\" [fontSet]=\"command.fontSet\">{{command | commandIcon:item}}</mat-icon>\r\n </button>\r\n </ng-container>\r\n <ng-template #elseChildren>\r\n <button [matMenuTriggerFor]=\"menu\" aria-hidden=\"true\" mat-icon-button>\r\n <mat-icon *ngIf=\"command?.icon\" class=\"c-icon\" [fontSet]=\"command.fontSet\">{{command | commandIcon:item}}\r\n </mat-icon>\r\n <mat-icon *ngIf=\"!command?.icon\" class=\"c-icon\">more_vert</mat-icon>\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <span>\r\n <button *ngFor=\"let childCommand of command.children\" mat-menu-item (click)=\"childCommand.click(item)\"\r\n [disabled]=\"item | commandDisable:childCommand\">\r\n <ng-container *ngIf=\"!childCommand.htmlTemplate\">\r\n <mat-icon [fontSet]=\"command.fontSet\" class=\"c-icon\">{{childCommand | commandIcon:item}}\r\n </mat-icon>\r\n <span> {{childCommand | commandTitle:item}}</span>\r\n </ng-container>\r\n <ng-container *ngIf=\"childCommand.htmlTemplate\">\r\n <div [innerHTML]=\"childCommand.htmlTemplate(item)\"></div>\r\n </ng-container>\r\n </button>\r\n </span>\r\n </mat-menu>\r\n </ng-template>\r\n </ng-container>\r\n</ng-container>\r\n",
1982
+ changeDetection: ChangeDetectionStrategy.OnPush,
1983
+ styles: [":host{align-items:center;display:flex}mat-icon.c-icon{color:rgba(0,0,0,.54)!important}"]
1984
+ },] }
1985
+ ];
1986
+ SdDesktopCommand.ctorParameters = () => [];
1987
+ SdDesktopCommand.propDecorators = {
1988
+ item: [{ type: Input }],
1989
+ commands: [{ type: Input }]
1990
+ };
1991
+
1992
+ class SdColumnBadgePipe {
1993
+ constructor() { }
1994
+ transform(value, rowData, column) {
1995
+ var _a, _b, _c;
1996
+ if (column.type === 'string' && (column === null || column === void 0 ? void 0 : column.badge)) {
1997
+ return {
1998
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
1999
+ color: column.badge(value, rowData),
2000
+ icon: (_a = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _a === void 0 ? void 0 : _a.call(column, value, rowData)
2001
+ };
2002
+ }
2003
+ if (column.type === 'number' && (column === null || column === void 0 ? void 0 : column.badge)) {
2004
+ return {
2005
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2006
+ color: column.badge(value, rowData),
2007
+ icon: (_b = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _b === void 0 ? void 0 : _b.call(column, value, rowData)
2008
+ };
2009
+ }
2010
+ if (column.type === 'bool') {
2011
+ return {
2012
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2013
+ color: !!value ? 'success' : 'danger',
2014
+ icon: null
2015
+ };
2016
+ }
2017
+ if (column.type === 'values' && (column === null || column === void 0 ? void 0 : column.badge)) {
2018
+ return {
2019
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2020
+ color: column.badge(value, rowData),
2021
+ icon: (_c = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _c === void 0 ? void 0 : _c.call(column, value, rowData)
2022
+ };
2023
+ }
2024
+ return null;
2025
+ }
2026
+ }
2027
+ SdColumnBadgePipe.decorators = [
2028
+ { type: Pipe, args: [{
2029
+ name: 'columnBadge'
2030
+ },] }
2031
+ ];
2032
+ SdColumnBadgePipe.ctorParameters = () => [];
2033
+
2034
+ class SdGridConfigurationResultPipe {
2035
+ constructor(gridConfigurationService) {
2036
+ this.gridConfigurationService = gridConfigurationService;
2037
+ }
2038
+ transform(configuration, gridOption, sdSubInformation) {
2039
+ const a = this.gridConfigurationService.generateConfigurationResult(configuration, gridOption, sdSubInformation);
2040
+ console.log(a);
2041
+ return a;
2042
+ }
2043
+ }
2044
+ SdGridConfigurationResultPipe.decorators = [
2045
+ { type: Pipe, args: [{
2046
+ name: 'sdGridConfigurationResult'
2047
+ },] }
2048
+ ];
2049
+ SdGridConfigurationResultPipe.ctorParameters = () => [
2050
+ { type: SdTableConfigurationService }
2051
+ ];
2052
+
2053
+ var _cache$3;
2054
+ class SdPopupGridConfiguration {
2055
+ constructor(ref, notifyService, translateService, gridConfigurationService) {
2056
+ this.ref = ref;
2057
+ this.notifyService = notifyService;
2058
+ this.translateService = translateService;
2059
+ this.gridConfigurationService = gridConfigurationService;
2060
+ this.changes = new EventEmitter();
2061
+ _cache$3.set(this, void 0);
2062
+ this.isCreatingColumn = false;
2063
+ this.selected = {};
2064
+ this.disabledDrag = true;
2065
+ this.open = () => __awaiter(this, void 0, void 0, function* () {
2066
+ __classPrivateFieldSet(this, _cache$3, this.gridConfigurationService.init(this.key, this.gridOption));
2067
+ this.configuration = yield __classPrivateFieldGet(this, _cache$3).get();
2068
+ this.modal.open();
2069
+ });
2070
+ this.onSave = () => {
2071
+ __classPrivateFieldGet(this, _cache$3).set(this.configuration);
2072
+ this.modal.close();
2073
+ this.ref.detectChanges();
2074
+ };
2075
+ this.onReset = () => __awaiter(this, void 0, void 0, function* () {
2076
+ const { translate } = this.translateService;
2077
+ this.notifyService.confirm(translate('Reset grid configuration to default')).then(() => {
2078
+ __classPrivateFieldGet(this, _cache$3).remove();
2079
+ this.modal.close();
2080
+ this.ref.detectChanges();
2081
+ });
2082
+ });
2083
+ this.createColumn = () => __awaiter(this, void 0, void 0, function* () {
2084
+ this.selected = {};
2085
+ this.isCreatingColumn = true;
2086
+ });
2087
+ this.confirm = () => __awaiter(this, void 0, void 0, function* () {
2088
+ const generatedColumn = {
2089
+ origin: {
2090
+ field: v4(),
2091
+ title: 'Generated',
2092
+ width: '300px',
2093
+ },
2094
+ fixed: false,
2095
+ invisible: false,
2096
+ title: 'Generated',
2097
+ width: '300px',
2098
+ };
2099
+ this.configuration.columns.push(generatedColumn);
2100
+ this.configuration = __classPrivateFieldGet(this, _cache$3).set(this.configuration);
2101
+ this.isCreatingColumn = false;
2102
+ });
2103
+ }
2104
+ ngOnInit() { }
2105
+ mouseUp(event) {
2106
+ this.disabledDrag = true;
2107
+ }
2108
+ dropTable(event) {
2109
+ moveItemInArray(this.configuration.columns, event.previousIndex, event.currentIndex);
2110
+ this.table.renderRows();
2111
+ }
2112
+ handleMouseDown() {
2113
+ this.disabledDrag = false;
2114
+ }
2115
+ handleMouseUp() {
2116
+ this.disabledDrag = true;
2117
+ }
2118
+ }
2119
+ _cache$3 = new WeakMap();
2120
+ SdPopupGridConfiguration.decorators = [
2121
+ { type: Component, args: [{
2122
+ selector: 'sd-popup-grid-configuration',
2123
+ template: "<sd-modal width=\"sm\" [title]=\"'Configuration' | sdTranslate\" #modal>\r\n <sd-modal-body *ngIf=\"configuration\">\r\n <div *ngIf=\"!isCreatingColumn\" class=\"c-container\">\r\n <div class=\"c-table\" style=\"max-height:70vh\">\r\n <table #table mat-table [dataSource]=\"configuration.columns\"\r\n cdkDropList\r\n [cdkDropListData]=\"configuration.columns\"\r\n (cdkDropListDropped)=\"dropTable($event)\">\r\n >\r\n <ng-container matColumnDef=\"stt\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:50px\">#\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item; let idx = index\">\r\n <div class=\"c-handle\" (mousedown) = \"handleMouseDown()\" (mouseup)=\"handleMouseUp()\">\r\n <svg width=\"24px\" fill=\"currentColor\" viewBox=\"0 0 24 24\">\r\n <path d=\"M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z\"></path>\r\n <path d=\"M0 0h24v24H0z\" fill=\"none\"></path>\r\n </svg>\r\n </div>\r\n\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"title\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef>{{'Title' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <sd-input [placeholder]=\"item?.origin?.title\" [(model)]=\"item.title\" disableErrorMessage></sd-input>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"width\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef style=\"width:80px\">{{'Width' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <!-- <span>{{item.width}}</span>\r\n <mat-slider\r\n step=\"1\"\r\n min=\"0\"\r\n [max]=\"+item?.origin?.width*3\"\r\n [(ngModel)]=\"+item.width\"\r\n aria-label=\"units\">\r\n </mat-slider> -->\r\n <sd-input [placeholder]=\"item?.origin?.width\" [(model)]=\"item.width\" disableErrorMessage></sd-input>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"invisible\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:80px\">{{'Hidden' |\r\n sdTranslate}}\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item;\">\r\n <mat-slide-toggle [(ngModel)]=\"item.invisible\" color=\"primary\">\r\n </mat-slide-toggle>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"fixed\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:80px\">{{'Freeze' |\r\n sdTranslate}}\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item;\">\r\n <mat-slide-toggle [(ngModel)]=\"item.fixed\" color=\"primary\"></mat-slide-toggle>\r\n </td>\r\n </ng-container>\r\n <tr mat-header-row *matHeaderRowDef=\"['stt', 'title', 'width', 'invisible', 'fixed']; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['stt', 'title', 'width', 'invisible', 'fixed'];\" cdkDrag [cdkDragData]=\"row\" cdkDragLockAxis=\"y\" [cdkDragDisabled] = \"disabledDrag\"></tr>\r\n </table>\r\n </div>\r\n </div>\r\n <div *ngIf=\"isCreatingColumn\">\r\n <div class=\"c-table\" style=\"max-height:50vh\">\r\n <table mat-table [dataSource]=\"configuration.columns\">\r\n <ng-container matColumnDef=\"stt\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:50px\">#\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item; let idx = index\">\r\n <sd-checkbox *ngIf=\"isCreatingColumn\" [(model)]=\"selected[item.origin?.field]\"></sd-checkbox>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"title\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef>{{'Title' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <span *ngIf=\"isCreatingColumn\">{{item.title || item?.origin?.title}}</span>\r\n </td>\r\n </ng-container>\r\n <tr mat-header-row *matHeaderRowDef=\"['stt', 'title']; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['stt', 'title'];\"></tr>\r\n </table>\r\n </div>\r\n </div>\r\n </sd-modal-body>\r\n <sd-modal-footer>\r\n <ng-container *ngIf=\"!isCreatingColumn\">\r\n <!-- <sd-button class=\"mr-auto\" (action)=\"createColumn()\" [title]=\"'Create column' | sdTranslate\" color=\"info\"\r\n size=\"sm\">\r\n </sd-button> -->\r\n <sd-button class=\"mr-5\" (action)=\"onReset()\" [title]=\"'Default' | sdTranslate\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n <sd-button (action)=\"onSave()\" [title]=\"'Save' | sdTranslate\" type=\"fill\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n </ng-container>\r\n <ng-container *ngIf=\"isCreatingColumn\">\r\n <sd-button class=\"mr-auto\" (action)=\"isCreatingColumn = false\" [title]=\"'Cancel' | sdTranslate\" color=\"info\"\r\n size=\"sm\">\r\n </sd-button>\r\n <sd-button (action)=\"confirm()\" [title]=\"'Confirm' | sdTranslate\" type=\"fill\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n </ng-container>\r\n </sd-modal-footer>\r\n</sd-modal>",
2124
+ styles: [".c-table{overflow:auto;position:relative}.c-table table{width:100%}.c-table .c-th{color:#000;font-size:14px;font-weight:500;line-height:20px}.c-container{min-height:200px;position:relative}.c-handle{color:#ccc;cursor:move}"]
2125
+ },] }
2126
+ ];
2127
+ SdPopupGridConfiguration.ctorParameters = () => [
2128
+ { type: ChangeDetectorRef },
2129
+ { type: SdNotifyService },
2130
+ { type: SdTranslateService },
2131
+ { type: SdTableConfigurationService }
2132
+ ];
2133
+ SdPopupGridConfiguration.propDecorators = {
2134
+ gridOption: [{ type: Input }],
2135
+ key: [{ type: Input }],
2136
+ modal: [{ type: ViewChild, args: ['modal',] }],
2137
+ table: [{ type: ViewChild, args: ['table',] }],
2138
+ mouseUp: [{ type: HostListener, args: ['window:mouseup', ['$event'],] }]
2139
+ };
2140
+
2141
+ class SdColumnTooltipPipe {
2142
+ constructor() { }
2143
+ transform(value, rowData, column) {
2144
+ if (column === null || column === void 0 ? void 0 : column.tooltip) {
2145
+ return column.tooltip(value, rowData);
2146
+ }
2147
+ return null;
2148
+ }
2149
+ }
2150
+ SdColumnTooltipPipe.decorators = [
2151
+ { type: Pipe, args: [{
2152
+ name: 'columnTooltip'
2153
+ },] }
2154
+ ];
2155
+ SdColumnTooltipPipe.ctorParameters = () => [];
2156
+
2157
+ var _convert;
2158
+ class SdSelectionActionFilterPipe {
2159
+ constructor() {
2160
+ _convert.set(this, (action) => {
2161
+ if ('children' in action) {
2162
+ return {
2163
+ title: action.title,
2164
+ icon: action.icon,
2165
+ fontSet: action.fontSet,
2166
+ tooltip: action.tooltip,
2167
+ color: action.color,
2168
+ type: action.type,
2169
+ children: action.children.map(e => ({
2170
+ title: e.title,
2171
+ icon: e.icon,
2172
+ color: action.color,
2173
+ type: action.type,
2174
+ fontSet: e.fontSet,
2175
+ tooltip: e.tooltip,
2176
+ click: e.click
2177
+ }))
2178
+ };
2179
+ }
2180
+ return {
2181
+ title: action.title,
2182
+ icon: action.icon,
2183
+ color: action.color,
2184
+ type: action.type,
2185
+ fontSet: action.fontSet,
2186
+ tooltip: action.tooltip,
2187
+ click: action.click
2188
+ };
2189
+ });
2190
+ this.transform = (selectedItems, actions) => {
2191
+ const results = [];
2192
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length) || !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length)) {
2193
+ return [];
2194
+ }
2195
+ for (const action of actions) {
2196
+ if ('children' in action) {
2197
+ const children = [];
2198
+ for (const childAction of action.children) {
2199
+ const key = hash__default(childAction);
2200
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2201
+ children.push(childAction);
2202
+ }
2203
+ }
2204
+ if (children.length > 0) {
2205
+ results.push(Object.assign(Object.assign({}, action), { children }));
2206
+ }
2207
+ }
2208
+ else {
2209
+ const key = hash__default(action);
2210
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2211
+ results.push(action);
2212
+ }
2213
+ }
2214
+ }
2215
+ return results.map(result => __classPrivateFieldGet(this, _convert).call(this, result));
2216
+ };
2217
+ }
2218
+ }
2219
+ _convert = new WeakMap();
2220
+ SdSelectionActionFilterPipe.decorators = [
2221
+ { type: Pipe, args: [{
2222
+ name: 'selectionActionFilter'
2223
+ },] }
2224
+ ];
2225
+
2226
+ class SdSelectionDisablePipe {
2227
+ constructor() {
2228
+ this.transform = (selectedItems, rowData, selection) => {
2229
+ const { disabled, actions } = selection;
2230
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2231
+ if (!disabled) {
2232
+ rowData.meta.selector.selectable = true;
2233
+ return false;
2234
+ }
2235
+ rowData.meta.selector.selectable = !disabled(rowData, selectedItems);
2236
+ return !rowData.meta.selector.selectable;
2237
+ }
2238
+ // Lọc các action theo selectedItems hiện tại
2239
+ const availableActions = actions.filter(action => {
2240
+ if ('children' in action) {
2241
+ for (const childAction of action.children) {
2242
+ const key = hash__default(childAction);
2243
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2244
+ return true;
2245
+ }
2246
+ }
2247
+ return false;
2248
+ }
2249
+ else {
2250
+ const key = hash__default(action);
2251
+ return selectedItems.every(e => e.meta.selector.actions.includes(key));
2252
+ }
2253
+ });
2254
+ // Kiểm tra rowData có action nào thỏa hay ko, nếu ko thì disabled
2255
+ for (const action of availableActions) {
2256
+ if ('children' in action) {
2257
+ for (const childAction of action.children) {
2258
+ if (rowData.meta.selector.actions.includes(hash__default(childAction))) {
2259
+ return false;
2260
+ }
2261
+ }
2262
+ }
2263
+ else {
2264
+ if (rowData.meta.selector.actions.includes(hash__default(action))) {
2265
+ return false;
2266
+ }
2267
+ }
2268
+ }
2269
+ return true;
2270
+ };
2271
+ }
2272
+ }
2273
+ SdSelectionDisablePipe.decorators = [
2274
+ { type: Pipe, args: [{
2275
+ name: 'selectionDisable'
2276
+ },] }
2277
+ ];
2278
+
2279
+ class SdSelectionVisibleSelectAllPipe {
2280
+ constructor() {
2281
+ this.transform = (items, selection) => __awaiter(this, void 0, void 0, function* () {
2282
+ const { actions } = selection;
2283
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2284
+ return true;
2285
+ }
2286
+ if (!items.length) {
2287
+ return false;
2288
+ }
2289
+ if (actions.some(e => ('children' in e && e.children.some(e1 => e1.isGrouped)) || e.isGrouped)) {
2290
+ return false;
2291
+ }
2292
+ yield new Promise(resolve => setTimeout(resolve, 500));
2293
+ const first = items.find(t => { var _a; return (_a = t.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length; });
2294
+ if (first) {
2295
+ for (const action of first.meta.selector.actions) {
2296
+ if (items.filter(t => { var _a; return (_a = t.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length; }).every(e => e.meta.selector.actions.includes(action))) {
2297
+ return true;
2298
+ }
2299
+ }
2300
+ }
2301
+ return false;
2302
+ });
2303
+ }
2304
+ }
2305
+ SdSelectionVisibleSelectAllPipe.decorators = [
2306
+ { type: Pipe, args: [{
2307
+ name: 'selectionVisibleSelectAll'
2308
+ },] }
2309
+ ];
2310
+
2311
+ class SdDesktopCell {
2312
+ constructor() {
2313
+ this.cellDef = {};
2314
+ }
2315
+ }
2316
+ SdDesktopCell.decorators = [
2317
+ { type: Component, args: [{
2318
+ selector: 'sd-desktop-cell',
2319
+ template: "<ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"cellDef[column.field].templateRef; context: { item: item, column: column, idx: idx }\"> </ng-container>\r\n</ng-container>\r\n<sd-desktop-cell-view\r\n *ngIf=\"!cellDef[column.field]\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [column]=\"column\"\r\n [gridOption]=\"gridOption\"\r\n [item]=\"item\">\r\n</sd-desktop-cell-view>\r\n",
2320
+ changeDetection: ChangeDetectionStrategy.OnPush
2321
+ },] }
2322
+ ];
2323
+ SdDesktopCell.ctorParameters = () => [];
2324
+ SdDesktopCell.propDecorators = {
2325
+ sdId: [{ type: Input }],
2326
+ value: [{ type: Input }],
2327
+ key: [{ type: Input }],
2328
+ column: [{ type: Input }],
2329
+ item: [{ type: Input }],
2330
+ gridOption: [{ type: Input }],
2331
+ cellDef: [{ type: Input }],
2332
+ idx: [{ type: Input }]
2333
+ };
2334
+
2335
+ const SdFilterOperators = [
2336
+ {
2337
+ value: 'EQUAL',
2338
+ symbol: '=',
2339
+ display: 'Bằng',
2340
+ },
2341
+ {
2342
+ value: 'NOT_EQUAL',
2343
+ symbol: '≠',
2344
+ display: 'Không bằng',
2345
+ },
2346
+ {
2347
+ value: 'GREATER_THAN',
2348
+ symbol: '>',
2349
+ display: 'Lớn hơn',
2350
+ },
2351
+ {
2352
+ value: 'LESS_THAN',
2353
+ symbol: '<',
2354
+ display: 'Nhỏ hơn',
2355
+ },
2356
+ {
2357
+ value: 'GREATER_OR_EQUAL',
2358
+ symbol: '≥',
2359
+ display: 'Lớn hơn, hoặc bằng'
2360
+ },
2361
+ {
2362
+ value: 'LESS_OR_EQUAL',
2363
+ symbol: '≤',
2364
+ display: 'Nhỏ hơn, hoặc bằng'
2365
+ },
2366
+ {
2367
+ value: 'CONTAIN',
2368
+ symbol: 'join_inner',
2369
+ display: 'Chứa',
2370
+ },
2371
+ {
2372
+ value: 'NOT_CONTAIN',
2373
+ symbol: 'join',
2374
+ display: 'Không chứa',
2375
+ },
2376
+ {
2377
+ value: 'START_WITH',
2378
+ symbol: 'line_start_circle',
2379
+ display: 'Bắt đầu bởi'
2380
+ },
2381
+ {
2382
+ value: 'END_WITH',
2383
+ symbol: 'line_end_circle',
2384
+ display: 'Kết thúc bởi'
2385
+ },
2386
+ {
2387
+ value: 'IN',
2388
+ symbol: 'checklist_rtl',
2389
+ display: 'Nằm trong'
2390
+ },
2391
+ {
2392
+ value: 'NOT_IN',
2393
+ symbol: 'event_list',
2394
+ display: 'Không nằm trong'
2395
+ },
2396
+ ];
2397
+
2398
+ var _inlineOperator_1, _valueChanges, _subcription;
2399
+ class SdColumnInlineFilter {
2400
+ constructor(ref) {
2401
+ this.ref = ref;
2402
+ this.inlineSymbol = 'filter_alt';
2403
+ _inlineOperator_1.set(this, void 0);
2404
+ this.inlineOperatorChange = new EventEmitter();
2405
+ this.columnFilter = {};
2406
+ this.operators = [];
2407
+ this.filterChange = new EventEmitter();
2408
+ _valueChanges.set(this, new Subject());
2409
+ _subcription.set(this, new Subscription());
2410
+ this.onFilterChange = () => {
2411
+ this.filterChange.emit();
2412
+ };
2413
+ this.onChangeOperator = (operator) => {
2414
+ if (operator) {
2415
+ __classPrivateFieldSet(this, _inlineOperator_1, operator.value);
2416
+ this.inlineSymbol = operator.symbol;
2417
+ }
2418
+ else {
2419
+ __classPrivateFieldSet(this, _inlineOperator_1, null);
2420
+ this.inlineSymbol = 'filter_alt';
2421
+ }
2422
+ this.inlineOperatorChange.emit(__classPrivateFieldGet(this, _inlineOperator_1));
2423
+ this.ref.markForCheck();
2424
+ };
2425
+ }
2426
+ _value(value) {
2427
+ this.value = value;
2428
+ __classPrivateFieldGet(this, _valueChanges).next();
2429
+ }
2430
+ set _inlineOperator(inlineOperator) {
2431
+ var _a, _b;
2432
+ if (__classPrivateFieldGet(this, _inlineOperator_1) !== inlineOperator) {
2433
+ __classPrivateFieldSet(this, _inlineOperator_1, inlineOperator);
2434
+ this.inlineSymbol = (_b = (_a = SdFilterOperators.find(e => e.value === inlineOperator)) === null || _a === void 0 ? void 0 : _a.symbol) !== null && _b !== void 0 ? _b : 'filter_alt';
2435
+ }
2436
+ }
2437
+ set _columnFilter(columnFilter) {
2438
+ this.columnFilter = columnFilter || {};
2439
+ __classPrivateFieldGet(this, _valueChanges).next();
2440
+ }
2441
+ set _column(column) {
2442
+ var _a, _b, _c;
2443
+ this.column = column;
2444
+ if (!((_a = column === null || column === void 0 ? void 0 : column.filter) === null || _a === void 0 ? void 0 : _a.disabled) && ((_c = (_b = column === null || column === void 0 ? void 0 : column.filter) === null || _b === void 0 ? void 0 : _b.operator) === null || _c === void 0 ? void 0 : _c.enable)) {
2445
+ this.operators = SdFilterOperators.filter(e => { var _a, _b; return (_b = (_a = column.filter.operator.list) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, e.value); });
2446
+ }
2447
+ else {
2448
+ this.operators = [];
2449
+ }
2450
+ }
2451
+ ngOnInit() {
2452
+ __classPrivateFieldGet(this, _subcription).add(__classPrivateFieldGet(this, _valueChanges).pipe(startWith(this.columnFilter)).subscribe(() => {
2453
+ var _a, _b;
2454
+ if (this.column.type === 'date' || this.column.type === 'time' || this.column.type === 'datetime') {
2455
+ if (!((_b = (_a = this.column) === null || _a === void 0 ? void 0 : _a.option) === null || _b === void 0 ? void 0 : _b.useFilterDate)) {
2456
+ this.columnFilter[this.column.field] = this.columnFilter[this.column.field] || {
2457
+ from: null,
2458
+ to: null,
2459
+ };
2460
+ }
2461
+ }
2462
+ }));
2463
+ }
2464
+ ngOnDestroy() {
2465
+ __classPrivateFieldGet(this, _subcription).unsubscribe();
2466
+ }
2467
+ }
2468
+ _inlineOperator_1 = new WeakMap(), _valueChanges = new WeakMap(), _subcription = new WeakMap();
2469
+ SdColumnInlineFilter.decorators = [
2470
+ { type: Component, args: [{
2471
+ selector: 'sd-column-inline-filter',
2472
+ template: "<div class=\"d-flex c-inline-column\">\r\n <ng-container\r\n *ngIf=\"\r\n column.type === 'string' ||\r\n column.type === 'number' ||\r\n column.type === 'bool' ||\r\n column.type === 'values' ||\r\n column.type === 'date' ||\r\n column.type === 'datetime' ||\r\n column.type === 'time';\r\n else noFilter\r\n \">\r\n <div class=\"d-flex align-items-center\" *ngIf=\"operators.length\">\r\n <!-- Only number column icon broken. add mb when not default symbol -->\r\n <sd-button class=\"{{ (column.type === 'number' && inlineSymbol !== 'filter_alt') ? 'mb-4 mr-2 ' :'mr-2 '}}\" fontSet=\"material-symbols-outlined\" [icon]=\"inlineSymbol\" size=\"sm\"\r\n [matMenuTriggerFor]=\"menu\" type=\"link\"> </sd-button>\r\n <mat-menu #menu=\"matMenu\">\r\n <button *ngFor=\"let operator of operators\" (click)=\"onChangeOperator(operator)\" mat-menu-item type=\"button\">\r\n <mat-icon fontSet=\"material-symbols-outlined\" class=\"{{column.type === 'number' ? 'mb-8 ':''}}\">{{ operator.symbol }}</mat-icon>\r\n <span> {{ operator.display }}</span>\r\n </button>\r\n </mat-menu>\r\n </div>\r\n <sd-input\r\n *ngIf=\"column.type === 'string'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n type=\"text\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (keyupEnter)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-input>\r\n <sd-input-number\r\n *ngIf=\"column.type === 'number'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (keyupEnter)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-input-number>\r\n <sd-select\r\n *ngIf=\"column.type === 'bool'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"[\r\n { value: '1', display: column.option?.displayOnTrue || 'True' },\r\n { value: '0', display: column.option?.displayOnFalse || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n <ng-template sdSelectDisplayDef let-item=\"item\">\r\n <sd-badge *ngIf=\"item.value === '1'\" color=\"success\" [title]=\"column.option?.displayOnTrue || 'True'\"> </sd-badge>\r\n <sd-badge *ngIf=\"item.value === '0'\" color=\"danger\" [title]=\"column.option?.displayOnFalse || 'False'\"> </sd-badge>\r\n </ng-template>\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"column.type === 'values' && column?.option?.selection !== 'AUTOCOMPLETE'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\"\r\n [multiple]=\"column?.option?.selection === 'MULTIPLE' || column?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [filtered]=\"column?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\">\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"column.type === 'values' && column?.option?.selection === 'AUTOCOMPLETE'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-autocomplete>\r\n <ng-container *ngIf=\"column.type === 'date' || column.type === 'datetime' || column.type === 'time'\">\r\n <sd-date-range\r\n *ngIf=\"!column.option?.useFilterDate\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [(from)]=\"columnFilter[column.field].from\"\r\n [(to)]=\"columnFilter[column.field].to\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-date-range>\r\n <sd-date-time\r\n *ngIf=\"column.option?.useFilterDate\"\r\n style=\"flex: 1\"\r\n type=\"date\"\r\n size=\"sm\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-date-time>\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #noFilter>\r\n <sd-input type=\"text\" size=\"sm\" disabled> </sd-input>\r\n </ng-template>\r\n</div>\r\n",
2473
+ changeDetection: ChangeDetectionStrategy.OnPush,
2474
+ styles: [":host ::ng-deep .c-inline-column .mat-form-field-wrapper{background-color:#fff;border-radius:8px;margin:8px 0 0!important;padding:0!important}"]
2475
+ },] }
2476
+ ];
2477
+ SdColumnInlineFilter.ctorParameters = () => [
2478
+ { type: ChangeDetectorRef }
2479
+ ];
2480
+ SdColumnInlineFilter.propDecorators = {
2481
+ _value: [{ type: Input, args: ['value',] }],
2482
+ _inlineOperator: [{ type: Input, args: ['inlineOperator',] }],
2483
+ inlineOperatorChange: [{ type: Output }],
2484
+ _columnFilter: [{ type: Input, args: ['columnFilter',] }],
2485
+ _column: [{ type: Input, args: ['column',] }],
2486
+ filterChange: [{ type: Output }]
2487
+ };
2488
+
2489
+ class SdSelectionVisiblePipe {
2490
+ constructor() {
2491
+ this.transform = (rowData, selection) => {
2492
+ var _a, _b, _c;
2493
+ const { actions } = selection;
2494
+ const groupedActions = [];
2495
+ rowData.meta.selector.actions = rowData.meta.selector.actions || [];
2496
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2497
+ rowData.meta.selector.selectable = true;
2498
+ return rowData.meta.selector.selectable;
2499
+ }
2500
+ for (const action of actions) {
2501
+ if ('children' in action) {
2502
+ let flag = false;
2503
+ let hasGroup = false;
2504
+ for (const childAction of action.children) {
2505
+ const { hidden, isGrouped } = childAction;
2506
+ const key = hash__default(childAction);
2507
+ if (isGrouped) {
2508
+ hasGroup = true;
2509
+ }
2510
+ if (typeof (hidden) === 'function') {
2511
+ if (!hidden(rowData)) {
2512
+ flag = true;
2513
+ rowData.meta.selector.actions.push(key);
2514
+ if (isGrouped) {
2515
+ groupedActions.push(key);
2516
+ }
2517
+ }
2518
+ }
2519
+ else if (!hidden) {
2520
+ flag = true;
2521
+ rowData.meta.selector.actions.push(key);
2522
+ if (isGrouped) {
2523
+ groupedActions.push(key);
2524
+ }
2525
+ }
2526
+ }
2527
+ if (flag) {
2528
+ rowData.meta.selector.actions.push(hash__default(action));
2529
+ if (hasGroup) {
2530
+ groupedActions.push(hash__default(action));
2531
+ }
2532
+ }
2533
+ }
2534
+ else {
2535
+ const { hidden, isGrouped } = action;
2536
+ const key = hash__default(action);
2537
+ if (typeof (hidden) === 'function') {
2538
+ if (!hidden(rowData)) {
2539
+ rowData.meta.selector.actions.push(key);
2540
+ if (isGrouped) {
2541
+ groupedActions.push(key);
2542
+ }
2543
+ }
2544
+ }
2545
+ else if (!hidden) {
2546
+ rowData.meta.selector.actions.push(key);
2547
+ if (isGrouped) {
2548
+ groupedActions.push(key);
2549
+ }
2550
+ }
2551
+ }
2552
+ }
2553
+ rowData.meta.selector.selectable = !!((_a = rowData.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length);
2554
+ if (!rowData.meta.selector.selectable || !groupedActions.length || ((_c = (_b = rowData === null || rowData === void 0 ? void 0 : rowData.meta.group) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length)) {
2555
+ return rowData.meta.selector.selectable;
2556
+ }
2557
+ // Đối với trường hợp grouped, tuy selectable là true nhưng vẫn ẩn đi checkbox
2558
+ // nếu các action đều thuộc groupedActions và rowData ko phải là dòng group
2559
+ return rowData.meta.selector.actions.some(action => !groupedActions.includes(action));
2560
+ };
2561
+ }
2562
+ }
2563
+ SdSelectionVisiblePipe.decorators = [
2564
+ { type: Pipe, args: [{
2565
+ name: 'selectionVisible'
2566
+ },] }
2567
+ ];
2568
+
2569
+ class SdGridQuickAction {
2570
+ constructor() {
2571
+ this.clear = new EventEmitter();
2572
+ this.onClear = () => {
2573
+ this.clear.emit();
2574
+ };
2575
+ }
2576
+ }
2577
+ SdGridQuickAction.decorators = [
2578
+ { type: Component, args: [{
2579
+ selector: 'sd-grid-quick-action',
2580
+ template: "<sd-quick-action *ngIf=\"selectedItems | selectionActionFilter: gridOption?.selector?.actions as actions\"\r\n [isOpened]=\"actions?.length\">\r\n <div class=\"d-flex align-items-center\" sdMessage>\r\n <div class=\"c-bg-length\">\r\n <span class=\"c-length\">{{ selectedItems.length }}</span>\r\n </div>\r\n <div class=\"c-message\">{{ gridOption?.selector?.message || 'd\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c ch\u1ECDn' }}</div>\r\n </div>\r\n <div class=\"d-flex align-items-center mr-8\" sdAction>\r\n <ng-container *ngFor=\"let action of actions\">\r\n <sd-button *ngIf=\"action.click\" class=\"ml-5\" [tooltip]=\"action.tooltip\" [icon]=\"action.icon\"\r\n [color]=\"action.color || 'secondary'\" [type]=\"action.type || 'light'\" [fontSet]=\"action.fontSet\"\r\n [title]=\"action.title\" size=\"sm\" (action)=\"action.click(selectedItems)\"></sd-button>\r\n <ng-container *ngIf=\"action.children?.length\">\r\n <sd-button class=\"ml-5\" [tooltip]=\"action.tooltip\" [icon]=\"action.icon || 'more_vert'\"\r\n [color]=\"action.color || 'secondary'\" [type]=\"action.type || 'light'\" [fontSet]=\"action.fontSet\"\r\n [title]=\"action.title\" size=\"sm\" [matMenuTriggerFor]=\"menu\">\r\n </sd-button>\r\n <mat-menu #menu=\"matMenu\">\r\n <span>\r\n <button *ngFor=\"let childAction of action.children\" mat-menu-item (click)=\"childAction.click(selectedItems)\"\r\n [disabled]=\"childAction.disabled\">\r\n <mat-icon [fontSet]=\"childAction.fontSet\" class=\"c-icon\">{{ childAction.icon }}\r\n </mat-icon>\r\n <span> {{ childAction.title }}</span>\r\n </button>\r\n </span>\r\n </mat-menu>\r\n </ng-container>\r\n </ng-container>\r\n <sd-button class=\"ml-5\" icon=\"close\" color=\"secondary\" type=\"outline\" size=\"sm\"\r\n (action)=\"onClear()\" width=\"35px\"></sd-button>\r\n </div>\r\n</sd-quick-action>",
2581
+ changeDetection: ChangeDetectionStrategy.OnPush,
2582
+ styles: [".c-bg-length{align-items:flex-start;background:#2962ff;border-radius:4px 0 0 4px;display:flex;flex-direction:column;height:48px;left:0;min-width:48px;padding:12px 8px;position:static;top:0;width:auto}.c-bg-length .c-length{color:#fff;font-size:16px;font-weight:500;height:24px;left:8px;line-height:24px;min-width:32px;text-align:center;top:12px;width:auto}.c-bg-length .c-length,.c-message{font-family:Roboto;font-style:normal;position:static}.c-message{color:#000;font-size:14px;font-weight:400;height:20px;left:0;line-height:20px;margin:0 0 0 16px;min-width:200px;top:6px}"]
2583
+ },] }
2584
+ ];
2585
+ SdGridQuickAction.ctorParameters = () => [];
2586
+ SdGridQuickAction.propDecorators = {
2587
+ gridOption: [{ type: Input }],
2588
+ selectedItems: [{ type: Input }],
2589
+ clear: [{ type: Output }]
2590
+ };
2591
+
2592
+ var _maxSecond, _maxMinute, _maxHour, _maxDay, _maxMonth, _isMobileOrTablet$1;
2593
+ class SdCellViewPipe {
2594
+ constructor(deviceService, utilityService, columnValuesPipe) {
2595
+ this.utilityService = utilityService;
2596
+ this.columnValuesPipe = columnValuesPipe;
2597
+ _maxSecond.set(this, 60);
2598
+ _maxMinute.set(this, __classPrivateFieldGet(this, _maxSecond) * 60);
2599
+ _maxHour.set(this, __classPrivateFieldGet(this, _maxMinute) * 24);
2600
+ _maxDay.set(this, __classPrivateFieldGet(this, _maxHour) * 30);
2601
+ _maxMonth.set(this, __classPrivateFieldGet(this, _maxHour) * 365);
2602
+ _isMobileOrTablet$1.set(this, false);
2603
+ __classPrivateFieldSet(this, _isMobileOrTablet$1, !deviceService.isDesktop());
2604
+ }
2605
+ transform(value, tableItem, column, gridOption) {
2606
+ var _a;
2607
+ return __awaiter(this, void 0, void 0, function* () {
2608
+ const { displayOnEmpty } = gridOption;
2609
+ const rowData = tableItem.current;
2610
+ const { align, click, tooltip, htmlTemplate, transform } = column;
2611
+ const result = {
2612
+ badge: null,
2613
+ tooltip: null,
2614
+ display: {
2615
+ align: align || (column.type === 'number' ? 'right' : 'left'),
2616
+ value
2617
+ },
2618
+ click: null
2619
+ };
2620
+ // Display
2621
+ if (typeof (htmlTemplate) === 'function') {
2622
+ result.display.hasHtml = true;
2623
+ result.display.html = htmlTemplate(value, rowData, __classPrivateFieldGet(this, _isMobileOrTablet$1));
2624
+ }
2625
+ else {
2626
+ if (column.type === 'datetime' || column.type === 'date' || column.type === 'time') {
2627
+ const { transformDate } = column;
2628
+ if (transformDate) {
2629
+ value = transformDate(value, rowData);
2630
+ }
2631
+ }
2632
+ if (typeof (transform) === 'function') {
2633
+ const val = transform(value, rowData);
2634
+ if (val instanceof Promise) {
2635
+ result.display.value = yield val;
2636
+ }
2637
+ else {
2638
+ result.display.value = val;
2639
+ }
2640
+ }
2641
+ else {
2642
+ if (column.type === 'date' || column.type === 'datetime') {
2643
+ const { option } = column;
2644
+ const seconds = Math.round((new Date().getTime() - new Date(value).getTime()) / 1000);
2645
+ if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'month' && seconds < __classPrivateFieldGet(this, _maxMonth)) {
2646
+ result.display.value = this.utilityService.timeDifference(value);
2647
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2648
+ }
2649
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'day' && seconds < __classPrivateFieldGet(this, _maxDay)) {
2650
+ result.display.value = this.utilityService.timeDifference(value);
2651
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2652
+ }
2653
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'hour' && seconds < __classPrivateFieldGet(this, _maxHour)) {
2654
+ result.display.value = this.utilityService.timeDifference(value);
2655
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2656
+ }
2657
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'minute' && seconds < __classPrivateFieldGet(this, _maxMinute)) {
2658
+ result.display.value = this.utilityService.timeDifference(value);
2659
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2660
+ }
2661
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'second' && seconds < __classPrivateFieldGet(this, _maxSecond)) {
2662
+ result.display.value = this.utilityService.timeDifference(value);
2663
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2664
+ }
2665
+ else {
2666
+ const date = Date.toFormat(value, 'dd/MM/yyyy');
2667
+ const time = Date.toFormat(value, 'HH:mm');
2668
+ const dateTime = Date.toFormat(value, 'HH:mm');
2669
+ if (column.type === 'datetime' && time && time !== '00:00') {
2670
+ result.display.value = dateTime;
2671
+ result.display.hasHtml = true;
2672
+ result.display.html = `<span class="d-block T14R text-black400">${Date.toFormat(value, 'HH:mm')}</span><span class="d-block T14R">${Date.toFormat(value, 'dd/MM/yyyy')}</span>`;
2673
+ }
2674
+ else {
2675
+ result.display.value = date;
2676
+ }
2677
+ }
2678
+ }
2679
+ if (column.type === 'time') {
2680
+ result.display.value = Date.toFormat(value, 'HH:mm');
2681
+ }
2682
+ if (column.type === 'values') {
2683
+ result.display.value = yield this.columnValuesPipe.transform(value, column);
2684
+ }
2685
+ else if (column.type === 'number' && Number.isNumber(value)) {
2686
+ result.display.value = Number.toVNCurrency(value);
2687
+ }
2688
+ if (column.type === 'bool') {
2689
+ const { option } = column;
2690
+ if (value !== undefined && value !== null && value !== '') {
2691
+ result.display.value = value === true ? ((option === null || option === void 0 ? void 0 : option.displayOnTrue) || 'True') : ((option === null || option === void 0 ? void 0 : option.displayOnFalse) || 'False');
2692
+ }
2693
+ else {
2694
+ result.display.value = null;
2695
+ }
2696
+ }
2697
+ }
2698
+ if (displayOnEmpty) {
2699
+ let values = [null, undefined, ''];
2700
+ if (typeof (displayOnEmpty) === 'object') {
2701
+ const { display, emptyValues } = displayOnEmpty;
2702
+ values = [null, undefined, '', ...emptyValues];
2703
+ if (values.includes(result.display.value)) {
2704
+ if (typeof (display) === 'function') {
2705
+ result.display.hasHtml = true;
2706
+ result.display.html = display(rowData, column);
2707
+ }
2708
+ else {
2709
+ result.display.hasHtml = true;
2710
+ result.display.html = `<div class="T16R text-black400">--</div>`;
2711
+ }
2712
+ }
2713
+ }
2714
+ else {
2715
+ if (values.includes(result.display.value)) {
2716
+ if (typeof (displayOnEmpty) === 'function') {
2717
+ result.display.hasHtml = true;
2718
+ result.display.html = displayOnEmpty(rowData, column);
2719
+ }
2720
+ else {
2721
+ result.display.hasHtml = true;
2722
+ result.display.html = `<div class="T16R text-black400">--</div>`;
2723
+ }
2724
+ }
2725
+ }
2726
+ }
2727
+ }
2728
+ // Badge
2729
+ if ((column.type === 'string' || column.type === 'number' || column.type === 'values') && column.badge) {
2730
+ result.badge = {
2731
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2732
+ color: column.badge(value, rowData),
2733
+ icon: (_a = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _a === void 0 ? void 0 : _a.call(column, value, rowData)
2734
+ };
2735
+ }
2736
+ else if (column.type === 'bool') {
2737
+ result.badge = {
2738
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2739
+ color: !!value ? 'success' : 'danger',
2740
+ icon: null
2741
+ };
2742
+ }
2743
+ // Tooltip
2744
+ if (typeof (tooltip) === 'function') {
2745
+ result.tooltip = tooltip(value, rowData);
2746
+ }
2747
+ // Clickable
2748
+ if (typeof (click) === 'function') {
2749
+ result.click = () => click(value, rowData);
2750
+ }
2751
+ return result;
2752
+ });
2753
+ }
2754
+ }
2755
+ _maxSecond = new WeakMap(), _maxMinute = new WeakMap(), _maxHour = new WeakMap(), _maxDay = new WeakMap(), _maxMonth = new WeakMap(), _isMobileOrTablet$1 = new WeakMap();
2756
+ SdCellViewPipe.decorators = [
2757
+ { type: Pipe, args: [{
2758
+ name: 'cellView'
2759
+ },] }
2760
+ ];
2761
+ SdCellViewPipe.ctorParameters = () => [
2762
+ { type: DeviceDetectorService },
2763
+ { type: SdUtilityService },
2764
+ { type: SdColumnValuesPipe }
2765
+ ];
2766
+
2767
+ class SdGroupPipe {
2768
+ transform(items, gridOption) {
2769
+ var _a;
2770
+ const { group } = gridOption;
2771
+ if (!group) {
2772
+ return items;
2773
+ }
2774
+ const { fields, htmlTemplate } = group;
2775
+ if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
2776
+ return items;
2777
+ }
2778
+ const groupItem = {};
2779
+ for (const item of items) {
2780
+ let obj = {};
2781
+ for (const field of fields) {
2782
+ obj = Object.assign(Object.assign({}, obj), ((_a = item[field]) !== null && _a !== void 0 ? _a : { [field]: item[field] }));
2783
+ }
2784
+ const key = hash__default(obj);
2785
+ if (!groupItem[key]) {
2786
+ groupItem[key] = [];
2787
+ }
2788
+ groupItem[key].push(item);
2789
+ }
2790
+ const results = [];
2791
+ for (const key of Object.keys(groupItem)) {
2792
+ const result = MapToSdTableItem({});
2793
+ result.meta.group.items = groupItem[key];
2794
+ result.meta.group.htmlTemplate = htmlTemplate(groupItem[key]);
2795
+ results.push(result);
2796
+ for (const item of groupItem[key]) {
2797
+ results.push(item);
2798
+ }
2799
+ }
2800
+ return results;
2801
+ }
2802
+ }
2803
+ SdGroupPipe.decorators = [
2804
+ { type: Pipe, args: [{
2805
+ name: 'sdGroup',
2806
+ },] }
2807
+ ];
2808
+
2809
+ class MatPaginatorIntlCro extends MatPaginatorIntl {
2810
+ constructor() {
2811
+ super(...arguments);
2812
+ this.firstPageLabel = 'Trang đầu';
2813
+ this.lastPageLabel = 'Trang cuối';
2814
+ this.itemsPerPageLabel = 'Kích thước trang';
2815
+ this.nextPageLabel = 'Trang sau';
2816
+ this.previousPageLabel = 'Trang trước';
2817
+ this.getRangeLabel = (page, pageSize, length) => {
2818
+ if (length === 0 || pageSize === 0) {
2819
+ return '';
2820
+ }
2821
+ const from = page * pageSize + 1;
2822
+ const to = from + (length - page * pageSize > pageSize ? pageSize : length - page * pageSize) - 1;
2823
+ return `${from}-${to} trên ${length}`;
2824
+ };
2825
+ }
2826
+ }
2827
+ MatPaginatorIntlCro.decorators = [
2828
+ { type: Injectable }
2829
+ ];
2830
+ class SdTableModule {
2831
+ }
2832
+ SdTableModule.decorators = [
2833
+ { type: NgModule, args: [{
2834
+ imports: [
2835
+ CommonModule,
2836
+ FormsModule,
2837
+ ReactiveFormsModule,
2838
+ MatInputModule,
2839
+ MatFormFieldModule,
2840
+ MatSortModule,
2841
+ MatPaginatorModule,
2842
+ MatTableModule,
2843
+ MatMenuModule,
2844
+ MatIconModule,
2845
+ MatButtonModule,
2846
+ MatTooltipModule,
2847
+ MatProgressSpinnerModule,
2848
+ MatChipsModule,
2849
+ MatRadioModule,
2850
+ MatSlideToggleModule,
2851
+ MatCheckboxModule,
2852
+ MatListModule,
2853
+ MatDividerModule,
2854
+ CdkTableModule,
2855
+ DragDropModule,
2856
+ SdFormModule,
2857
+ SdServiceModule,
2858
+ MatSliderModule,
2859
+ ScrollingModule,
2860
+ SdCommonModule,
2861
+ SdGroupModule,
2862
+ ],
2863
+ declarations: [
2864
+ SdGridQuickAction,
2865
+ SdDesktopCell,
2866
+ SdDesktopCellView,
2867
+ SdDesktopCommand,
2868
+ SdColumnInlineFilter,
2869
+ SdTable,
2870
+ SdMaterialFooterDefDirective,
2871
+ SdMaterialCellDefDirective,
2872
+ SdMaterialFilterDefDirective,
2873
+ SdMaterialSubInformationDefDirective,
2874
+ SdMaterialEmptyDataDefDirective,
2875
+ SdPopupGridConfiguration,
2876
+ SdGridFilter,
2877
+ SdPopupFilter,
2878
+ // Pipes
2879
+ SdGridConfigurationResultPipe,
2880
+ SdColumnChildrenFilterPipe,
2881
+ SdCommandFilterPipe,
2882
+ SdCommandDisablePipe,
2883
+ SdCommandIconPipe,
2884
+ SdCommandTitlePipe,
2885
+ SdColumnValuesPipe,
2886
+ SdColumnHtmlTemplatePipe,
2887
+ SdColumnTransformPipe,
2888
+ SdColumnTooltipPipe,
2889
+ SdColumnBadgePipe,
2890
+ SdFilterColumnPipe,
2891
+ SdFilterExternalPipe,
2892
+ SdSelectionActionFilterPipe,
2893
+ SdSelectionVisiblePipe,
2894
+ SdSelectionDisablePipe,
2895
+ SdSelectionVisibleSelectAllPipe,
2896
+ SdCellViewPipe,
2897
+ SdGroupPipe,
2898
+ ],
2899
+ exports: [
2900
+ SdTable,
2901
+ SdMaterialFooterDefDirective,
2902
+ SdMaterialCellDefDirective,
2903
+ SdMaterialFilterDefDirective,
2904
+ SdMaterialEmptyDataDefDirective,
2905
+ SdMaterialSubInformationDefDirective,
2906
+ ],
2907
+ providers: [
2908
+ DatePipe,
2909
+ DecimalPipe,
2910
+ CdkColumnDef,
2911
+ SdTableFilterService,
2912
+ SdTableConfigurationService,
2913
+ SdColumnValuesPipe,
2914
+ {
2915
+ provide: MatPaginatorIntl,
2916
+ useClass: MatPaginatorIntlCro,
2917
+ },
2918
+ ],
2919
+ },] }
2920
+ ];
2921
+
2922
+ /**
2923
+ * Generated bundle index. Do not edit.
2924
+ */
2925
+
2926
+ export { MatPaginatorIntlCro, SdFilterOperators, SdTable, SdTableModule, SdGridQuickAction as ɵa, SdDesktopCell as ɵb, SdColumnTooltipPipe as ɵba, SdColumnBadgePipe as ɵbb, SdFilterColumnPipe as ɵbc, SdFilterExternalPipe as ɵbd, SdSelectionActionFilterPipe as ɵbe, SdSelectionVisiblePipe as ɵbf, SdSelectionDisablePipe as ɵbg, SdSelectionVisibleSelectAllPipe as ɵbh, SdCellViewPipe as ɵbi, SdGroupPipe as ɵbj, SdDesktopCellView as ɵc, SdDesktopCommand as ɵd, SdColumnInlineFilter as ɵe, SdGridFilter as ɵf, SdPopupFilter as ɵg, SdMaterialSubInformationDefDirective as ɵh, SdMaterialEmptyDataDefDirective as ɵi, SdMaterialCellDefDirective as ɵj, SdMaterialFooterDefDirective as ɵk, SdMaterialFilterDefDirective as ɵl, TABLE_CONFIG as ɵn, SdTableConfigurationService as ɵo, SdColumnValuesPipe as ɵp, SdTableFilterService as ɵq, SdPopupGridConfiguration as ɵr, SdGridConfigurationResultPipe as ɵs, SdColumnChildrenFilterPipe as ɵt, SdCommandFilterPipe as ɵu, SdCommandDisablePipe as ɵv, SdCommandIconPipe as ɵw, SdCommandTitlePipe as ɵx, SdColumnHtmlTemplatePipe as ɵy, SdColumnTransformPipe as ɵz };
2927
+ //# sourceMappingURL=sd-angular-core-table.js.map