@acorex/platform 19.2.20 → 19.3.0-next.0

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.
Files changed (193) hide show
  1. package/common/index.d.ts +1 -0
  2. package/common/lib/app/application.types.d.ts +13 -3
  3. package/common/lib/file-storage/file-storage.types.d.ts +20 -12
  4. package/common/lib/filters/filters.types.d.ts +5 -0
  5. package/common/lib/layout/menu/badge-helper.d.ts +7 -0
  6. package/common/lib/layout/menu/index.d.ts +1 -0
  7. package/common/lib/layout/menu/menu.types.d.ts +1 -0
  8. package/common/lib/layout/task-badge/index.d.ts +2 -0
  9. package/common/lib/layout/task-badge/task-badge.service.d.ts +11 -0
  10. package/common/lib/layout/task-badge/task-badge.type.d.ts +6 -0
  11. package/common/lib/settings/setting-definition.provider.d.ts +7 -5
  12. package/common/lib/settings/setting.builder.d.ts +8 -5
  13. package/common/lib/settings/settings.service.d.ts +6 -5
  14. package/common/lib/settings/settings.types.d.ts +6 -10
  15. package/core/lib/data/index.d.ts +1 -0
  16. package/core/lib/data/value-transformer.d.ts +6 -0
  17. package/core/lib/types/core.types.d.ts +18 -0
  18. package/{layout/entity/lib → core/lib/types}/data.types.d.ts +3 -1
  19. package/core/lib/types/element.types.d.ts +6 -0
  20. package/core/lib/types/index.d.ts +6 -0
  21. package/core/lib/{types.d.ts → types/interactive.types.d.ts} +5 -25
  22. package/core/lib/types/scope.types.d.ts +10 -0
  23. package/core/lib/types/validation.types.d.ts +7 -0
  24. package/core/lib/utils/index.d.ts +1 -0
  25. package/core/lib/utils/object-util.d.ts +3 -0
  26. package/fesm2022/acorex-platform-common.mjs +79 -35
  27. package/fesm2022/acorex-platform-common.mjs.map +1 -1
  28. package/fesm2022/acorex-platform-core.mjs +151 -6
  29. package/fesm2022/acorex-platform-core.mjs.map +1 -1
  30. package/fesm2022/acorex-platform-layout-builder.mjs +44 -55
  31. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  32. package/fesm2022/acorex-platform-layout-designer.mjs +77 -35
  33. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  34. package/fesm2022/acorex-platform-layout-entity.mjs +240 -414
  35. package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
  36. package/fesm2022/acorex-platform-layout-search.mjs +7 -26
  37. package/fesm2022/acorex-platform-layout-search.mjs.map +1 -1
  38. package/fesm2022/acorex-platform-layout-setting.mjs +211 -278
  39. package/fesm2022/acorex-platform-layout-setting.mjs.map +1 -1
  40. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-LKhN00ob.mjs → acorex-platform-themes-default-entity-master-create-view.component-3gmbdeJ_.mjs} +4 -3
  41. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-3gmbdeJ_.mjs.map +1 -0
  42. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DnEL7Ej-.mjs +741 -0
  43. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DnEL7Ej-.mjs.map +1 -0
  44. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-8DdICjNs.mjs +91 -0
  45. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-8DdICjNs.mjs.map +1 -0
  46. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DadBeY1I.mjs +164 -0
  47. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DadBeY1I.mjs.map +1 -0
  48. package/fesm2022/{acorex-platform-themes-default-search-popup.component-BY3oQqbr.mjs → acorex-platform-themes-default-search-popup.component-BADEuoeJ.mjs} +9 -9
  49. package/fesm2022/{acorex-platform-themes-default-search-popup.component-BY3oQqbr.mjs.map → acorex-platform-themes-default-search-popup.component-BADEuoeJ.mjs.map} +1 -1
  50. package/fesm2022/acorex-platform-themes-default-setting-page.component-Cj73brIK.mjs +219 -0
  51. package/fesm2022/acorex-platform-themes-default-setting-page.component-Cj73brIK.mjs.map +1 -0
  52. package/fesm2022/acorex-platform-themes-default-setting-view.component-rrAq6hg2.mjs +103 -0
  53. package/fesm2022/acorex-platform-themes-default-setting-view.component-rrAq6hg2.mjs.map +1 -0
  54. package/fesm2022/acorex-platform-themes-default.mjs +108 -64
  55. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  56. package/fesm2022/acorex-platform-themes-shared-setting.provider-CXiRmniv.mjs +168 -0
  57. package/fesm2022/acorex-platform-themes-shared-setting.provider-CXiRmniv.mjs.map +1 -0
  58. package/fesm2022/acorex-platform-themes-shared.mjs +495 -240
  59. package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
  60. package/fesm2022/acorex-platform-widgets.mjs +4100 -1480
  61. package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
  62. package/layout/builder/lib/builder/builder.service.d.ts +1 -1
  63. package/layout/builder/lib/builder/index.d.ts +2 -1
  64. package/layout/builder/lib/builder/widget-categories.d.ts +10 -0
  65. package/layout/builder/lib/builder/widget-group.types.d.ts +10 -0
  66. package/layout/builder/lib/builder/widget-map.d.ts +8 -1
  67. package/layout/builder/lib/builder/widget-status.types.d.ts +2 -0
  68. package/layout/builder/lib/builder/widget.types.d.ts +11 -27
  69. package/layout/designer/lib/designer/components/widget-picker/widget-picker.component.d.ts +7 -3
  70. package/layout/designer/lib/designer/components/widget-picker/widget-picker.service.d.ts +12 -0
  71. package/layout/designer/lib/designer/index.d.ts +1 -0
  72. package/layout/designer/lib/designer/shared/designer.service.d.ts +1 -0
  73. package/layout/designer/lib/property-viewer/widget-property-viewer.component.d.ts +2 -1
  74. package/layout/entity/lib/entity-data-seeder.d.ts +2 -2
  75. package/layout/entity/lib/entity-master-list.viewmodel.d.ts +4 -7
  76. package/layout/entity/lib/entity-storage-service.d.ts +39 -55
  77. package/layout/entity/lib/entity.types.d.ts +21 -0
  78. package/layout/entity/lib/index.d.ts +1 -2
  79. package/layout/entity/lib/widgets/lookup-widget/index.d.ts +0 -2
  80. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-column.component.d.ts +4 -0
  81. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-edit.component.d.ts +7 -9
  82. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-selector.component.d.ts +5 -2
  83. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-selector.viewmodel.d.ts +11 -3
  84. package/layout/search/lib/search.viewmodel.d.ts +0 -2
  85. package/layout/setting/lib/setting.viewmodel.d.ts +45 -111
  86. package/package.json +5 -5
  87. package/themes/default/lib/layouts/base/base-page.component.d.ts +14 -5
  88. package/themes/default/lib/layouts/base/base-page.types.d.ts +6 -1
  89. package/themes/default/lib/layouts/base/page-layout/page-layout.component.d.ts +5 -4
  90. package/themes/default/lib/layouts/base/simple-page/simple-page.layout.d.ts +2 -2
  91. package/themes/default/lib/layouts/entity-layouts/entity-category/entity-category.component.d.ts +16 -0
  92. package/themes/default/lib/layouts/entity-layouts/entity-detail-list-view/entity-detail-list-view.component.d.ts +2 -2
  93. package/themes/default/lib/layouts/entity-layouts/entity-master-list-view/entity-master-list-view.component.d.ts +10 -8
  94. package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/entity-master-single-view.component.d.ts +12 -4
  95. package/themes/default/lib/layouts/entity-layouts/entity-master-toolbar-view/entity-master-toolbar-view.component.d.ts +7 -0
  96. package/themes/default/lib/layouts/entity-layouts/entity-master-toolbar-view/filters/entity-filter-toolbar.component.d.ts +48 -0
  97. package/themes/default/lib/layouts/entity-layouts/entity-master-toolbar-view/views/entity-view-toolbar.component.d.ts +12 -0
  98. package/themes/default/lib/layouts/root-layout/components/header/header.component.d.ts +2 -2
  99. package/themes/default/lib/layouts/root-layout/components/horizontal-menu/horizontal-menu.component.d.ts +9 -3
  100. package/themes/default/lib/layouts/root-layout/components/side-menu/side-menu.component.d.ts +7 -1
  101. package/themes/default/lib/layouts/root-layout/horizontal/horizontal-layout.component.d.ts +2 -2
  102. package/themes/default/lib/layouts/root-layout/root-layout.component.d.ts +2 -2
  103. package/themes/default/lib/layouts/root-layout/vertical/vertical-layout.component.d.ts +2 -2
  104. package/themes/default/lib/layouts/setting-layout/setting-page/setting-page.component.d.ts +61 -5
  105. package/themes/default/lib/layouts/setting-layout/setting-view/setting-view.component.d.ts +68 -6
  106. package/themes/shared/index.d.ts +1 -0
  107. package/themes/shared/lib/components/badge/badge.directive.d.ts +14 -0
  108. package/themes/shared/lib/components/layout-elements/layout-blocks.component.d.ts +4 -1
  109. package/themes/shared/lib/components/layout-elements/layout-side.component.d.ts +2 -2
  110. package/themes/shared/lib/components/slots/theme-slot.component.d.ts +2 -2
  111. package/themes/shared/lib/palette.provider.d.ts +1 -1
  112. package/themes/shared/lib/setting.keys.d.ts +2 -1
  113. package/themes/shared/lib/setting.provider.d.ts +4 -1
  114. package/themes/shared/lib/theme.service.d.ts +2 -2
  115. package/themes/shared/lib/theme.types.d.ts +11 -2
  116. package/themes/shared/lib/widgets/font-size-chooser/font-size-chooser-widget.component.d.ts +10 -0
  117. package/themes/shared/lib/widgets/font-size-chooser/font-size-chooser-widget.config.d.ts +7 -0
  118. package/themes/shared/lib/widgets/font-size-chooser/index.d.ts +2 -0
  119. package/themes/shared/lib/widgets/font-style-chooser/font-style-chooser-widget.component.d.ts +15 -0
  120. package/themes/shared/lib/widgets/font-style-chooser/font-style-chooser-widget.config.d.ts +7 -0
  121. package/themes/shared/lib/widgets/font-style-chooser/index.d.ts +2 -0
  122. package/themes/shared/lib/widgets/menu-orientation-chooser/index.d.ts +2 -0
  123. package/themes/shared/lib/widgets/menu-orientation-chooser/menu-orientation-chooser-widget.component.d.ts +15 -0
  124. package/themes/shared/lib/widgets/menu-orientation-chooser/menu-orientation-chooser-widget.config.d.ts +7 -0
  125. package/themes/shared/lib/widgets/theme-mode-chooser/index.d.ts +2 -0
  126. package/themes/shared/lib/widgets/theme-mode-chooser/theme-mode-chooser-widget.component.d.ts +16 -0
  127. package/themes/shared/lib/widgets/theme-mode-chooser/theme-mode-chooser-widget.config.d.ts +7 -0
  128. package/themes/shared/lib/widgets/theme-palette-chooser/index.d.ts +2 -0
  129. package/themes/shared/lib/widgets/theme-palette-chooser/theme-palette-chooser-widget.component.d.ts +13 -0
  130. package/themes/shared/lib/widgets/{theme-color-selection/theme-color-selection-widget.config.d.ts → theme-palette-chooser/theme-palette-chooser-widget.config.d.ts} +2 -2
  131. package/widgets/lib/properties/groups.d.ts +2 -0
  132. package/widgets/lib/widgets/advance/file/file-box-widget-edit.component.d.ts +5 -5
  133. package/widgets/lib/widgets/charts/bar-chart/bar-chart-widget.component.d.ts +52 -0
  134. package/widgets/lib/widgets/charts/bar-chart/bar-chart.type.d.ts +29 -11
  135. package/widgets/lib/widgets/charts/bar-chart/index.d.ts +1 -1
  136. package/widgets/lib/widgets/charts/chart.type.d.ts +3 -0
  137. package/widgets/lib/widgets/charts/clock-calendar/clock-calendar-widget.component.d.ts +40 -0
  138. package/widgets/lib/widgets/charts/clock-calendar/clock-calendar-widget.config.d.ts +7 -0
  139. package/widgets/lib/widgets/charts/clock-calendar/clock-calendar.types.d.ts +50 -0
  140. package/widgets/lib/widgets/charts/clock-calendar/index.d.ts +3 -0
  141. package/widgets/lib/widgets/charts/donut-chart/donut-chart-widget.component.d.ts +54 -0
  142. package/widgets/lib/widgets/charts/donut-chart/donut-chart.type.d.ts +31 -21
  143. package/widgets/lib/widgets/charts/donut-chart/index.d.ts +1 -1
  144. package/widgets/lib/widgets/charts/gauge-chart/{gauge-chart-widget-edit.component.d.ts → gauge-chart-widget.component.d.ts} +3 -3
  145. package/widgets/lib/widgets/charts/gauge-chart/gauge-chart.type.d.ts +26 -11
  146. package/widgets/lib/widgets/charts/gauge-chart/index.d.ts +2 -1
  147. package/widgets/lib/widgets/charts/shared/chart-base.component.d.ts +44 -0
  148. package/widgets/lib/widgets/charts/shared/chart-base.type.d.ts +37 -0
  149. package/widgets/lib/widgets/charts/sticky-note/index.d.ts +1 -1
  150. package/widgets/lib/widgets/charts/sticky-note/{sticky-note-widget-edit.component.d.ts → sticky-note-widget.component.d.ts} +3 -3
  151. package/widgets/lib/widgets/charts/weather/index.d.ts +4 -0
  152. package/widgets/lib/widgets/charts/weather/weather-services/index.d.ts +3 -0
  153. package/widgets/lib/widgets/charts/weather/weather-services/weather-api.abstract.d.ts +174 -0
  154. package/widgets/lib/widgets/charts/weather/weather-services/weather-api.key.d.ts +2 -0
  155. package/widgets/lib/widgets/charts/weather/weather-services/weather-api.mock.service.d.ts +47 -0
  156. package/widgets/lib/widgets/charts/weather/weather-services/weather-api.service.d.ts +48 -0
  157. package/widgets/lib/widgets/charts/weather/weather-widget.component.d.ts +109 -0
  158. package/widgets/lib/widgets/charts/weather/weather-widget.config.d.ts +14 -0
  159. package/widgets/lib/widgets/charts/weather/weather.module.d.ts +11 -0
  160. package/widgets/lib/widgets/editors/select/select-box-widget-column.component.d.ts +0 -1
  161. package/widgets/lib/widgets/editors/select/select-box-widget-edit.component.d.ts +4 -1
  162. package/widgets/lib/widgets/editors/template-box/index.d.ts +6 -0
  163. package/widgets/lib/widgets/editors/template-box/template-box-widget-column.component.d.ts +10 -0
  164. package/widgets/lib/widgets/editors/template-box/template-box-widget-edit.component.d.ts +29 -0
  165. package/widgets/lib/widgets/editors/template-box/template-box-widget-filter.component.d.ts +6 -0
  166. package/widgets/lib/widgets/editors/template-box/template-box-widget-print.component.d.ts +10 -0
  167. package/widgets/lib/widgets/editors/template-box/template-box-widget-view.component.d.ts +11 -0
  168. package/widgets/lib/widgets/editors/template-box/template-box-widget.config.d.ts +7 -0
  169. package/widgets/lib/widgets/filters/select-filter/select-filter-widget-edit.component.d.ts +2 -5
  170. package/widgets/lib/widgets/index.d.ts +3 -0
  171. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-LKhN00ob.mjs.map +0 -1
  172. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-BYUOmONk.mjs +0 -400
  173. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-BYUOmONk.mjs.map +0 -1
  174. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-B9TUh-2S.mjs +0 -91
  175. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-B9TUh-2S.mjs.map +0 -1
  176. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-9U774Tr7.mjs +0 -135
  177. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-9U774Tr7.mjs.map +0 -1
  178. package/fesm2022/acorex-platform-themes-default-setting-page.component-_IStMWcu.mjs +0 -74
  179. package/fesm2022/acorex-platform-themes-default-setting-page.component-_IStMWcu.mjs.map +0 -1
  180. package/fesm2022/acorex-platform-themes-default-setting-view.component-CeHpcfsc.mjs +0 -73
  181. package/fesm2022/acorex-platform-themes-default-setting-view.component-CeHpcfsc.mjs.map +0 -1
  182. package/fesm2022/acorex-platform-themes-default-theme-palette-preview.page-D_EkB2k8.mjs +0 -146
  183. package/fesm2022/acorex-platform-themes-default-theme-palette-preview.page-D_EkB2k8.mjs.map +0 -1
  184. package/layout/builder/lib/builder/widget-groups.d.ts +0 -9
  185. package/layout/entity/lib/dexie-storage.service.d.ts +0 -16
  186. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-filter.component.d.ts +0 -6
  187. package/layout/entity/lib/widgets/lookup-widget/lookup-widget-print.component.d.ts +0 -6
  188. package/themes/default/lib/layouts/filters-layout/simple-filter-builder/filters-view.component.d.ts +0 -13
  189. package/themes/default/lib/pages/theme-palette-preview/theme-palette-preview.page.d.ts +0 -85
  190. package/themes/shared/lib/widgets/theme-color-selection/index.d.ts +0 -2
  191. package/themes/shared/lib/widgets/theme-color-selection/theme-color-selection-widget-edit.component.d.ts +0 -6
  192. package/widgets/lib/widgets/charts/bar-chart/bar-chart-widget-edit.component.d.ts +0 -40
  193. package/widgets/lib/widgets/charts/donut-chart/donut-chart-widget-edit.component.d.ts +0 -44
@@ -1,15 +1,15 @@
1
- import { AXDialogService } from '@acorex/components/dialog';
2
- import { AXToastService } from '@acorex/components/toast';
3
1
  import * as i1 from '@acorex/platform/common';
4
- import { AXPSettingScope, AXPSettingDefinitionProviderService, AXPSettingService, AXP_SEARCH_PROVIDER, AXP_SEARCH_DEFINITION_PROVIDER } from '@acorex/platform/common';
5
- import { AXHighlightService } from '@acorex/platform/core';
2
+ import { AXPSettingDefinitionProviderService, AXPSettingService, AXP_SEARCH_PROVIDER, AXP_SEARCH_DEFINITION_PROVIDER } from '@acorex/platform/common';
6
3
  import { AXPPageStatus } from '@acorex/platform/layout/builder';
7
4
  import { AXPLayoutThemeService } from '@acorex/platform/themes/shared';
8
5
  import * as i0 from '@angular/core';
9
- import { inject, signal, computed, effect, Injectable, NgModule } from '@angular/core';
10
- import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
11
- import { isNil, isEmpty, get, isEqual, sortBy } from 'lodash-es';
12
- import { filter, take } from 'rxjs';
6
+ import { computed, inject, NgModule } from '@angular/core';
7
+ import { signalStore, withState, withComputed, withMethods, patchState, withHooks } from '@ngrx/signals';
8
+ import { get, isEqual, isNil, isEmpty, sortBy } from 'lodash-es';
9
+ import { filter } from 'rxjs';
10
+ import { AXToastService } from '@acorex/components/toast';
11
+ import { AXTranslationService } from '@acorex/core/translation';
12
+ import { resolvePlatformScopeName, AXPPlatformScope } from '@acorex/platform/core';
13
13
  import { AXPSessionService } from '@acorex/platform/auth';
14
14
 
15
15
  function searchSettings(groups, search) {
@@ -58,306 +58,239 @@ function searchSettings(groups, search) {
58
58
  return [...sectionMatchResult, ...settingMatchResult];
59
59
  }
60
60
 
61
- class AXPSettingsViewModel {
62
- resolveScopeKey(name) {
63
- const scopeMap = {
64
- environment: AXPSettingScope.Environment,
65
- global: AXPSettingScope.Global,
66
- tenant: AXPSettingScope.Tenant,
67
- user: AXPSettingScope.User,
68
- };
69
- return scopeMap[name.toLowerCase()] ?? AXPSettingScope.User;
70
- }
71
- resolveScope() {
72
- return this.resolveScopeKey(this.scopeName());
73
- }
74
- #effect2;
75
- /**
76
- * @ignore
77
- */
78
- constructor() {
79
- this.router = inject(Router);
80
- this.settingDefinitionService = inject(AXPSettingDefinitionProviderService);
81
- this.settingValueService = inject(AXPSettingService);
82
- this.toastService = inject(AXToastService);
83
- this.dialogService = inject(AXDialogService);
84
- this.highlightService = inject(AXHighlightService);
85
- this.layout = inject(AXPLayoutThemeService);
86
- this.activatedRoute = inject(ActivatedRoute);
87
- this.searchExpression = signal('');
88
- this.isValidQuery = (expression) => !isNil(expression) && !isEmpty(expression);
89
- this.isSearching = computed(() => this.isValidQuery(this.searchExpression()));
90
- this.searchResult = signal([]);
91
- this.isSaving = signal(false);
92
- this.isBusy = signal(false);
93
- this.activateGroup = signal(undefined);
94
- this.activeScope = signal('U');
95
- this.loadedItems = signal(null);
96
- this.scopeName = () => {
97
- return this.activatedRoute?.snapshot?.paramMap?.get('scope')?.trim().toLowerCase() ?? 'user';
98
- };
99
- this.title = computed(() => {
100
- // fake change detect simulate
101
- this.activeScope();
102
- //
103
- return `settings.${this.scopeName()}.title`;
61
+ const AXPSettingsViewModel = signalStore(withState(() => ({
62
+ groups: [],
63
+ activateGroup: undefined,
64
+ scope: 'U',
65
+ //
66
+ searchExpression: null,
67
+ //
68
+ previousContext: {},
69
+ context: {},
70
+ //
71
+ status: AXPPageStatus.Processing,
72
+ form: null,
73
+ })), withComputed((store, layout = inject(AXPLayoutThemeService)) => ({
74
+ searchResults: computed(() => searchSettings(store.groups(), store.searchExpression())),
75
+ hasActivateGroup: computed(() => store.activateGroup() != null),
76
+ showGroups: computed(() => store.activateGroup() != null && layout.isLarge()),
77
+ scopeTitle: computed(() => {
78
+ return `${resolvePlatformScopeName(store.scope())}.title`;
79
+ }),
80
+ scopeDescription: computed(() => {
81
+ return `${resolvePlatformScopeName(store.scope())}.description`;
82
+ }),
83
+ isSearching: computed(() => store.searchExpression() != null),
84
+ isBusy: computed(() => store.status() == AXPPageStatus.Processing),
85
+ isSaving: computed(() => store.status() == AXPPageStatus.Submitting),
86
+ isLoaded: computed(() => store.groups().length > 0),
87
+ })), withMethods((store, settingDefinitionService = inject(AXPSettingDefinitionProviderService), settingValueService = inject(AXPSettingService), toastService = inject(AXToastService), translateService = inject(AXTranslationService)) => ({
88
+ registerForm(form) {
89
+ patchState(store, {
90
+ form: form,
104
91
  });
105
- this.groups = computed(() => {
106
- if (this.activateGroup()) {
107
- return this.settingDefinitionService.findGroup(this.activeScope(), this.activateGroup());
108
- }
109
- else {
110
- return null;
111
- }
92
+ },
93
+ async load(scope) {
94
+ patchState(store, {
95
+ scope: scope,
96
+ status: AXPPageStatus.Processing,
112
97
  });
113
- this.hasGroup = computed(() => this.activateGroup() != null);
114
- this.showSide = computed(() => this.layout.isLarge() && this.hasGroup());
115
- this.#effect2 = effect(() => {
116
- if (this.searchExpression()) {
117
- this.searchResult.set(searchSettings(this.loadedItems(), this.searchExpression()));
118
- }
98
+ //
99
+ const groups = await settingDefinitionService.getListAsync(scope);
100
+ patchState(store, {
101
+ groups: groups,
119
102
  });
120
- this.context = signal({});
121
- this.previousContext = signal({});
122
- this.settingValueService.onChanged.pipe(filter((c) => c.scope == this.resolveScope())).subscribe((e) => {
123
- e.keys.forEach((k) => {
124
- const currentValue = e.values[k];
125
- const contextValue = get(this.context(), k);
126
- const previousValue = get(this.previousContext(), k);
127
- // Update only if there are actual changes
128
- if (!isEqual(previousValue, currentValue) || !isEqual(currentValue, contextValue)) {
129
- this.previousContext.update((prev) => ({
130
- ...prev,
131
- [k]: currentValue, // Use backend-provided value
132
- }));
133
- this.context.update((ctx) => ({
134
- ...ctx,
135
- [k]: currentValue,
136
- }));
137
- }
138
- });
103
+ const currentContext = await settingValueService.scope(scope).all();
104
+ const defaults = await settingValueService.scope(scope).defaultValues();
105
+ patchState(store, {
106
+ context: { ...defaults, ...currentContext },
139
107
  });
140
- this.load();
141
- //
142
- this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(async (event) => {
143
- await this.updateGroupParam();
108
+ patchState(store, {
109
+ previousContext: store.context(),
110
+ status: AXPPageStatus.Rendered,
144
111
  });
145
- }
146
- async load() {
147
- //
148
- this.activeScope.set(this.resolveScope());
149
- //
150
- const items = await this.settingDefinitionService.getListAsync(this.activeScope());
151
- this.loadedItems.set(items);
152
- const currentContext = await this.settingValueService.scope(this.resolveScope()).all();
153
- const defaults = await this.settingValueService.scope(this.resolveScope()).defaultValues();
154
- this.context.set({ ...defaults, ...currentContext });
155
- this.previousContext.set(this.context());
156
- //
157
- await this.updateGroupParam();
158
- if (!this.activateGroup() && this.layout.isLarge() && !this.isSearching()) {
159
- await this.redirectToFirstGroup();
160
- }
161
- }
162
- async updateGroupParam() {
163
- const query = this.activatedRoute.snapshot.queryParams['q'];
164
- const scope = this.resolveScope();
165
- const group = this.activatedRoute.snapshot.paramMap.get('group');
166
- if ((this.activeScope() && this.activeScope() != scope) || this.activateGroup() != group) {
167
- this.activateGroup.set(undefined);
168
- await this.load();
169
- return;
170
- }
171
- if (this.isValidQuery(query)) {
172
- this.searchExpression.set(query);
173
- }
174
- if (this.isSearching()) {
175
- setTimeout(() => {
176
- this.highlightService.highlight('#ax-settings', this.searchExpression());
177
- }, 100);
178
- }
179
- else {
180
- this.highlightService.clear();
181
- }
182
- // If no child routes exist, set activateGroup to undefined
183
- if (this.activatedRoute.children.length === 0) {
184
- this.activateGroup.set(undefined);
185
- return;
186
- }
187
- // Traverse child routes to check for the group parameter
188
- for (const childRoute of this.activatedRoute.children) {
189
- const params = await childRoute.paramMap.pipe(take(1)).toPromise();
190
- const group = params?.get('group');
191
- if (group) {
192
- this.activateGroup.set(group);
193
- }
194
- }
195
- }
196
- async redirectToFirstGroup() {
197
- const firstGroup = this.determineFirstGroup();
198
- if (firstGroup) {
199
- const app = this.activatedRoute.snapshot.params['app'];
200
- const scope = this.activatedRoute.snapshot.params['scope'];
201
- await this.router.navigate([app, 'settings', scope, firstGroup], { replaceUrl: true });
202
- }
203
- }
204
- async navigateUpLevel() {
205
- const func = async () => {
206
- const app = this.activatedRoute.snapshot.params['app'];
207
- const scope = this.activatedRoute.snapshot.params['scope'];
208
- await this.router.navigate([app, 'settings', scope]);
209
- };
210
- if (this.isDirty()) {
211
- const dialogResult = await this.dialogService.confirm('Unsaved Changes', 'You have unsaved changes. Are you sure you want to go back without saving?', 'warning');
212
- if (dialogResult.result) {
213
- await func();
214
- }
215
- }
216
- else {
217
- await func();
218
- }
219
- }
220
- determineFirstGroup() {
221
- const groups = this.loadedItems();
222
- return groups && groups.length > 0 ? groups[0].name : null;
223
- }
224
- handleSelectGroup(item) {
225
- this.router.navigate([`${item.name}`], { relativeTo: this.activatedRoute });
226
- this.searchExpression.set('');
227
- }
228
- async handleContextChanged(e) {
229
- if (e.state == 'initiated') {
230
- this.previousContext.set(e.data);
112
+ },
113
+ async reload() {
114
+ await settingDefinitionService.reload();
115
+ const groups = await settingDefinitionService.getListAsync(store.scope());
116
+ const oldActivateGroupName = store.activateGroup()?.name;
117
+ patchState(store, {
118
+ groups: groups,
119
+ activateGroup: undefined,
120
+ });
121
+ if (oldActivateGroupName) {
122
+ this.setActivateGroupByName(oldActivateGroupName);
231
123
  }
232
- else {
233
- this.context.set(e.data);
124
+ },
125
+ updateContext(context) {
126
+ patchState(store, {
127
+ context: { ...store.context(), ...context },
128
+ });
129
+ },
130
+ updatePreviousContext(context) {
131
+ patchState(store, {
132
+ previousContext: { ...store.previousContext(), ...context },
133
+ });
134
+ },
135
+ setActivateGroup(group) {
136
+ patchState(store, {
137
+ activateGroup: group,
138
+ });
139
+ },
140
+ unloadActivateGroup() {
141
+ patchState(store, {
142
+ activateGroup: undefined,
143
+ });
144
+ },
145
+ setActivateGroupByName(name) {
146
+ const group = store.groups().find(g => g.name === name);
147
+ if (group) {
148
+ patchState(store, {
149
+ activateGroup: group,
150
+ });
234
151
  }
235
- //this.apply();
236
- }
237
- isDirty(section) {
238
- if (section) {
239
- // Check for changes in the specific section
240
- return section.settings.some((c) => !isEqual(get(this.context(), c.name), get(this.previousContext(), c.name)));
152
+ },
153
+ //
154
+ async search(expression) {
155
+ debugger;
156
+ if (!isNil(expression) && !isEmpty(expression)) {
157
+ patchState(store, {
158
+ searchExpression: expression,
159
+ });
241
160
  }
242
161
  else {
243
- // Check for changes globally based on loadedItems keys
244
- return (this.loadedItems()?.some((group) => group.sections.some((sec) => sec.settings.some((setting) => {
245
- const currentValue = get(this.context(), setting.name);
246
- const previousValue = get(this.previousContext(), setting.name);
247
- return !isEqual(currentValue, previousValue);
248
- }))) || false);
162
+ patchState(store, {
163
+ searchExpression: null,
164
+ });
249
165
  }
250
- }
251
- // Save settings logic
252
- async apply(section) {
166
+ },
167
+ clearSearch() {
168
+ patchState(store, {
169
+ searchExpression: null,
170
+ });
171
+ },
172
+ isDirty() {
173
+ return store.groups()?.some((group) => group.sections.some((sec) => sec.settings.some((setting) => {
174
+ const currentValue = get(store.context(), setting.name);
175
+ const previousValue = get(store.previousContext(), setting.name);
176
+ return !isEqual(currentValue, previousValue);
177
+ }))) || false;
178
+ },
179
+ async apply() {
180
+ const i18nScope = "settings";
253
181
  try {
254
- this.isSaving.set(true);
255
- this.builder.setStatus(AXPPageStatus.Submitting);
256
- const formResult = await this.form.validate();
257
- if (!formResult.result) {
258
- this.toastService.show({
259
- color: 'danger',
260
- title: 'Review Needed',
261
- content: 'Invalid configuration detected. Please review your inputs.',
182
+ if (await store.form() && this.isDirty()) {
183
+ const form = store.form();
184
+ form.resetErrors();
185
+ //
186
+ patchState(store, {
187
+ status: AXPPageStatus.Submitting,
188
+ });
189
+ const formResult = await form.validate();
190
+ if (!formResult.result) {
191
+ toastService.show({
192
+ color: 'danger',
193
+ title: await translateService.translateAsync('actions.apply.invalid.title', { scope: i18nScope }),
194
+ content: await translateService.translateAsync('actions.apply.invalid.message', { scope: i18nScope }),
195
+ location: 'bottom-center',
196
+ closeButton: true,
197
+ timeOut: 3000,
198
+ timeOutProgress: true,
199
+ });
200
+ patchState(store, {
201
+ status: AXPPageStatus.Error,
202
+ });
203
+ return false;
204
+ }
205
+ await settingValueService.scope(store.scope()).set(store.context());
206
+ // Show success notification
207
+ toastService.show({
208
+ color: 'success',
209
+ title: await translateService.translateAsync('actions.apply.success.title', { scope: i18nScope }),
210
+ content: await translateService.translateAsync('actions.apply.success.message', { scope: i18nScope }),
262
211
  location: 'bottom-center',
263
212
  closeButton: true,
264
213
  timeOut: 3000,
265
214
  timeOutProgress: true,
266
215
  });
267
- this.isSaving.set(false);
268
- this.builder.setStatus(AXPPageStatus.Error);
269
- return;
270
- }
271
- if (section) {
272
- // Apply changes for the specific section
273
- const changes = {};
274
- section.settings.forEach((c) => {
275
- changes[c.name] = get(this.context(), c.name);
216
+ patchState(store, {
217
+ status: AXPPageStatus.Submitted,
276
218
  });
277
- if (!isEmpty(changes)) {
278
- await this.settingValueService.scope(this.resolveScope()).set(changes);
279
- }
280
- }
281
- else {
282
- // Save the settings
283
- await this.settingValueService.scope(this.resolveScope()).set(this.context());
219
+ return true;
284
220
  }
285
- this.builder.setStatus(AXPPageStatus.Submitted);
286
- // Show success notification
287
- this.toastService.show({
288
- color: 'success',
289
- title: 'Settings Saved',
290
- content: 'Your changes have been saved successfully.',
291
- location: 'bottom-center',
292
- closeButton: true,
293
- timeOut: 3000,
294
- timeOutProgress: true,
295
- });
221
+ return false;
296
222
  }
297
223
  catch (error) {
298
- // Handle and show errors
299
- this.builder.setStatus(AXPPageStatus.Error);
300
- console.error('Error saving settings:', error);
301
- this.toastService.show({
224
+ toastService.show({
302
225
  color: 'danger',
303
- title: 'Save Failed',
304
- content: error?.['message'] || 'An error occurred while saving your settings. Please try again.',
226
+ title: await translateService.translateAsync('actions.apply.error.title', { scope: i18nScope }),
227
+ content: await translateService.translateAsync('actions.apply.error.message', { scope: i18nScope }),
305
228
  location: 'bottom-center',
306
229
  closeButton: true,
307
- timeOut: 5000,
230
+ timeOut: 3000,
308
231
  timeOutProgress: true,
309
232
  });
310
- }
311
- finally {
312
- this.isSaving.set(false);
313
- }
314
- }
315
- // discard settings logic
316
- async discard(section) {
317
- this.form.resetErrors();
318
- if (section) {
319
- // Discard changes for the specific section
320
- section.settings.forEach((c) => {
321
- const previousValue = get(this.previousContext(), c.name);
322
- this.context.update((ctx) => ({
323
- ...ctx,
324
- [c.name]: previousValue,
325
- }));
233
+ patchState(store, {
234
+ status: AXPPageStatus.Error,
326
235
  });
236
+ return false;
327
237
  }
328
- else {
329
- // Discard changes for all sections
330
- this.context.set(this.previousContext());
331
- }
332
- }
333
- // Cancel settings logic
238
+ },
239
+ async discard() {
240
+ const form = store.form();
241
+ form.resetErrors();
242
+ //
243
+ patchState(store, {
244
+ status: AXPPageStatus.Rendered,
245
+ });
246
+ patchState(store, {
247
+ context: store.previousContext(),
248
+ });
249
+ },
334
250
  async resetToDefault() {
335
- const defaults = await this.settingValueService.scope(this.resolveScope()).defaultValues();
336
251
  // Update the context with the defaults
337
- this.context.set(defaults);
252
+ const defaults = await settingValueService.scope(store.scope()).defaultValues();
253
+ patchState(store, {
254
+ context: defaults,
255
+ });
338
256
  //
339
- await this.apply();
340
- }
341
- async search(expression) {
342
- this.searchExpression.set(expression);
343
- const app = this.activatedRoute.snapshot.params['app'];
344
- const scope = this.activatedRoute.snapshot.params['scope'];
257
+ const result = await this.apply();
258
+ if (!result) {
259
+ this.discard();
260
+ }
261
+ },
262
+ })), withHooks((store, settingValueService = inject(AXPSettingService), translationService = inject(AXTranslationService)) => ({
263
+ async onInit() {
345
264
  //
346
- if (this.isValidQuery(expression)) {
347
- await this.router.navigate([app, 'settings', scope, this.activateGroup() ?? ''], {
348
- queryParams: { q: expression },
265
+ settingValueService.onChanged.pipe(filter((c) => c.scope == store.scope())).subscribe((e) => {
266
+ e.keys.forEach((k) => {
267
+ const currentValue = e.values[k];
268
+ const contextValue = get(store.context(), k);
269
+ const previousValue = get(store.previousContext(), k);
270
+ // Update only if there are actual changes
271
+ if (!isEqual(previousValue, currentValue) || !isEqual(currentValue, contextValue)) {
272
+ patchState(store, {
273
+ previousContext: {
274
+ ...store.previousContext(),
275
+ [k]: currentValue,
276
+ }
277
+ });
278
+ patchState(store, {
279
+ context: {
280
+ ...store.context(),
281
+ [k]: currentValue,
282
+ }
283
+ });
284
+ }
349
285
  });
350
- }
351
- else {
352
- await this.router.navigate([app, 'settings', scope, this.activateGroup() ?? '']);
353
- }
354
- }
355
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPSettingsViewModel, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
356
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPSettingsViewModel }); }
357
- }
358
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPSettingsViewModel, decorators: [{
359
- type: Injectable
360
- }], ctorParameters: () => [] });
286
+ });
287
+ //
288
+ translationService.langChanges$.subscribe(async () => {
289
+ await store.reload();
290
+ });
291
+ },
292
+ onDestroy() { },
293
+ })));
361
294
 
362
295
  class AXPSettingSearchProvider {
363
296
  constructor() {
@@ -365,9 +298,9 @@ class AXPSettingSearchProvider {
365
298
  this.sessionService = inject(AXPSessionService);
366
299
  }
367
300
  async search(text) {
368
- const groupsSetting = this.settingService.getList(AXPSettingScope.User);
301
+ const groupsSetting = this.settingService.getList(AXPPlatformScope.User);
369
302
  if (groupsSetting.length == 0) {
370
- groupsSetting.push(...(await this.settingService.getListAsync(AXPSettingScope.User)));
303
+ groupsSetting.push(...(await this.settingService.getListAsync(AXPPlatformScope.User)));
371
304
  }
372
305
  // Step 2: Flatten settings from groups
373
306
  const allSettings = [];