@shival99/z-ui 2.0.45 → 2.0.46
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.
|
@@ -7054,7 +7054,7 @@ class ZTableComponent {
|
|
|
7054
7054
|
showVerticalBorder: this.showVerticalBorder(),
|
|
7055
7055
|
};
|
|
7056
7056
|
try {
|
|
7057
|
-
ZCacheService.set(
|
|
7057
|
+
ZCacheService.set(this._getConfigCacheKey(key), config);
|
|
7058
7058
|
}
|
|
7059
7059
|
catch (error) {
|
|
7060
7060
|
console.error('Failed to save table config:', error);
|
|
@@ -7083,12 +7083,22 @@ class ZTableComponent {
|
|
|
7083
7083
|
return false;
|
|
7084
7084
|
}
|
|
7085
7085
|
try {
|
|
7086
|
-
const
|
|
7086
|
+
const cacheKey = this._getConfigCacheKey(key);
|
|
7087
|
+
let config = ZCacheService.get(cacheKey);
|
|
7088
|
+
if (!config) {
|
|
7089
|
+
const legacyCacheKey = `table-config-${key}`;
|
|
7090
|
+
const legacyConfig = ZCacheService.get(legacyCacheKey);
|
|
7091
|
+
if (legacyConfig && this._isColumnConfigValid(legacyConfig.columnInfo)) {
|
|
7092
|
+
config = legacyConfig;
|
|
7093
|
+
ZCacheService.set(cacheKey, legacyConfig);
|
|
7094
|
+
ZCacheService.delete(legacyCacheKey);
|
|
7095
|
+
}
|
|
7096
|
+
}
|
|
7087
7097
|
if (!config) {
|
|
7088
7098
|
return false;
|
|
7089
7099
|
}
|
|
7090
7100
|
if (!this._isColumnConfigValid(config.columnInfo)) {
|
|
7091
|
-
ZCacheService.delete(
|
|
7101
|
+
ZCacheService.delete(cacheKey);
|
|
7092
7102
|
return false;
|
|
7093
7103
|
}
|
|
7094
7104
|
if (config.columnOrder && config.columnOrder.length > 0) {
|
|
@@ -7120,6 +7130,20 @@ class ZTableComponent {
|
|
|
7120
7130
|
return false;
|
|
7121
7131
|
}
|
|
7122
7132
|
}
|
|
7133
|
+
_getConfigCacheKey(key) {
|
|
7134
|
+
const collectSchema = (columns) => columns.map(column => [
|
|
7135
|
+
column.id,
|
|
7136
|
+
column.accessorKey ?? '',
|
|
7137
|
+
column.columns ? collectSchema(column.columns) : null,
|
|
7138
|
+
]);
|
|
7139
|
+
const schema = JSON.stringify(collectSchema(this.zConfig().columns ?? []));
|
|
7140
|
+
let fingerprint = 2166136261;
|
|
7141
|
+
for (let index = 0; index < schema.length; index++) {
|
|
7142
|
+
fingerprint ^= schema.charCodeAt(index);
|
|
7143
|
+
fingerprint = Math.imul(fingerprint, 16777619);
|
|
7144
|
+
}
|
|
7145
|
+
return `table-config-${key}-${(fingerprint >>> 0).toString(36)}`;
|
|
7146
|
+
}
|
|
7123
7147
|
/**
|
|
7124
7148
|
* Validates cached column info against current config.
|
|
7125
7149
|
* Returns false if columns have been added/removed/renamed since cache was saved,
|