@acorex/platform 21.0.0-next.44 → 21.0.0-next.45
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/{acorex-platform-common-common-settings.provider-lWz_f-Ia.mjs → acorex-platform-common-common-settings.provider-CsOyxClO.mjs} +17 -3
- package/fesm2022/acorex-platform-common-common-settings.provider-CsOyxClO.mjs.map +1 -0
- package/fesm2022/acorex-platform-common.mjs +204 -164
- package/fesm2022/acorex-platform-common.mjs.map +1 -1
- package/fesm2022/acorex-platform-core.mjs +5 -4
- package/fesm2022/acorex-platform-core.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-entity.mjs +381 -49
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-views.mjs +5 -3
- package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-widget-core.mjs +72 -6
- package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-widgets.mjs +109 -131
- package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-default.mjs +71 -5
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
- package/fesm2022/acorex-platform-workflow.mjs +85 -4
- package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
- package/package.json +1 -1
- package/types/acorex-platform-common.d.ts +64 -47
- package/types/acorex-platform-layout-entity.d.ts +79 -4
- package/types/acorex-platform-layout-widget-core.d.ts +15 -0
- package/types/acorex-platform-layout-widgets.d.ts +15 -19
- package/types/acorex-platform-themes-default.d.ts +6 -0
- package/types/acorex-platform-workflow.d.ts +68 -2
- package/fesm2022/acorex-platform-common-common-settings.provider-lWz_f-Ia.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable } from '@angular/core';
|
|
3
1
|
import { AXPPlatformScope } from '@acorex/platform/core';
|
|
4
2
|
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Injectable } from '@angular/core';
|
|
5
5
|
import { AXPCommonSettings } from './acorex-platform-common.mjs';
|
|
6
6
|
|
|
7
7
|
const I18N = '@general:settings';
|
|
@@ -108,6 +108,20 @@ class AXPCommonSettingProvider {
|
|
|
108
108
|
},
|
|
109
109
|
},
|
|
110
110
|
description: `${I18N}.general.entity.show-page-badge.description`,
|
|
111
|
+
})
|
|
112
|
+
.addSetting({
|
|
113
|
+
key: AXPCommonSettings.ShowRowIndexColumn,
|
|
114
|
+
title: `${I18N}.general.entity.show-row-index-column.title`,
|
|
115
|
+
scope: AXPPlatformScope.User,
|
|
116
|
+
isInherited: true,
|
|
117
|
+
defaultValue: false,
|
|
118
|
+
widget: {
|
|
119
|
+
type: AXPWidgetsCatalog.toggle,
|
|
120
|
+
options: {
|
|
121
|
+
label: null,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
description: `${I18N}.general.entity.show-row-index-column.description`,
|
|
111
125
|
})
|
|
112
126
|
// End the 'Entity Settings' section
|
|
113
127
|
.endSection()
|
|
@@ -122,4 +136,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
122
136
|
}], ctorParameters: () => [{ type: i0.Injector }] });
|
|
123
137
|
|
|
124
138
|
export { AXPCommonSettingProvider };
|
|
125
|
-
//# sourceMappingURL=acorex-platform-common-common-settings.provider-
|
|
139
|
+
//# sourceMappingURL=acorex-platform-common-common-settings.provider-CsOyxClO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-common-common-settings.provider-CsOyxClO.mjs","sources":["../../../../libs/platform/common/src/lib/configs/common-settings.provider.ts"],"sourcesContent":["import { AXPPlatformScope } from '@acorex/platform/core';\nimport { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';\nimport { Injectable, Injector } from '@angular/core';\nimport { AXPSettingDefinitionProvider, AXPSettingDefinitionProviderContext } from '../settings';\nimport { AXPCommonSettings } from './common-settings.key';\n\nconst I18N = '@general:settings';\n\n@Injectable()\nexport class AXPCommonSettingProvider implements AXPSettingDefinitionProvider {\n constructor(private _injector: Injector) {}\n\n async provide(context: AXPSettingDefinitionProviderContext): Promise<void> {\n // Define the 'General Settings' group\n context\n .group('general')\n ?.addSection('notifications', `${I18N}.general.notifications.title`, `${I18N}.general.notifications.description`)\n // Add the 'Enable Operation Toasts' setting\n .addSetting({\n key: AXPCommonSettings.EnableOperationToasts,\n title: `${I18N}.general.notifications.enable-operation-toasts.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: true,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n\n description: `${I18N}.general.notifications.enable-operation-toasts.description`,\n })\n\n // End the 'Notifications' section\n .endSection()\n .addSection('entity', `${I18N}.general.entity.title`, `${I18N}.general.entity.description`)\n // Add the 'Enable Operation Toasts' setting\n .addSetting({\n key: AXPCommonSettings.EntityFilterApplyMode,\n title: `${I18N}.general.entity.filter-apply-mode.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: 'auto',\n widget: {\n type: AXPWidgetsCatalog.select,\n options: {\n label: null,\n valueField: 'value',\n textField: 'text',\n dataSource: [\n { value: 'auto', text: `${I18N}.general.entity.filter-apply-mode.options.auto` },\n { value: 'manual', text: `${I18N}.general.entity.filter-apply-mode.options.manual` },\n ],\n },\n },\n\n description: `${I18N}.general.entity.filter-apply-mode.description`,\n })\n .addSetting({\n key: AXPCommonSettings.ShowCategoryColumnsByDefault,\n title: `${I18N}.general.entity.show-category-columns-by-default.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: false,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n description: `${I18N}.general.entity.show-category-columns-by-default.description`,\n })\n .addSetting({\n key: AXPCommonSettings.ApplyLayoutOrdering,\n title: `${I18N}.general.entity.apply-layout-ordering.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: true,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n description: `${I18N}.general.entity.apply-layout-ordering.description`,\n })\n .addSetting({\n key: AXPCommonSettings.RedirectToDetailsAfterCreate,\n title: `${I18N}.general.entity.redirect-to-details-after-create.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: true,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n description: `${I18N}.general.entity.redirect-to-details-after-create.description`,\n })\n .addSetting({\n key: AXPCommonSettings.ShowPageBadge,\n title: `${I18N}.general.entity.show-page-badge.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: true,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n description: `${I18N}.general.entity.show-page-badge.description`,\n })\n .addSetting({\n key: AXPCommonSettings.ShowRowIndexColumn,\n title: `${I18N}.general.entity.show-row-index-column.title`,\n scope: AXPPlatformScope.User,\n isInherited: true,\n defaultValue: false,\n widget: {\n type: AXPWidgetsCatalog.toggle,\n options: {\n label: null,\n },\n },\n description: `${I18N}.general.entity.show-row-index-column.description`,\n })\n\n // End the 'Entity Settings' section\n .endSection()\n // End the 'General Settings' group\n .endGroup();\n }\n}\n"],"names":[],"mappings":";;;;;;AAMA,MAAM,IAAI,GAAG,mBAAmB;MAGnB,wBAAwB,CAAA;AACnC,IAAA,WAAA,CAAoB,SAAmB,EAAA;QAAnB,IAAA,CAAA,SAAS,GAAT,SAAS;IAAa;IAE1C,MAAM,OAAO,CAAC,OAA4C,EAAA;;QAExD;aACG,KAAK,CAAC,SAAS;cACd,UAAU,CAAC,eAAe,EAAE,CAAA,EAAG,IAAI,CAAA,4BAAA,CAA8B,EAAE,CAAA,EAAG,IAAI,CAAA,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
|
@@ -239,154 +239,6 @@ var AXPRegionalSetting;
|
|
|
239
239
|
AXPRegionalSetting["MultiLanguageSupport"] = "LocaleManagement:Setting:Regional.MultiLanguageSupport";
|
|
240
240
|
})(AXPRegionalSetting || (AXPRegionalSetting = {}));
|
|
241
241
|
|
|
242
|
-
//#region ---- Imports ----
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region ---- Kind inference ----
|
|
245
|
-
/**
|
|
246
|
-
* If the payload uses the common `{ value: T }` shape from setting widgets, returns the inner value; otherwise returns `raw`.
|
|
247
|
-
*/
|
|
248
|
-
function peelSettingValueKey(raw) {
|
|
249
|
-
return unwrapValueProperty(raw);
|
|
250
|
-
}
|
|
251
|
-
function coercionKindFromScalarSample(v) {
|
|
252
|
-
if (v === null || v === undefined) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
if (typeof v === 'boolean') {
|
|
256
|
-
return 'boolean';
|
|
257
|
-
}
|
|
258
|
-
if (typeof v === 'number' && Number.isFinite(v)) {
|
|
259
|
-
return 'number';
|
|
260
|
-
}
|
|
261
|
-
if (v instanceof Date) {
|
|
262
|
-
return 'date';
|
|
263
|
-
}
|
|
264
|
-
if (typeof v === 'string') {
|
|
265
|
-
if (v === 'true' || v === 'false') {
|
|
266
|
-
return 'boolean';
|
|
267
|
-
}
|
|
268
|
-
return 'string';
|
|
269
|
-
}
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Picks a primitive coercion kind from the setting definition default and/or the effective stored value.
|
|
274
|
-
* Type argument `T` on the settings service `get` method is compile-time only; runtime behavior follows this inference.
|
|
275
|
-
*/
|
|
276
|
-
function inferSettingCoercionKind(defaultSample, effective) {
|
|
277
|
-
const fromDefault = coercionKindFromScalarSample(defaultSample);
|
|
278
|
-
if (fromDefault) {
|
|
279
|
-
return fromDefault;
|
|
280
|
-
}
|
|
281
|
-
return coercionKindFromScalarSample(unwrapValueProperty(effective));
|
|
282
|
-
}
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region ---- Value coercion ----
|
|
285
|
-
function coerceAXPSettingRawValueByKind(raw, kind) {
|
|
286
|
-
switch (kind) {
|
|
287
|
-
case 'string':
|
|
288
|
-
return coerceUnknownToTrimmedString(raw);
|
|
289
|
-
case 'boolean':
|
|
290
|
-
return coerceUnknownToBoolean(raw);
|
|
291
|
-
case 'number':
|
|
292
|
-
return coerceUnknownToFiniteNumber(raw);
|
|
293
|
-
case 'date':
|
|
294
|
-
return coerceUnknownToDate(raw);
|
|
295
|
-
default: {
|
|
296
|
-
const _exhaustive = kind;
|
|
297
|
-
return _exhaustive;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function coerceAXPSettingRawValue(raw, kind) {
|
|
302
|
-
return coerceAXPSettingRawValueByKind(raw, kind);
|
|
303
|
-
}
|
|
304
|
-
//#endregion
|
|
305
|
-
|
|
306
|
-
const AXP_SETTING_VALUE_PROVIDER = new InjectionToken('AXP_SETTING_VALUE_PROVIDER', {
|
|
307
|
-
providedIn: 'root',
|
|
308
|
-
factory: () => {
|
|
309
|
-
const injector = inject(Injector);
|
|
310
|
-
return [
|
|
311
|
-
new AXPSettingValueProviderDefault(AXPPlatformScope.Platform, injector),
|
|
312
|
-
new AXPSettingValueProviderDefault(AXPPlatformScope.Tenant, injector),
|
|
313
|
-
new AXPSettingValueProviderDefault(AXPPlatformScope.User, injector)
|
|
314
|
-
];
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
class AXPSettingValueProviderDefault {
|
|
318
|
-
constructor(_scope, injector) {
|
|
319
|
-
this._scope = _scope;
|
|
320
|
-
this.injector = injector;
|
|
321
|
-
this.cache = new Map();
|
|
322
|
-
this.localStorageKey = null;
|
|
323
|
-
this.sessionService = this.injector.get(AXPSessionService);
|
|
324
|
-
// Platform scope doesn't depend on session, initialize immediately
|
|
325
|
-
if (this.scope === AXPPlatformScope.Platform) {
|
|
326
|
-
this.localStorageKey = `AXP_SETTINGS_SCOPE(P)`;
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
this.sessionService.status$.subscribe((status) => {
|
|
330
|
-
if (status === AXPSessionStatus.Authorized || status === AXPSessionStatus.Authenticated) {
|
|
331
|
-
if (this.scope === AXPPlatformScope.User) {
|
|
332
|
-
this.localStorageKey = `AXP_SETTINGS_SCOPE(${this.sessionService.user?.id ?? 'U'})`;
|
|
333
|
-
}
|
|
334
|
-
else if (this.scope === AXPPlatformScope.Tenant) {
|
|
335
|
-
this.localStorageKey = `AXP_SETTINGS_SCOPE(${this.sessionService.tenant?.id ?? 'T'})`;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
get scope() {
|
|
342
|
-
return this._scope;
|
|
343
|
-
}
|
|
344
|
-
async load() {
|
|
345
|
-
if (!this.localStorageKey) {
|
|
346
|
-
return Promise.resolve([]);
|
|
347
|
-
}
|
|
348
|
-
// Load settings from localStorage as a single key
|
|
349
|
-
const storedSettings = localStorage.getItem(this.localStorageKey);
|
|
350
|
-
if (storedSettings) {
|
|
351
|
-
const parsedSettings = JSON.parse(storedSettings);
|
|
352
|
-
Object.entries(parsedSettings).forEach(([key, value]) => {
|
|
353
|
-
this.cache.set(key, value);
|
|
354
|
-
});
|
|
355
|
-
return Promise.resolve(Array.from(this.cache.entries()).map(c => ({ key: c[0], value: c[1] })));
|
|
356
|
-
}
|
|
357
|
-
return Promise.resolve([]);
|
|
358
|
-
}
|
|
359
|
-
async set(keyOrValues, value) {
|
|
360
|
-
if (typeof keyOrValues === 'string') {
|
|
361
|
-
// Single value update
|
|
362
|
-
this.cache.set(keyOrValues, value);
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
// Bulk update
|
|
366
|
-
for (const [key, val] of Object.entries(keyOrValues)) {
|
|
367
|
-
this.cache.set(key, val);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
await this.saveToLocalStorage();
|
|
371
|
-
}
|
|
372
|
-
async saveToLocalStorage() {
|
|
373
|
-
if (!this.localStorageKey) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
const settingsObject = {};
|
|
377
|
-
this.cache.forEach((value, key) => {
|
|
378
|
-
settingsObject[key] = value;
|
|
379
|
-
});
|
|
380
|
-
localStorage.setItem(this.localStorageKey, JSON.stringify(settingsObject));
|
|
381
|
-
}
|
|
382
|
-
async clear() {
|
|
383
|
-
if (!this.localStorageKey) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
localStorage.removeItem(this.localStorageKey);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
242
|
class AXPSettingDefinitionProviderContext {
|
|
391
243
|
constructor() {
|
|
392
244
|
this.rootGroups = [];
|
|
@@ -552,7 +404,8 @@ class AXPSettingDefinitionProviderService {
|
|
|
552
404
|
return groups
|
|
553
405
|
.map((group) => ({
|
|
554
406
|
...group,
|
|
555
|
-
sections: group.sections
|
|
407
|
+
sections: group.sections
|
|
408
|
+
.map((section) => ({
|
|
556
409
|
...section,
|
|
557
410
|
settings: section.settings.filter((setting) => {
|
|
558
411
|
const settingScopeIndex = scopeOrder.indexOf(setting.scope);
|
|
@@ -569,7 +422,8 @@ class AXPSettingDefinitionProviderService {
|
|
|
569
422
|
// 3. Exclude settings with a lower or irrelevant scope.
|
|
570
423
|
return false;
|
|
571
424
|
}),
|
|
572
|
-
}))
|
|
425
|
+
}))
|
|
426
|
+
.filter((section) => section.settings.length > 0), // Keep only sections with settings
|
|
573
427
|
groups: filterByScope(group.groups, currentScope), // Recursively filter nested groups
|
|
574
428
|
}))
|
|
575
429
|
.filter((group) => group.sections.length > 0 || group.groups.length > 0); // Keep groups with valid sections or nested groups
|
|
@@ -596,12 +450,33 @@ class AXPSettingDefinitionProviderService {
|
|
|
596
450
|
collectDefaults(this.cache);
|
|
597
451
|
return defaults;
|
|
598
452
|
}
|
|
453
|
+
async settingScopeByKey() {
|
|
454
|
+
const scopes = {};
|
|
455
|
+
const collect = (groups) => {
|
|
456
|
+
groups.forEach((group) => {
|
|
457
|
+
group.sections.forEach((section) => {
|
|
458
|
+
section.settings.forEach((setting) => {
|
|
459
|
+
scopes[setting.name] = setting.scope;
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
collect(group.groups);
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
if (!this.cache) {
|
|
466
|
+
await this.load();
|
|
467
|
+
}
|
|
468
|
+
collect(this.cache);
|
|
469
|
+
return scopes;
|
|
470
|
+
}
|
|
599
471
|
findGroup(scope, groupName) {
|
|
600
472
|
return this.searchRecursive(this.getList(scope), groupName, []); // Initialize with an empty breadcrumb
|
|
601
473
|
}
|
|
602
474
|
searchRecursive(groups, groupName, breadcrumb) {
|
|
603
475
|
for (const group of groups) {
|
|
604
|
-
const currentBreadcrumb = [
|
|
476
|
+
const currentBreadcrumb = [
|
|
477
|
+
...breadcrumb,
|
|
478
|
+
{ name: group.name, title: group.title, description: group.description },
|
|
479
|
+
];
|
|
605
480
|
// If the group name matches, return its details
|
|
606
481
|
if (group.name === groupName) {
|
|
607
482
|
return {
|
|
@@ -620,7 +495,7 @@ class AXPSettingDefinitionProviderService {
|
|
|
620
495
|
return {
|
|
621
496
|
breadcrumb: [],
|
|
622
497
|
groups: [],
|
|
623
|
-
sections: []
|
|
498
|
+
sections: [],
|
|
624
499
|
};
|
|
625
500
|
}
|
|
626
501
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPSettingDefinitionProviderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -664,6 +539,154 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
664
539
|
args: [{ providedIn: 'root' }]
|
|
665
540
|
}] });
|
|
666
541
|
|
|
542
|
+
//#region ---- Imports ----
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region ---- Kind inference ----
|
|
545
|
+
/**
|
|
546
|
+
* If the payload uses the common `{ value: T }` shape from setting widgets, returns the inner value; otherwise returns `raw`.
|
|
547
|
+
*/
|
|
548
|
+
function peelSettingValueKey(raw) {
|
|
549
|
+
return unwrapValueProperty(raw);
|
|
550
|
+
}
|
|
551
|
+
function coercionKindFromScalarSample(v) {
|
|
552
|
+
if (v === null || v === undefined) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
if (typeof v === 'boolean') {
|
|
556
|
+
return 'boolean';
|
|
557
|
+
}
|
|
558
|
+
if (typeof v === 'number' && Number.isFinite(v)) {
|
|
559
|
+
return 'number';
|
|
560
|
+
}
|
|
561
|
+
if (v instanceof Date) {
|
|
562
|
+
return 'date';
|
|
563
|
+
}
|
|
564
|
+
if (typeof v === 'string') {
|
|
565
|
+
if (v === 'true' || v === 'false') {
|
|
566
|
+
return 'boolean';
|
|
567
|
+
}
|
|
568
|
+
return 'string';
|
|
569
|
+
}
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Picks a primitive coercion kind from the setting definition default and/or the effective stored value.
|
|
574
|
+
* Type argument `T` on the settings service `get` method is compile-time only; runtime behavior follows this inference.
|
|
575
|
+
*/
|
|
576
|
+
function inferSettingCoercionKind(defaultSample, effective) {
|
|
577
|
+
const fromDefault = coercionKindFromScalarSample(defaultSample);
|
|
578
|
+
if (fromDefault) {
|
|
579
|
+
return fromDefault;
|
|
580
|
+
}
|
|
581
|
+
return coercionKindFromScalarSample(unwrapValueProperty(effective));
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region ---- Value coercion ----
|
|
585
|
+
function coerceAXPSettingRawValueByKind(raw, kind) {
|
|
586
|
+
switch (kind) {
|
|
587
|
+
case 'string':
|
|
588
|
+
return coerceUnknownToTrimmedString(raw);
|
|
589
|
+
case 'boolean':
|
|
590
|
+
return coerceUnknownToBoolean(raw);
|
|
591
|
+
case 'number':
|
|
592
|
+
return coerceUnknownToFiniteNumber(raw);
|
|
593
|
+
case 'date':
|
|
594
|
+
return coerceUnknownToDate(raw);
|
|
595
|
+
default: {
|
|
596
|
+
const _exhaustive = kind;
|
|
597
|
+
return _exhaustive;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function coerceAXPSettingRawValue(raw, kind) {
|
|
602
|
+
return coerceAXPSettingRawValueByKind(raw, kind);
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
|
|
606
|
+
const AXP_SETTING_VALUE_PROVIDER = new InjectionToken('AXP_SETTING_VALUE_PROVIDER', {
|
|
607
|
+
providedIn: 'root',
|
|
608
|
+
factory: () => {
|
|
609
|
+
const injector = inject(Injector);
|
|
610
|
+
return [
|
|
611
|
+
new AXPSettingValueProviderDefault(AXPPlatformScope.Platform, injector),
|
|
612
|
+
new AXPSettingValueProviderDefault(AXPPlatformScope.Tenant, injector),
|
|
613
|
+
new AXPSettingValueProviderDefault(AXPPlatformScope.User, injector),
|
|
614
|
+
];
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
class AXPSettingValueProviderDefault {
|
|
618
|
+
constructor(_scope, injector) {
|
|
619
|
+
this._scope = _scope;
|
|
620
|
+
this.injector = injector;
|
|
621
|
+
this.cache = new Map();
|
|
622
|
+
this.localStorageKey = null;
|
|
623
|
+
this.sessionService = this.injector.get(AXPSessionService);
|
|
624
|
+
// Platform scope doesn't depend on session, initialize immediately
|
|
625
|
+
if (this.scope === AXPPlatformScope.Platform) {
|
|
626
|
+
this.localStorageKey = `AXP_SETTINGS_SCOPE(P)`;
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
this.sessionService.status$.subscribe((status) => {
|
|
630
|
+
if (status === AXPSessionStatus.Authorized || status === AXPSessionStatus.Authenticated) {
|
|
631
|
+
if (this.scope === AXPPlatformScope.User) {
|
|
632
|
+
this.localStorageKey = `AXP_SETTINGS_SCOPE(${this.sessionService.user?.id ?? 'U'})`;
|
|
633
|
+
}
|
|
634
|
+
else if (this.scope === AXPPlatformScope.Tenant) {
|
|
635
|
+
this.localStorageKey = `AXP_SETTINGS_SCOPE(${this.sessionService.tenant?.id ?? 'T'})`;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
get scope() {
|
|
642
|
+
return this._scope;
|
|
643
|
+
}
|
|
644
|
+
async load() {
|
|
645
|
+
if (!this.localStorageKey) {
|
|
646
|
+
return Promise.resolve([]);
|
|
647
|
+
}
|
|
648
|
+
// Load settings from localStorage as a single key
|
|
649
|
+
const storedSettings = localStorage.getItem(this.localStorageKey);
|
|
650
|
+
if (storedSettings) {
|
|
651
|
+
const parsedSettings = JSON.parse(storedSettings);
|
|
652
|
+
Object.entries(parsedSettings).forEach(([key, value]) => {
|
|
653
|
+
this.cache.set(key, value);
|
|
654
|
+
});
|
|
655
|
+
return Promise.resolve(Array.from(this.cache.entries()).map((c) => ({ key: c[0], value: c[1] })));
|
|
656
|
+
}
|
|
657
|
+
return Promise.resolve([]);
|
|
658
|
+
}
|
|
659
|
+
async set(keyOrValues, value) {
|
|
660
|
+
if (typeof keyOrValues === 'string') {
|
|
661
|
+
// Single value update
|
|
662
|
+
this.cache.set(keyOrValues, value);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
// Bulk update
|
|
666
|
+
for (const [key, val] of Object.entries(keyOrValues)) {
|
|
667
|
+
this.cache.set(key, val);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
await this.saveToLocalStorage();
|
|
671
|
+
}
|
|
672
|
+
async saveToLocalStorage() {
|
|
673
|
+
if (!this.localStorageKey) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const settingsObject = {};
|
|
677
|
+
this.cache.forEach((value, key) => {
|
|
678
|
+
settingsObject[key] = value;
|
|
679
|
+
});
|
|
680
|
+
localStorage.setItem(this.localStorageKey, JSON.stringify(settingsObject));
|
|
681
|
+
}
|
|
682
|
+
async clear() {
|
|
683
|
+
if (!this.localStorageKey) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
localStorage.removeItem(this.localStorageKey);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
667
690
|
class AXPSettingsService {
|
|
668
691
|
constructor() {
|
|
669
692
|
this.providers = inject(AXP_SETTING_VALUE_PROVIDER);
|
|
@@ -674,11 +697,7 @@ class AXPSettingsService {
|
|
|
674
697
|
this.onChanged = new Subject();
|
|
675
698
|
this.onLoaded = new Subject();
|
|
676
699
|
// Initialize scoped caches for dynamic scopes
|
|
677
|
-
const staticScopes = [
|
|
678
|
-
AXPPlatformScope.Platform,
|
|
679
|
-
AXPPlatformScope.Tenant,
|
|
680
|
-
AXPPlatformScope.User,
|
|
681
|
-
];
|
|
700
|
+
const staticScopes = [AXPPlatformScope.Platform, AXPPlatformScope.Tenant, AXPPlatformScope.User];
|
|
682
701
|
staticScopes.forEach((scope) => {
|
|
683
702
|
if (!this.scopedSettingsCache.has(scope)) {
|
|
684
703
|
this.scopedSettingsCache.set(scope, new Map());
|
|
@@ -713,6 +732,7 @@ class AXPSettingsService {
|
|
|
713
732
|
});
|
|
714
733
|
settingsList.push(...providerSettings);
|
|
715
734
|
}
|
|
735
|
+
await this.seedMissingDefaults();
|
|
716
736
|
this.onLoaded.next();
|
|
717
737
|
return settingsList;
|
|
718
738
|
}
|
|
@@ -759,11 +779,7 @@ class AXPSettingsService {
|
|
|
759
779
|
return { effective: defaultSample, defaultSample };
|
|
760
780
|
}
|
|
761
781
|
async defaultValues(scope) {
|
|
762
|
-
let scopeOrder = [
|
|
763
|
-
AXPPlatformScope.Platform,
|
|
764
|
-
AXPPlatformScope.Tenant,
|
|
765
|
-
AXPPlatformScope.User,
|
|
766
|
-
].reverse();
|
|
782
|
+
let scopeOrder = [AXPPlatformScope.Platform, AXPPlatformScope.Tenant, AXPPlatformScope.User].reverse();
|
|
767
783
|
const scopeIndex = scopeOrder.indexOf(scope);
|
|
768
784
|
if (scopeIndex === -1) {
|
|
769
785
|
throw new Error(`Invalid scope: ${scope}`);
|
|
@@ -797,6 +813,29 @@ class AXPSettingsService {
|
|
|
797
813
|
this.onChanged.next(event);
|
|
798
814
|
this.eventService.publish('AXPSettingChangedEvent', event);
|
|
799
815
|
}
|
|
816
|
+
async seedMissingDefaults() {
|
|
817
|
+
const definitionService = this.injector.get(AXPSettingDefinitionProviderService);
|
|
818
|
+
const aggregator = this.injector.get(AXPSettingDefaultValuesAggregatorService);
|
|
819
|
+
const [defaults, scopeByKey] = await Promise.all([aggregator.getDefaults(), definitionService.settingScopeByKey()]);
|
|
820
|
+
const persistedKeysByScope = new Map(await Promise.all(this.providers.map(async (provider) => {
|
|
821
|
+
const stored = await provider.load();
|
|
822
|
+
return [provider.scope, new Set(stored.map((s) => s.key))];
|
|
823
|
+
})));
|
|
824
|
+
const toPersist = {};
|
|
825
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
826
|
+
const scope = scopeByKey[key];
|
|
827
|
+
if (!scope || value === undefined || persistedKeysByScope.get(scope)?.has(key)) {
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
toPersist[scope] ??= {};
|
|
831
|
+
toPersist[scope][key] = value;
|
|
832
|
+
}
|
|
833
|
+
for (const [scope, values] of Object.entries(toPersist)) {
|
|
834
|
+
if (Object.keys(values).length > 0) {
|
|
835
|
+
await this.scope(scope).set(values);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
800
839
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPSettingsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
801
840
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPSettingsService, providedIn: 'root' }); }
|
|
802
841
|
}
|
|
@@ -3186,6 +3225,7 @@ var AXPCommonSettings;
|
|
|
3186
3225
|
AXPCommonSettings["RedirectToDetailsAfterCreate"] = "Common:Setting:Entity.RedirectToDetailsAfterCreate";
|
|
3187
3226
|
AXPCommonSettings["ShowPageBadge"] = "Common:Setting:Entity.ShowPageBadge";
|
|
3188
3227
|
AXPCommonSettings["DebugMode"] = "PlatformDevTools:Setting:Developer.DebugMode";
|
|
3228
|
+
AXPCommonSettings["ShowRowIndexColumn"] = "Common:Setting:Entity.ShowRowIndexColumn";
|
|
3189
3229
|
})(AXPCommonSettings || (AXPCommonSettings = {}));
|
|
3190
3230
|
|
|
3191
3231
|
//TODO Loading, Redirect, Drawer, Show toast
|
|
@@ -3431,7 +3471,7 @@ class AXPCommonModule {
|
|
|
3431
3471
|
provide: AXP_SETTING_DEFINITION_PROVIDER,
|
|
3432
3472
|
useFactory: async () => {
|
|
3433
3473
|
const injector = inject(Injector);
|
|
3434
|
-
const provider = (await import('./acorex-platform-common-common-settings.provider-
|
|
3474
|
+
const provider = (await import('./acorex-platform-common-common-settings.provider-CsOyxClO.mjs')).AXPCommonSettingProvider;
|
|
3435
3475
|
return new provider(injector);
|
|
3436
3476
|
},
|
|
3437
3477
|
multi: true,
|
|
@@ -3511,7 +3551,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
3511
3551
|
provide: AXP_SETTING_DEFINITION_PROVIDER,
|
|
3512
3552
|
useFactory: async () => {
|
|
3513
3553
|
const injector = inject(Injector);
|
|
3514
|
-
const provider = (await import('./acorex-platform-common-common-settings.provider-
|
|
3554
|
+
const provider = (await import('./acorex-platform-common-common-settings.provider-CsOyxClO.mjs')).AXPCommonSettingProvider;
|
|
3515
3555
|
return new provider(injector);
|
|
3516
3556
|
},
|
|
3517
3557
|
multi: true,
|