@sinequa/atomic-angular 1.19.1 → 1.19.2
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.
- package/fesm2022/sinequa-atomic-angular.mjs +52 -3
- package/fesm2022/sinequa-atomic-angular.mjs.map +1 -1
- package/index.d.ts +452 -385
- package/package.json +1 -1
|
@@ -18228,6 +18228,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.29", ngImpo
|
|
|
18228
18228
|
`, styles: [":host ul{scrollbar-width:thin}\n"] }]
|
|
18229
18229
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
18230
18230
|
|
|
18231
|
+
/** Whether a value is an object (an array excluded): a structure, which this form cannot edit. */
|
|
18232
|
+
const isPlainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18233
|
+
/**
|
|
18234
|
+
* Normalizes `features.userProfile.customData`, as written in the custom JSON, into a flat list.
|
|
18235
|
+
*
|
|
18236
|
+
* Two entry shapes are accepted and can be mixed:
|
|
18237
|
+
* - `"nickname"` — a property without default;
|
|
18238
|
+
* - `{ "nickname": "none" }` — a property and its default value. An object with several keys declares
|
|
18239
|
+
* one property per key.
|
|
18240
|
+
*
|
|
18241
|
+
* The JSON is read at run time and nothing validates it, so an entry that is neither a string nor a
|
|
18242
|
+
* plain object is dropped, with a warning, rather than thrown on. When a key is declared twice, the
|
|
18243
|
+
* first declaration wins.
|
|
18244
|
+
*/
|
|
18245
|
+
function normalizeCustomData(entries) {
|
|
18246
|
+
const properties = new Map();
|
|
18247
|
+
const add = (key, value) => {
|
|
18248
|
+
if (!key || properties.has(key)) {
|
|
18249
|
+
return;
|
|
18250
|
+
}
|
|
18251
|
+
properties.set(key, value === undefined || value === null ? { key } : { key, defaultValue: value });
|
|
18252
|
+
};
|
|
18253
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
18254
|
+
if (typeof entry === "string") {
|
|
18255
|
+
add(entry);
|
|
18256
|
+
}
|
|
18257
|
+
else if (isPlainObject(entry)) {
|
|
18258
|
+
Object.entries(entry).forEach(([key, value]) => add(key, value));
|
|
18259
|
+
}
|
|
18260
|
+
else {
|
|
18261
|
+
console.warn("[user-profile] customData: entry ignored, expected a string or an object.", entry);
|
|
18262
|
+
}
|
|
18263
|
+
}
|
|
18264
|
+
return [...properties.values()];
|
|
18265
|
+
}
|
|
18266
|
+
|
|
18231
18267
|
const SUPPORTED_LANGUAGES = ["en", "fr", "de"];
|
|
18232
18268
|
class UserProfileFormComponent {
|
|
18233
18269
|
principalStore = inject(PrincipalStore);
|
|
@@ -18258,7 +18294,17 @@ class UserProfileFormComponent {
|
|
|
18258
18294
|
{ code: "de", label: "Deutsch", icon: FlagGermanIcon }
|
|
18259
18295
|
];
|
|
18260
18296
|
changingPassword = signal(false, ...(ngDevMode ? [{ debugName: "changingPassword" }] : []));
|
|
18261
|
-
|
|
18297
|
+
customDataConfig = computed(() => normalizeCustomData(this.appStore.general()?.features?.userProfile?.customData), ...(ngDevMode ? [{ debugName: "customDataConfig" }] : []));
|
|
18298
|
+
/**
|
|
18299
|
+
* The editable custom properties. A property that already holds an object in the profile (hierarchical
|
|
18300
|
+
* `customData`) is left out: this form edits scalars only and would overwrite the structure.
|
|
18301
|
+
*/
|
|
18302
|
+
customData = computed(() => {
|
|
18303
|
+
const stored = this.userProfile()?.customData;
|
|
18304
|
+
return this.customDataConfig()
|
|
18305
|
+
.map(({ key }) => key)
|
|
18306
|
+
.filter(key => !this.keys().some(k => k.toLowerCase() === key.toLowerCase()) && !isPlainObject(stored?.[key]));
|
|
18307
|
+
}, ...(ngDevMode ? [{ debugName: "customData" }] : []));
|
|
18262
18308
|
allowChangePassword = computed(() => {
|
|
18263
18309
|
const { useCredentials } = globalConfig;
|
|
18264
18310
|
const { allowChangePassword = false } = this.appStore.general()?.features || {};
|
|
@@ -18308,8 +18354,7 @@ class UserProfileFormComponent {
|
|
|
18308
18354
|
* @param propertyName property name
|
|
18309
18355
|
*/
|
|
18310
18356
|
onEdit(category, propertyName) {
|
|
18311
|
-
const
|
|
18312
|
-
const value = data?.[propertyName];
|
|
18357
|
+
const value = this.getDataValue(category, propertyName);
|
|
18313
18358
|
this.feedback.set(undefined);
|
|
18314
18359
|
this.value.set(value?.trim() || "");
|
|
18315
18360
|
this.propertyToEdit.set(`${category}.${propertyName}`);
|
|
@@ -18420,6 +18465,10 @@ class UserProfileFormComponent {
|
|
|
18420
18465
|
getDataValue(category, key) {
|
|
18421
18466
|
const data = this.userProfile()?.[category];
|
|
18422
18467
|
const value = data?.[key];
|
|
18468
|
+
if (value === undefined && category === "customData") {
|
|
18469
|
+
const defaultValue = this.customDataConfig().find(property => property.key === key)?.defaultValue;
|
|
18470
|
+
return defaultValue === undefined || typeof defaultValue === "object" ? undefined : String(defaultValue);
|
|
18471
|
+
}
|
|
18423
18472
|
return value;
|
|
18424
18473
|
}
|
|
18425
18474
|
/**
|