@topconsultnpm/sdkui-react 6.20.0-dev2.30 → 6.20.0-dev2.31
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.
|
@@ -26,6 +26,9 @@ export declare class UserSettings {
|
|
|
26
26
|
static LoadSettings(userID: number | undefined, archiveID: string | undefined): UserSettings;
|
|
27
27
|
/** Save settings to local storage or other sources */
|
|
28
28
|
static SaveSettings(settings: UserSettings): void;
|
|
29
|
+
/** Save default settings for properties that don't exist in localStorage yet.*/
|
|
30
|
+
static SaveDefaultSettings(//nosonar
|
|
31
|
+
userID: number | undefined, archiveID: string | undefined, defaultProperties?: string[]): void;
|
|
29
32
|
}
|
|
30
33
|
export declare class DataGridSettings {
|
|
31
34
|
showColumnLines: number;
|
|
@@ -59,6 +59,59 @@ export class UserSettings {
|
|
|
59
59
|
}));
|
|
60
60
|
LocalStorageService.setItem(`userSettings_${settings.archiveID}_${settings.userID}`, JSON.stringify(filteredSettings));
|
|
61
61
|
}
|
|
62
|
+
/** Save default settings for properties that don't exist in localStorage yet.*/
|
|
63
|
+
static SaveDefaultSettings(//nosonar
|
|
64
|
+
userID, archiveID, defaultProperties = ['devSettings.betaFeatures']) {
|
|
65
|
+
if (!userID || !archiveID) {
|
|
66
|
+
throw new Error('User ID and Archive ID are required to save default settings.');
|
|
67
|
+
}
|
|
68
|
+
// Load existing settings from local storage
|
|
69
|
+
const loadedSettings = LocalStorageService.getItem(`userSettings_${archiveID}_${userID}`);
|
|
70
|
+
// If no settings exist yet, save all defaults
|
|
71
|
+
if (!loadedSettings) {
|
|
72
|
+
const defaultSettings = new UserSettings(true);
|
|
73
|
+
const settingsToSave = {
|
|
74
|
+
userID: userID,
|
|
75
|
+
archiveID: archiveID,
|
|
76
|
+
devSettings: defaultSettings.devSettings
|
|
77
|
+
};
|
|
78
|
+
LocalStorageService.setItem(`userSettings_${archiveID}_${userID}`, JSON.stringify(settingsToSave));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Check if any of the default properties are missing
|
|
82
|
+
let needsUpdate = false;
|
|
83
|
+
const defaultSettings = new UserSettings(true);
|
|
84
|
+
for (const propertyPath of defaultProperties) {
|
|
85
|
+
const pathParts = propertyPath.split('.');
|
|
86
|
+
let current = loadedSettings;
|
|
87
|
+
let exists = true;
|
|
88
|
+
// Check if the property exists in loaded settings
|
|
89
|
+
for (const part of pathParts) {
|
|
90
|
+
if (current && typeof current === 'object' && part in current) {
|
|
91
|
+
current = current[part];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
exists = false;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// If property doesn't exist, we need to add it
|
|
99
|
+
if (!exists) {
|
|
100
|
+
needsUpdate = true;
|
|
101
|
+
// Add the missing property from defaults
|
|
102
|
+
const [topLevel] = pathParts;
|
|
103
|
+
if (!loadedSettings[topLevel]) {
|
|
104
|
+
loadedSettings[topLevel] = defaultSettings[topLevel];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Save updated settings if needed
|
|
109
|
+
if (needsUpdate) {
|
|
110
|
+
loadedSettings.userID = userID;
|
|
111
|
+
loadedSettings.archiveID = archiveID;
|
|
112
|
+
LocalStorageService.setItem(`userSettings_${archiveID}_${userID}`, JSON.stringify(loadedSettings));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
62
115
|
}
|
|
63
116
|
export class DataGridSettings {
|
|
64
117
|
constructor() {
|