@fuentis/phoenix-ui 0.0.9-alpha.628 → 0.0.9-alpha.630
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.
|
@@ -2965,6 +2965,7 @@ class TableComponent {
|
|
|
2965
2965
|
columnTypeEnum = tableColumnType;
|
|
2966
2966
|
/** Latest active filters coming from table-caption. */
|
|
2967
2967
|
currentFilters = {};
|
|
2968
|
+
SORT_KEY = '';
|
|
2968
2969
|
/** When stale filter values are detected, holds the remaining valid values per key. */
|
|
2969
2970
|
filterValidValues = null;
|
|
2970
2971
|
/**
|
|
@@ -3184,6 +3185,9 @@ class TableComponent {
|
|
|
3184
3185
|
ngOnChanges(changes) {
|
|
3185
3186
|
// clear selection on inputs update (safe default behavior)
|
|
3186
3187
|
this.selectedItems.set([]);
|
|
3188
|
+
if (this.tableConfiguration?.key) {
|
|
3189
|
+
this.SORT_KEY = `sort_${this.tableConfiguration.key}`;
|
|
3190
|
+
}
|
|
3187
3191
|
// Build columnTypeMap for sorting normalization
|
|
3188
3192
|
if (this.columns?.length > 0) {
|
|
3189
3193
|
this.columnTypeMap = {};
|
|
@@ -3224,6 +3228,8 @@ class TableComponent {
|
|
|
3224
3228
|
this.tableData = this.allData;
|
|
3225
3229
|
this.totalRecords = this.tableData.length;
|
|
3226
3230
|
this.lastSortKey = '';
|
|
3231
|
+
if (this.SORT_KEY)
|
|
3232
|
+
localStorage.removeItem(this.SORT_KEY);
|
|
3227
3233
|
this.cdr.markForCheck();
|
|
3228
3234
|
return;
|
|
3229
3235
|
}
|
|
@@ -3231,6 +3237,8 @@ class TableComponent {
|
|
|
3231
3237
|
if (sortKey === this.lastSortKey)
|
|
3232
3238
|
return;
|
|
3233
3239
|
this.lastSortKey = sortKey;
|
|
3240
|
+
if (this.SORT_KEY)
|
|
3241
|
+
localStorage.setItem(this.SORT_KEY, JSON.stringify(meta));
|
|
3234
3242
|
this.runWorkerSort(meta);
|
|
3235
3243
|
}
|
|
3236
3244
|
/**
|
|
@@ -3331,12 +3339,35 @@ class TableComponent {
|
|
|
3331
3339
|
[];
|
|
3332
3340
|
if (!cols.length)
|
|
3333
3341
|
return;
|
|
3334
|
-
// 1)
|
|
3342
|
+
// 1) restore persisted sort (takes precedence over config default)
|
|
3343
|
+
if (this.SORT_KEY) {
|
|
3344
|
+
const stored = localStorage.getItem(this.SORT_KEY);
|
|
3345
|
+
if (stored) {
|
|
3346
|
+
try {
|
|
3347
|
+
const restoredMeta = JSON.parse(stored);
|
|
3348
|
+
const validMeta = restoredMeta.filter((m) => m?.field && cols.some((c) => c?.field === m.field));
|
|
3349
|
+
if (validMeta.length) {
|
|
3350
|
+
try {
|
|
3351
|
+
if (this.dt)
|
|
3352
|
+
this.dt.multiSortMeta = validMeta;
|
|
3353
|
+
}
|
|
3354
|
+
catch { }
|
|
3355
|
+
this.lastSortKey = JSON.stringify(validMeta);
|
|
3356
|
+
this.initialSortApplied = true;
|
|
3357
|
+
this.initialSortFieldApplied = validMeta[0].field;
|
|
3358
|
+
this.runWorkerSort(validMeta);
|
|
3359
|
+
return;
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
catch { }
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
// 2) normalize config
|
|
3335
3366
|
const cfgMeta = this.normalizeInitialSort(this.tableConfiguration);
|
|
3336
|
-
//
|
|
3367
|
+
// 3) if nothing configured -> fallback first column ASC
|
|
3337
3368
|
const fallbackField = cols[0]?.field;
|
|
3338
3369
|
const wantedMeta = (cfgMeta.length ? cfgMeta : [{ field: fallbackField, order: 1 }]).filter((m) => !!m?.field);
|
|
3339
|
-
//
|
|
3370
|
+
// 4) keep only fields that exist in columns
|
|
3340
3371
|
const validMeta = wantedMeta.filter((m) => cols.some((c) => c?.field === m.field));
|
|
3341
3372
|
const finalMeta = validMeta.length
|
|
3342
3373
|
? validMeta
|