ng-prime-tools 1.1.4 → 1.1.6
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.
|
@@ -253,9 +253,7 @@ class PTAdvancedPrimeTableComponent {
|
|
|
253
253
|
}
|
|
254
254
|
ngOnInit() {
|
|
255
255
|
this.hasGroupedColumns = this.columns.some((col) => col.children && col.children.length > 0);
|
|
256
|
-
this.globalFilterFields = this.
|
|
257
|
-
.filter((col) => col.code !== undefined && col.isFilter !== false)
|
|
258
|
-
.map((col) => col.code);
|
|
256
|
+
this.globalFilterFields = this.buildGlobalFilterFields();
|
|
259
257
|
this.initializePagination();
|
|
260
258
|
this.initializeActions();
|
|
261
259
|
this.columns.forEach((col) => {
|
|
@@ -275,10 +273,11 @@ class PTAdvancedPrimeTableComponent {
|
|
|
275
273
|
col.isSortable = true;
|
|
276
274
|
if (col.isEditable === undefined)
|
|
277
275
|
col.isEditable = true;
|
|
278
|
-
if (col.isFilter !== false &&
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
276
|
+
if (col.isFilter !== false &&
|
|
277
|
+
col.code !== undefined &&
|
|
278
|
+
col.type !== TableTypeEnum.COMPOSED &&
|
|
279
|
+
!this.globalFilterFields.includes(col.code)) {
|
|
280
|
+
this.globalFilterFields.push(col.code);
|
|
282
281
|
}
|
|
283
282
|
if (!col.width)
|
|
284
283
|
col.width = this.calculateColumnWidth(col);
|
|
@@ -303,6 +302,29 @@ class PTAdvancedPrimeTableComponent {
|
|
|
303
302
|
ngOnDestroy() {
|
|
304
303
|
this.cleanupPointerDrag();
|
|
305
304
|
}
|
|
305
|
+
buildGlobalFilterFields() {
|
|
306
|
+
const fields = [];
|
|
307
|
+
this.columns.forEach((column) => {
|
|
308
|
+
if (!column.code || column.isFilter === false) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (column.type !== TableTypeEnum.COMPOSED) {
|
|
312
|
+
fields.push(column.code);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
column.composedNames?.forEach((composedName, index) => {
|
|
316
|
+
const composedType = column.composedTypes?.[index];
|
|
317
|
+
/*
|
|
318
|
+
* Image URLs, base64 data and other non-text composed values
|
|
319
|
+
* must not participate in the global search.
|
|
320
|
+
*/
|
|
321
|
+
if (composedType === TableTypeEnum.STRING) {
|
|
322
|
+
fields.push(`${column.code}.${composedName}`);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
return fields;
|
|
327
|
+
}
|
|
306
328
|
emitLazyLoad() {
|
|
307
329
|
const payload = {
|
|
308
330
|
page: this.currentPage,
|
|
@@ -677,16 +699,24 @@ class PTAdvancedPrimeTableComponent {
|
|
|
677
699
|
}
|
|
678
700
|
}
|
|
679
701
|
initializeComposedFilters(col) {
|
|
680
|
-
col.composedNames?.forEach((composedName) => {
|
|
681
|
-
const
|
|
682
|
-
|
|
702
|
+
col.composedNames?.forEach((composedName, index) => {
|
|
703
|
+
const composedType = col.composedTypes?.[index];
|
|
704
|
+
/*
|
|
705
|
+
* Only textual composed properties are searchable/filterable.
|
|
706
|
+
* Do not add IMAGE properties such as devise.icon.
|
|
707
|
+
*/
|
|
708
|
+
if (composedType !== TableTypeEnum.STRING) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const code = col.code;
|
|
712
|
+
const composedCode = `${code}.${composedName}`;
|
|
683
713
|
if (!this.globalFilterFields.includes(composedCode)) {
|
|
684
714
|
this.globalFilterFields.push(composedCode);
|
|
685
715
|
}
|
|
686
716
|
this.filters[composedName] = {
|
|
687
717
|
options: col.filterOptions,
|
|
688
718
|
value: [],
|
|
689
|
-
label:
|
|
719
|
+
label: `Filter by ${composedName}`,
|
|
690
720
|
placeholder: 'Select option',
|
|
691
721
|
};
|
|
692
722
|
});
|
|
@@ -1033,27 +1063,30 @@ class PTAdvancedPrimeTableComponent {
|
|
|
1033
1063
|
}
|
|
1034
1064
|
filterGlobal(event) {
|
|
1035
1065
|
const target = event.target;
|
|
1036
|
-
const value =
|
|
1066
|
+
const value = target.value ?? '';
|
|
1037
1067
|
this.searchValue = value;
|
|
1068
|
+
this.resetToFirstPage();
|
|
1038
1069
|
if (this.isLazy) {
|
|
1039
|
-
this.
|
|
1040
|
-
this.search.emit(value);
|
|
1070
|
+
this.search.emit(value.trim());
|
|
1041
1071
|
this.emitLazyLoad();
|
|
1042
1072
|
return;
|
|
1043
1073
|
}
|
|
1044
|
-
this.
|
|
1045
|
-
this.refreshTableData();
|
|
1046
|
-
this.filteredData.emit([...this.tableData]);
|
|
1074
|
+
this.dt?.filterGlobal(value.trim(), 'contains');
|
|
1047
1075
|
}
|
|
1048
|
-
filterComposedColumn(composedData, value) {
|
|
1049
|
-
if (!composedData)
|
|
1076
|
+
filterComposedColumn(composedData, column, value) {
|
|
1077
|
+
if (!composedData) {
|
|
1050
1078
|
return false;
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1079
|
+
}
|
|
1080
|
+
return (column.composedNames?.some((composedName, index) => {
|
|
1081
|
+
const composedType = column.composedTypes?.[index];
|
|
1082
|
+
if (composedType !== TableTypeEnum.STRING) {
|
|
1083
|
+
return false;
|
|
1084
|
+
}
|
|
1085
|
+
const cellValue = composedData?.[composedName];
|
|
1086
|
+
return String(cellValue ?? '')
|
|
1087
|
+
.toLowerCase()
|
|
1088
|
+
.includes(value);
|
|
1089
|
+
}) ?? false);
|
|
1057
1090
|
}
|
|
1058
1091
|
parseAnyDate(input) {
|
|
1059
1092
|
if (input === null || input === undefined || input === '')
|
|
@@ -1189,7 +1222,7 @@ class PTAdvancedPrimeTableComponent {
|
|
|
1189
1222
|
.includes(normalizedValue);
|
|
1190
1223
|
}
|
|
1191
1224
|
if (column.type === TableTypeEnum.COMPOSED) {
|
|
1192
|
-
return this.filterComposedColumn(cell, normalizedValue);
|
|
1225
|
+
return this.filterComposedColumn(cell, column, normalizedValue);
|
|
1193
1226
|
}
|
|
1194
1227
|
return String(cell ?? '')
|
|
1195
1228
|
.toLowerCase()
|