@acorex-platform/module-common-client 0.0.14

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 (44) hide show
  1. package/README.md +3 -0
  2. package/fesm2022/acorex-platform-module-common-client-acorex-platform-module-common-client-IHaYrZeE.mjs +6437 -0
  3. package/fesm2022/acorex-platform-module-common-client-acorex-platform-module-common-client-IHaYrZeE.mjs.map +1 -0
  4. package/fesm2022/acorex-platform-module-common-client-archive-entity.command-Dgsmx1_A.mjs +57 -0
  5. package/fesm2022/acorex-platform-module-common-client-archive-entity.command-Dgsmx1_A.mjs.map +1 -0
  6. package/fesm2022/acorex-platform-module-common-client-archive-entity.command.util-CEvlTSlo.mjs +144 -0
  7. package/fesm2022/acorex-platform-module-common-client-archive-entity.command.util-CEvlTSlo.mjs.map +1 -0
  8. package/fesm2022/acorex-platform-module-common-client-audit-info-column.component-DuZUwD31.mjs +158 -0
  9. package/fesm2022/acorex-platform-module-common-client-audit-info-column.component-DuZUwD31.mjs.map +1 -0
  10. package/fesm2022/acorex-platform-module-common-client-audit-info-edit.component-CSsCG6Dz.mjs +127 -0
  11. package/fesm2022/acorex-platform-module-common-client-audit-info-edit.component-CSsCG6Dz.mjs.map +1 -0
  12. package/fesm2022/acorex-platform-module-common-client-audit-info-view.component-WYXsZcLg.mjs +127 -0
  13. package/fesm2022/acorex-platform-module-common-client-audit-info-view.component-WYXsZcLg.mjs.map +1 -0
  14. package/fesm2022/acorex-platform-module-common-client-bulk-archive-entity.command-DZ6VL4oy.mjs +75 -0
  15. package/fesm2022/acorex-platform-module-common-client-bulk-archive-entity.command-DZ6VL4oy.mjs.map +1 -0
  16. package/fesm2022/acorex-platform-module-common-client-bulk-disable-entity.command-0J4vgsFL.mjs +75 -0
  17. package/fesm2022/acorex-platform-module-common-client-bulk-disable-entity.command-0J4vgsFL.mjs.map +1 -0
  18. package/fesm2022/acorex-platform-module-common-client-bulk-enable-entity.command-DsVuaInC.mjs +75 -0
  19. package/fesm2022/acorex-platform-module-common-client-bulk-enable-entity.command-DsVuaInC.mjs.map +1 -0
  20. package/fesm2022/acorex-platform-module-common-client-bulk-restore-archive-entity.command-C-ptvYRp.mjs +75 -0
  21. package/fesm2022/acorex-platform-module-common-client-bulk-restore-archive-entity.command-C-ptvYRp.mjs.map +1 -0
  22. package/fesm2022/acorex-platform-module-common-client-clone-entity.command-CyIAr8bc.mjs +227 -0
  23. package/fesm2022/acorex-platform-module-common-client-clone-entity.command-CyIAr8bc.mjs.map +1 -0
  24. package/fesm2022/acorex-platform-module-common-client-contracts.mjs +128 -0
  25. package/fesm2022/acorex-platform-module-common-client-contracts.mjs.map +1 -0
  26. package/fesm2022/acorex-platform-module-common-client-disable-entity.command-DWyqAAwo.mjs +57 -0
  27. package/fesm2022/acorex-platform-module-common-client-disable-entity.command-DWyqAAwo.mjs.map +1 -0
  28. package/fesm2022/acorex-platform-module-common-client-disable-entity.command.util-BBwY9Q30.mjs +146 -0
  29. package/fesm2022/acorex-platform-module-common-client-disable-entity.command.util-BBwY9Q30.mjs.map +1 -0
  30. package/fesm2022/acorex-platform-module-common-client-enable-entity.command-BP30gOku.mjs +57 -0
  31. package/fesm2022/acorex-platform-module-common-client-enable-entity.command-BP30gOku.mjs.map +1 -0
  32. package/fesm2022/acorex-platform-module-common-client-get-current-time.command-B7hJTMzT.mjs +72 -0
  33. package/fesm2022/acorex-platform-module-common-client-get-current-time.command-B7hJTMzT.mjs.map +1 -0
  34. package/fesm2022/acorex-platform-module-common-client-restore-archive-entity.command-D6ms054j.mjs +57 -0
  35. package/fesm2022/acorex-platform-module-common-client-restore-archive-entity.command-D6ms054j.mjs.map +1 -0
  36. package/fesm2022/acorex-platform-module-common-client-search-popup.component-upSRWTIO.mjs +136 -0
  37. package/fesm2022/acorex-platform-module-common-client-search-popup.component-upSRWTIO.mjs.map +1 -0
  38. package/fesm2022/acorex-platform-module-common-client-timeline-version-history-popup.component-D4lLwLpx.mjs +59 -0
  39. package/fesm2022/acorex-platform-module-common-client-timeline-version-history-popup.component-D4lLwLpx.mjs.map +1 -0
  40. package/fesm2022/acorex-platform-module-common-client.mjs +2 -0
  41. package/fesm2022/acorex-platform-module-common-client.mjs.map +1 -0
  42. package/package.json +32 -0
  43. package/types/acorex-platform-module-common-client-contracts.d.ts +111 -0
  44. package/types/acorex-platform-module-common-client.d.ts +777 -0
@@ -0,0 +1,227 @@
1
+ import { AXTranslationService } from '@acorex/core/translation';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, Injectable } from '@angular/core';
4
+ import { AXDialogService } from '@acorex/components/dialog';
5
+ import { AXLoadingDialogService } from '@acorex/components/loading-dialog';
6
+ import { AXToastService } from '@acorex/components/toast';
7
+ import { AXPSettingsService, AXPCommonSettings, AXPRefreshEvent } from '@acorex-platform/framework-client/common';
8
+ import { AXPEntityDefinitionRegistryService } from '@acorex-platform/framework-client/layout/entity';
9
+ import { createWorkFlowEvent, AXPWorkflowEventService } from '@acorex-platform/framework-client/workflow';
10
+ import { t as toVariableName, i as isValidVariableName } from './acorex-platform-module-common-client-acorex-platform-module-common-client-IHaYrZeE.mjs';
11
+
12
+ const AXPEntityClonedEvent = createWorkFlowEvent('[Entity] Cloned');
13
+
14
+ class AXPCloneEntityCommandHelper {
15
+ constructor() {
16
+ this.entityRegistry = inject(AXPEntityDefinitionRegistryService);
17
+ this.dialogService = inject(AXDialogService);
18
+ this.loadingDialog = inject(AXLoadingDialogService);
19
+ this.translationService = inject(AXTranslationService);
20
+ this.toastService = inject(AXToastService);
21
+ this.settingsService = inject(AXPSettingsService);
22
+ this.workflowEventService = inject(AXPWorkflowEventService);
23
+ }
24
+ async resolveEntity(refType) {
25
+ const [moduleName, entityName] = refType.split('.');
26
+ return this.entityRegistry.resolve(moduleName, entityName);
27
+ }
28
+ async fetchEntityData(refType, refId) {
29
+ const entityDefinition = await this.resolveEntity(refType);
30
+ if (entityDefinition.queries?.byKey) {
31
+ const queryExec = entityDefinition.queries.byKey.execute;
32
+ if (!queryExec) {
33
+ throw new Error('Entity byKey query is not executable');
34
+ }
35
+ return queryExec(refId);
36
+ }
37
+ return { id: refId };
38
+ }
39
+ async createEntity(refType, data) {
40
+ const entityDefinition = await this.resolveEntity(refType);
41
+ const createExec = entityDefinition.commands?.create?.execute;
42
+ if (!createExec) {
43
+ throw new Error('Entity does not support create operation');
44
+ }
45
+ return createExec(data);
46
+ }
47
+ async confirm(titleKey, messageKey, messageParams) {
48
+ const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync(titleKey), await this.translationService.translateAsync(messageKey, { params: messageParams }), 'warning', 'horizontal', false, 'cancel');
49
+ return dialogResult.result === true;
50
+ }
51
+ showLoading(title, status) {
52
+ return this.loadingDialog.show({
53
+ title,
54
+ mode: 'indeterminate',
55
+ status,
56
+ });
57
+ }
58
+ async showSuccessToast(titleKey, contentKey) {
59
+ const enabled = await this.settingsService.get(AXPCommonSettings.EnableOperationToasts);
60
+ if (!enabled) {
61
+ return;
62
+ }
63
+ this.toastService.show({
64
+ color: 'success',
65
+ title: await this.translationService.translateAsync(titleKey),
66
+ content: contentKey ? await this.translationService.translateAsync(contentKey) : undefined,
67
+ });
68
+ }
69
+ dispatchCloned(refType, originalId, newId, meta) {
70
+ this.workflowEventService.dispatch(AXPEntityClonedEvent({ entity: refType, originalId, newId, meta }));
71
+ this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta }));
72
+ }
73
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommandHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
74
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommandHelper, providedIn: 'root' }); }
75
+ }
76
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommandHelper, decorators: [{
77
+ type: Injectable,
78
+ args: [{ providedIn: 'root' }]
79
+ }] });
80
+
81
+ //#region ---- Constants ----
82
+ const CLONE_TITLE_SUFFIX = ' (Copy)';
83
+ const CLONE_CODE_SUFFIX = '_copy';
84
+ //#endregion
85
+ //#region ---- Clone Identifier Field Preparation ----
86
+ /**
87
+ * Adjusts common identifier fields after cloning.
88
+ * Uses entity metadata (derived-name plugin, variable-name validation) to pick a safe strategy.
89
+ */
90
+ function prepareCloneIdentifierFields(clonedData, entityDefinition) {
91
+ const derivedName = entityDefinition.extensions
92
+ ?.derivedName;
93
+ const properties = entityDefinition.properties ?? [];
94
+ const propertyHasVariableNameRule = (fieldName) => properties.some((prop) => prop.name === fieldName && prop.validations?.some((validation) => validation.rule === 'variable-name'));
95
+ const title = clonedData['title'];
96
+ if (typeof title === 'string' && title.trim()) {
97
+ clonedData['title'] = `${title.trim()}${CLONE_TITLE_SUFFIX}`;
98
+ }
99
+ if (Object.prototype.hasOwnProperty.call(clonedData, 'name')) {
100
+ clonedData['name'] = resolveClonedName(clonedData, derivedName, propertyHasVariableNameRule('name'));
101
+ }
102
+ const code = clonedData['code'];
103
+ if (typeof code === 'string' && code.trim()) {
104
+ clonedData['code'] = `${code.trim()}${CLONE_CODE_SUFFIX}`;
105
+ }
106
+ }
107
+ function resolveClonedName(clonedData, derivedName, hasVariableNameValidation) {
108
+ const sourceField = derivedName?.sourceField ?? 'title';
109
+ const sourceValue = clonedData[sourceField];
110
+ if (derivedName || hasVariableNameValidation) {
111
+ const fromSource = toVariableName(sourceValue);
112
+ if (fromSource) {
113
+ return fromSource;
114
+ }
115
+ }
116
+ const currentName = clonedData['name'];
117
+ if (typeof currentName === 'string' && currentName.trim()) {
118
+ const suffixed = `${currentName.trim()}${CLONE_CODE_SUFFIX}`;
119
+ if (isValidVariableName(suffixed)) {
120
+ return suffixed;
121
+ }
122
+ const fromTitle = toVariableName(clonedData['title']);
123
+ if (fromTitle) {
124
+ return fromTitle;
125
+ }
126
+ return toVariableName(currentName, 'clone');
127
+ }
128
+ return toVariableName(clonedData['title'], 'clone');
129
+ }
130
+ //#endregion
131
+
132
+ function normalizeCloneInput(input) {
133
+ const ctx = input['__context__'];
134
+ const options = (input['options'] ?? ctx?.['options'] ?? input);
135
+ const data = ctx?.['data'] ?? input;
136
+ const rowData = Array.isArray(data)
137
+ ? data[0]
138
+ : data;
139
+ const refType = String(options['refType'] ?? ctx?.['entity'] ?? ctx?.['entityInfo']?.['source'] ?? '');
140
+ const rawId = options['refId'] ?? rowData?.['id'] ?? rowData?.['_id'] ?? input['refId'];
141
+ if (!refType || rawId == null || rawId === '') {
142
+ return null;
143
+ }
144
+ return { refId: String(rawId), refType, rowData };
145
+ }
146
+ function prepareClonedData(originalData, entityDefinition) {
147
+ const clonedData = { ...originalData };
148
+ delete clonedData['id'];
149
+ delete clonedData['createdAt'];
150
+ delete clonedData['updatedAt'];
151
+ delete clonedData['createdBy'];
152
+ delete clonedData['updatedBy'];
153
+ delete clonedData['version'];
154
+ delete clonedData['isArchived'];
155
+ delete clonedData['archivedAt'];
156
+ delete clonedData['isDisabled'];
157
+ delete clonedData['disabledAt'];
158
+ prepareCloneIdentifierFields(clonedData, entityDefinition);
159
+ if (clonedData['isActive'] !== undefined) {
160
+ clonedData['isActive'] = true;
161
+ }
162
+ if (clonedData['status'] !== undefined) {
163
+ clonedData['status'] = 'draft';
164
+ }
165
+ return clonedData;
166
+ }
167
+ function buildCloneRefreshMeta(entityDefinition, clonedData) {
168
+ const meta = {};
169
+ if (entityDefinition.parentKey && clonedData[entityDefinition.parentKey] != null) {
170
+ meta['refreshTargetId'] = clonedData[entityDefinition.parentKey];
171
+ }
172
+ return meta;
173
+ }
174
+
175
+ class AXPCloneEntityCommand {
176
+ constructor() {
177
+ this.helper = inject(AXPCloneEntityCommandHelper);
178
+ this.translationService = inject(AXTranslationService);
179
+ }
180
+ async execute(input) {
181
+ const context = normalizeCloneInput(input);
182
+ if (!context) {
183
+ return {
184
+ success: false,
185
+ message: {
186
+ text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),
187
+ },
188
+ };
189
+ }
190
+ const confirmed = await this.helper.confirm('@general:actions.clone.confirm.title', '@general:actions.clone.confirm.message');
191
+ if (!confirmed) {
192
+ return { success: false };
193
+ }
194
+ const loadingDialog = this.helper.showLoading(await this.translationService.translateAsync('@general:actions.clone.confirm.processing'), 'Cloning...');
195
+ try {
196
+ const entityDefinition = await this.helper.resolveEntity(context.refType);
197
+ const originalData = await this.helper.fetchEntityData(context.refType, context.refId);
198
+ const clonedData = prepareClonedData(originalData, entityDefinition);
199
+ const newId = await this.helper.createEntity(context.refType, clonedData);
200
+ const meta = buildCloneRefreshMeta(entityDefinition, clonedData);
201
+ this.helper.dispatchCloned(context.refType, context.refId, newId, meta);
202
+ await this.helper.showSuccessToast('@general:workflow.entity-cloned', '@general:workflow.entity-cloned-body');
203
+ return { success: true, data: { newId } };
204
+ }
205
+ catch (error) {
206
+ console.error('Clone operation failed:', error);
207
+ return {
208
+ success: false,
209
+ message: {
210
+ text: error instanceof Error ? error.message : 'Clone operation failed',
211
+ },
212
+ };
213
+ }
214
+ finally {
215
+ loadingDialog.close();
216
+ }
217
+ }
218
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
219
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommand, providedIn: 'root' }); }
220
+ }
221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCloneEntityCommand, decorators: [{
222
+ type: Injectable,
223
+ args: [{ providedIn: 'root' }]
224
+ }] });
225
+
226
+ export { AXPCloneEntityCommand };
227
+ //# sourceMappingURL=acorex-platform-module-common-client-clone-entity.command-CyIAr8bc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-common-client-clone-entity.command-CyIAr8bc.mjs","sources":["../../../../libs/modules/common/client/src/lib/features/clone-plugin/clone-entity.events.ts","../../../../libs/modules/common/client/src/lib/features/clone-plugin/commands/clone-entity.command.helper.ts","../../../../libs/modules/common/client/src/lib/features/clone-plugin/clone-identifier-fields.util.ts","../../../../libs/modules/common/client/src/lib/features/clone-plugin/commands/clone-entity.command.util.ts","../../../../libs/modules/common/client/src/lib/features/clone-plugin/commands/clone-entity.command.ts"],"sourcesContent":["import { createWorkFlowEvent } from '@acorex-platform/framework-client/workflow';\n\nexport const AXPEntityClonedEvent = createWorkFlowEvent<{\n entity: string;\n originalId: string;\n newId: string;\n meta?: unknown;\n}>('[Entity] Cloned');\n","import { AXDialogService } from '@acorex/components/dialog';\nimport { AXLoadingDialogService } from '@acorex/components/loading-dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport type { AXPContextData } from '@acorex-platform/framework-shared/core';\nimport { AXPCommonSettings, AXPRefreshEvent, AXPSettingsService } from '@acorex-platform/framework-client/common';\nimport { AXPEntityDefinitionRegistryService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPWorkflowEventService } from '@acorex-platform/framework-client/workflow';\nimport type { AXPEntity } from '@acorex-platform/framework-shared/entity';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPEntityClonedEvent } from '../clone-entity.events';\n\n@Injectable({ providedIn: 'root' })\nexport class AXPCloneEntityCommandHelper {\n private readonly entityRegistry = inject(AXPEntityDefinitionRegistryService);\n private readonly dialogService = inject(AXDialogService);\n private readonly loadingDialog = inject(AXLoadingDialogService);\n private readonly translationService = inject(AXTranslationService);\n private readonly toastService = inject(AXToastService);\n private readonly settingsService = inject(AXPSettingsService);\n private readonly workflowEventService = inject(AXPWorkflowEventService);\n\n async resolveEntity(refType: string): Promise<AXPEntity> {\n const [moduleName, entityName] = refType.split('.');\n return this.entityRegistry.resolve(moduleName, entityName);\n }\n\n async fetchEntityData(refType: string, refId: string): Promise<AXPContextData> {\n const entityDefinition = await this.resolveEntity(refType);\n\n if (entityDefinition.queries?.byKey) {\n const queryExec = entityDefinition.queries.byKey.execute as\n | ((id: string) => Promise<AXPContextData>)\n | undefined;\n\n if (!queryExec) {\n throw new Error('Entity byKey query is not executable');\n }\n\n return queryExec(refId);\n }\n\n return { id: refId };\n }\n\n async createEntity(refType: string, data: AXPContextData): Promise<string> {\n const entityDefinition = await this.resolveEntity(refType);\n const createExec = entityDefinition.commands?.create?.execute as\n | ((payload: AXPContextData) => Promise<string>)\n | undefined;\n\n if (!createExec) {\n throw new Error('Entity does not support create operation');\n }\n\n return createExec(data);\n }\n\n async confirm(titleKey: string, messageKey: string, messageParams?: AXPContextData): Promise<boolean> {\n const dialogResult = await this.dialogService.confirm(\n await this.translationService.translateAsync(titleKey),\n await this.translationService.translateAsync(messageKey, { params: messageParams }),\n 'warning',\n 'horizontal',\n false,\n 'cancel',\n );\n return dialogResult.result === true;\n }\n\n showLoading(title: string, status: string) {\n return this.loadingDialog.show({\n title,\n mode: 'indeterminate',\n status,\n });\n }\n\n async showSuccessToast(titleKey: string, contentKey?: string): Promise<void> {\n const enabled = await this.settingsService.get<boolean>(AXPCommonSettings.EnableOperationToasts);\n if (!enabled) {\n return;\n }\n\n this.toastService.show({\n color: 'success',\n title: await this.translationService.translateAsync(titleKey),\n content: contentKey ? await this.translationService.translateAsync(contentKey) : undefined,\n });\n }\n\n dispatchCloned(refType: string, originalId: string, newId: string, meta?: AXPContextData): void {\n this.workflowEventService.dispatch(\n AXPEntityClonedEvent({ entity: refType, originalId, newId, meta }),\n );\n this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta }));\n }\n}\n","import type { AXPContextData } from '@acorex-platform/framework-shared/core';\nimport { AXPEntity } from '@acorex-platform/framework-shared/entity';\nimport { isValidVariableName, toVariableName } from '../../validations/utils/variable-name.util';\nimport { AXPDerivedNameExtension } from '../derived-name-plugin/derived-name.plugin';\n\n//#region ---- Constants ----\n\nexport const CLONE_TITLE_SUFFIX = ' (Copy)';\nexport const CLONE_CODE_SUFFIX = '_copy';\n\n//#endregion\n\n//#region ---- Clone Identifier Field Preparation ----\n\n/**\n * Adjusts common identifier fields after cloning.\n * Uses entity metadata (derived-name plugin, variable-name validation) to pick a safe strategy.\n */\nexport function prepareCloneIdentifierFields(\n clonedData: AXPContextData,\n entityDefinition: AXPEntity,\n): void {\n const derivedName = (entityDefinition as { extensions?: { derivedName?: AXPDerivedNameExtension } }).extensions\n ?.derivedName;\n const properties = entityDefinition.properties ?? [];\n\n const propertyHasVariableNameRule = (fieldName: string): boolean =>\n properties.some(\n (prop) =>\n prop.name === fieldName && prop.validations?.some((validation) => validation.rule === 'variable-name'),\n );\n\n const title = clonedData['title'];\n if (typeof title === 'string' && title.trim()) {\n clonedData['title'] = `${title.trim()}${CLONE_TITLE_SUFFIX}`;\n }\n\n if (Object.prototype.hasOwnProperty.call(clonedData, 'name')) {\n clonedData['name'] = resolveClonedName(clonedData, derivedName, propertyHasVariableNameRule('name'));\n }\n\n const code = clonedData['code'];\n if (typeof code === 'string' && code.trim()) {\n clonedData['code'] = `${code.trim()}${CLONE_CODE_SUFFIX}`;\n }\n}\n\nfunction resolveClonedName(\n clonedData: AXPContextData,\n derivedName: AXPDerivedNameExtension | undefined,\n hasVariableNameValidation: boolean,\n): string {\n const sourceField = derivedName?.sourceField ?? 'title';\n const sourceValue = clonedData[sourceField];\n\n if (derivedName || hasVariableNameValidation) {\n const fromSource = toVariableName(sourceValue);\n if (fromSource) {\n return fromSource;\n }\n }\n\n const currentName = clonedData['name'];\n if (typeof currentName === 'string' && currentName.trim()) {\n const suffixed = `${currentName.trim()}${CLONE_CODE_SUFFIX}`;\n if (isValidVariableName(suffixed)) {\n return suffixed;\n }\n\n const fromTitle = toVariableName(clonedData['title']);\n if (fromTitle) {\n return fromTitle;\n }\n\n return toVariableName(currentName, 'clone');\n }\n\n return toVariableName(clonedData['title'], 'clone');\n}\n\n//#endregion\n","import type { AXPContextData } from '@acorex-platform/framework-shared/core';\nimport type { AXPEntity } from '@acorex-platform/framework-shared/entity';\n\nimport { prepareCloneIdentifierFields } from '../clone-identifier-fields.util';\n\nexport interface AXPCloneCommandContext {\n refId: string;\n refType: string;\n rowData?: AXPContextData;\n}\n\nexport function normalizeCloneInput(input: AXPContextData): AXPCloneCommandContext | null {\n const ctx = input['__context__'] as AXPContextData | undefined;\n const options = (input['options'] ?? ctx?.['options'] ?? input) as AXPContextData;\n const data = ctx?.['data'] ?? input;\n const rowData = Array.isArray(data)\n ? (data[0] as AXPContextData | undefined)\n : (data as AXPContextData | undefined);\n\n const refType = String(\n options['refType'] ?? ctx?.['entity'] ?? (ctx?.['entityInfo'] as AXPContextData | undefined)?.['source'] ?? '',\n );\n const rawId = options['refId'] ?? rowData?.['id'] ?? rowData?.['_id'] ?? input['refId'];\n\n if (!refType || rawId == null || rawId === '') {\n return null;\n }\n\n return { refId: String(rawId), refType, rowData };\n}\n\nexport function prepareClonedData(originalData: AXPContextData, entityDefinition: AXPEntity): AXPContextData {\n const clonedData = { ...originalData };\n\n delete clonedData['id'];\n delete clonedData['createdAt'];\n delete clonedData['updatedAt'];\n delete clonedData['createdBy'];\n delete clonedData['updatedBy'];\n delete clonedData['version'];\n delete clonedData['isArchived'];\n delete clonedData['archivedAt'];\n delete clonedData['isDisabled'];\n delete clonedData['disabledAt'];\n\n prepareCloneIdentifierFields(clonedData, entityDefinition);\n\n if (clonedData['isActive'] !== undefined) {\n clonedData['isActive'] = true;\n }\n if (clonedData['status'] !== undefined) {\n clonedData['status'] = 'draft';\n }\n\n return clonedData;\n}\n\nexport function buildCloneRefreshMeta(\n entityDefinition: AXPEntity,\n clonedData: AXPContextData,\n): AXPContextData {\n const meta: AXPContextData = {};\n if (entityDefinition.parentKey && clonedData[entityDefinition.parentKey] != null) {\n meta['refreshTargetId'] = clonedData[entityDefinition.parentKey];\n }\n return meta;\n}\n","import { AXPCommand } from '@acorex-platform/framework-shared/runtime';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPExecuteCommandResult, type AXPContextData } from '@acorex-platform/framework-shared/core';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPCloneEntityCommandHelper } from './clone-entity.command.helper';\nimport {\n buildCloneRefreshMeta,\n normalizeCloneInput,\n prepareClonedData,\n} from './clone-entity.command.util';\n\n@Injectable({ providedIn: 'root' })\nexport class AXPCloneEntityCommand implements AXPCommand<AXPContextData, { newId: string }> {\n private readonly helper = inject(AXPCloneEntityCommandHelper);\n private readonly translationService = inject(AXTranslationService);\n\n async execute(input: AXPContextData): Promise<AXPExecuteCommandResult<{ newId: string }>> {\n const context = normalizeCloneInput(input);\n if (!context) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n const confirmed = await this.helper.confirm(\n '@general:actions.clone.confirm.title',\n '@general:actions.clone.confirm.message',\n );\n if (!confirmed) {\n return { success: false };\n }\n\n const loadingDialog = this.helper.showLoading(\n await this.translationService.translateAsync('@general:actions.clone.confirm.processing'),\n 'Cloning...',\n );\n\n try {\n const entityDefinition = await this.helper.resolveEntity(context.refType);\n const originalData = await this.helper.fetchEntityData(context.refType, context.refId);\n const clonedData = prepareClonedData(originalData, entityDefinition);\n const newId = await this.helper.createEntity(context.refType, clonedData);\n\n const meta = buildCloneRefreshMeta(entityDefinition, clonedData);\n this.helper.dispatchCloned(context.refType, context.refId, newId, meta);\n await this.helper.showSuccessToast('@general:workflow.entity-cloned', '@general:workflow.entity-cloned-body');\n\n return { success: true, data: { newId } };\n } catch (error) {\n console.error('Clone operation failed:', error);\n return {\n success: false,\n message: {\n text: error instanceof Error ? error.message : 'Clone operation failed',\n },\n };\n } finally {\n loadingDialog.close();\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,oBAAoB,GAAG,mBAAmB,CAKpD,iBAAiB,CAAC;;MCOR,2BAA2B,CAAA;AADxC,IAAA,WAAA,GA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G,qBAAqB,CAAC,gBAAgB,EAAE,UAAU,CAAC;AAChE,YAAA,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;YACvE,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,EAAE,sCAAsC,CAAC;YAE7G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3C;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC;YAC/C,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE;AACP,oBAAA,IAAI,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,wBAAwB;AACxE,iBAAA;aACF;QACH;gBAAU;YACR,aAAa,CAAC,KAAK,EAAE;QACvB;IACF;8GAlDW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cADR,MAAM,EAAA,CAAA,CAAA;;2FACnB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
@@ -0,0 +1,128 @@
1
+ /** Cross-module catalog scope for shared questionnaires, question bank items, and workflows. */
2
+ const COMMON_CATALOG_SCOPE_GENERAL = 'common.general';
3
+
4
+ //#region ---- Command keys ----
5
+ const AXPCommonCommandKeys = {
6
+ Archive: {
7
+ Archive: 'archive-entity',
8
+ Restore: 'restore-archive-entity',
9
+ BulkArchive: 'bulk-archive-entity',
10
+ BulkRestore: 'bulk-restore-archive-entity',
11
+ },
12
+ Disable: {
13
+ Disable: 'disable-entity',
14
+ Enable: 'enable-entity',
15
+ BulkDisable: 'bulk-disable-entity',
16
+ BulkEnable: 'bulk-enable-entity',
17
+ },
18
+ Clone: {
19
+ Clone: 'clone-entity',
20
+ },
21
+ Compare: {
22
+ EntityRecords: 'compare-entity-records',
23
+ EntityRecordVersions: 'compare-entity-record-versions',
24
+ },
25
+ GlobalSearch: {
26
+ Open: 'global-search',
27
+ },
28
+ Lock: {
29
+ Lock: 'lock-popup',
30
+ Unlock: 'unlock-confirm',
31
+ },
32
+ };
33
+ //#endregion
34
+
35
+ const AXPCommonFeatureKeys = {
36
+ GlobalSearch: 'Common:Feature:GlobalSearch',
37
+ AdvancedExport: 'Common:Feature:AdvancedExport',
38
+ ActivityLog: 'Common:Feature:ActivityLog',
39
+ DataImport: 'Common:Feature:DataImport',
40
+ BulkOperations: 'Common:Feature:BulkOperations',
41
+ AdvancedFiltering: 'Common:Feature:AdvancedFiltering',
42
+ DataSynchronization: 'Common:Feature:DataSynchronization',
43
+ };
44
+
45
+ const AXPCommonMenuKeys = {
46
+ Home: 'Common:Menu:Home',
47
+ Administration: 'Common:Menu:Administration',
48
+ Help: 'Common:Menu:Help',
49
+ Configuration: 'Common:Menu:Configuration',
50
+ Contacts: 'Common:Menu:Contacts',
51
+ Platform: 'Common:Menu:Platform',
52
+ /** Administration > Content (Promotions, Page Builder, Dashboards) */
53
+ Content: 'Common:Menu:Administration:Content',
54
+ /** Administration > Workflows (Workflow Definitions, Instances, Studio, Activities) */
55
+ Workflows: 'Common:Menu:Administration:Workflows',
56
+ /** Commerce (Products, Orders, Supplier Products) */
57
+ Commerce: 'Common:Menu:Commerce',
58
+ /** Configuration > Meeting (Meeting Types, Meeting Role Types) */
59
+ Meeting: 'Common:Menu:Configuration:Meeting',
60
+ /** Organization (Teams, Positions, Employees, Leave - merged with Staff) */
61
+ Organization: 'Common:Menu:Organization',
62
+ /** Configuration > Organization (Job Definitions, Employment Types, etc.) */
63
+ OrganizationConfig: 'Common:Menu:Configuration:Organization',
64
+ /** Configuration > Help Desk (Issue Types) */
65
+ HelpDeskConfig: 'Common:Menu:Configuration:HelpDesk',
66
+ /** Configuration > Document Management (Document Types) */
67
+ DocumentManagementConfig: 'Common:Menu:Configuration:DocumentManagement',
68
+ /** Configuration > Forms & Assessments (Question Bank, Questionnaires, Form Templates) */
69
+ FormsAndAssessments: 'Common:Menu:Configuration:FormsAndAssessments',
70
+ /** Configuration > Reservation (Types, Statuses, Classes) */
71
+ ReservationConfig: 'Common:Menu:Configuration:Reservation',
72
+ /** Configuration > Date and Time (Timezones, Calendars, Calendar Event Types) */
73
+ DateAndTime: 'Common:Menu:Configuration:DateAndTime',
74
+ /** Configuration > Region and Locale (Location Types, Geographic Regions, Languages) */
75
+ Region: 'Common:Menu:Configuration:Region',
76
+ /** Configuration > People and Demographics (personal reference data) */
77
+ PeopleAndDemographics: 'Common:Menu:Configuration:PeopleAndDemographics',
78
+ /** Configuration > Health (health reference data and catalogs) */
79
+ Health: 'Common:Menu:Configuration:Health',
80
+ /** Configuration > Projects (Project + Task reference data) */
81
+ Projects: 'Common:Menu:Configuration:Projects',
82
+ /** Configuration > Scheduling and Events (Meeting + Reservation types) */
83
+ SchedulingAndEvents: 'Common:Menu:Configuration:SchedulingAndEvents',
84
+ /** Configuration > Data and Content (Documents + Data Definitions) */
85
+ DataAndContent: 'Common:Menu:Configuration:DataAndContent',
86
+ /** Configuration > Intelligence (AI Management) */
87
+ AiManagementConfig: 'Common:Menu:Configuration:AiManagement',
88
+ /** Plant & Equipment (top-level menu group) */
89
+ PlantEquipment: 'Common:Menu:PlantEquipment',
90
+ };
91
+
92
+ var AXMLockSystemSettings;
93
+ (function (AXMLockSystemSettings) {
94
+ AXMLockSystemSettings["LockSystem"] = "Common:Setting:LockSystem.Enabled";
95
+ })(AXMLockSystemSettings || (AXMLockSystemSettings = {}));
96
+ var AXMCommonSettings;
97
+ (function (AXMCommonSettings) {
98
+ AXMCommonSettings["QuickSearchEnabled"] = "Common:Setting:Entity.QuickSearchEnabled";
99
+ })(AXMCommonSettings || (AXMCommonSettings = {}));
100
+
101
+ const config = {
102
+ i18n: 'common',
103
+ module: 'Common',
104
+ };
105
+ const RootConfig = {
106
+ config,
107
+ module: {
108
+ route: 'common',
109
+ name: config.module,
110
+ title: '@general:common.module.title',
111
+ icon: 'fa-light fa-file-invoice',
112
+ },
113
+ entities: {},
114
+ };
115
+
116
+ /**
117
+ * Common module domain layer.
118
+ * Entity types live in feature modules; this package satisfies the workspace graph.
119
+ */
120
+
121
+ //#region ---- Contracts barrel ----
122
+
123
+ /**
124
+ * Generated bundle index. Do not edit.
125
+ */
126
+
127
+ export { AXMCommonSettings, AXMLockSystemSettings, AXPCommonCommandKeys, AXPCommonFeatureKeys, AXPCommonMenuKeys, COMMON_CATALOG_SCOPE_GENERAL, RootConfig };
128
+ //# sourceMappingURL=acorex-platform-module-common-client-contracts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-common-client-contracts.mjs","sources":["../../../../libs/modules/common/contracts/src/catalog-scope.keys.ts","../../../../libs/modules/common/contracts/src/commands.keys.ts","../../../../libs/modules/common/contracts/src/features.keys.ts","../../../../libs/modules/common/contracts/src/menu.keys.ts","../../../../libs/modules/common/contracts/src/settings.keys.ts","../../../../libs/modules/common/contracts/src/root-config.ts","../../../../libs/modules/common/contracts/src/entities/index.ts","../../../../libs/modules/common/contracts/src/index.ts","../../../../libs/modules/common/contracts/src/acorex-platform-module-common-client-contracts.ts"],"sourcesContent":["/** Cross-module catalog scope for shared questionnaires, question bank items, and workflows. */\nexport const COMMON_CATALOG_SCOPE_GENERAL = 'common.general';\n","//#region ---- Command keys ----\n\nexport const AXPCommonCommandKeys = {\n Archive: {\n Archive: 'archive-entity',\n Restore: 'restore-archive-entity',\n BulkArchive: 'bulk-archive-entity',\n BulkRestore: 'bulk-restore-archive-entity',\n },\n Disable: {\n Disable: 'disable-entity',\n Enable: 'enable-entity',\n BulkDisable: 'bulk-disable-entity',\n BulkEnable: 'bulk-enable-entity',\n },\n Clone: {\n Clone: 'clone-entity',\n },\n Compare: {\n EntityRecords: 'compare-entity-records',\n EntityRecordVersions: 'compare-entity-record-versions',\n },\n GlobalSearch: {\n Open: 'global-search',\n },\n Lock: {\n Lock: 'lock-popup',\n Unlock: 'unlock-confirm',\n },\n} as const;\n\n//#endregion\n","export const AXPCommonFeatureKeys = {\n GlobalSearch: 'Common:Feature:GlobalSearch',\n AdvancedExport: 'Common:Feature:AdvancedExport',\n ActivityLog: 'Common:Feature:ActivityLog',\n DataImport: 'Common:Feature:DataImport',\n BulkOperations: 'Common:Feature:BulkOperations',\n AdvancedFiltering: 'Common:Feature:AdvancedFiltering',\n DataSynchronization: 'Common:Feature:DataSynchronization',\n} as const;\n\n","export const AXPCommonMenuKeys = {\n Home: 'Common:Menu:Home',\n Administration: 'Common:Menu:Administration',\n Help: 'Common:Menu:Help',\n Configuration: 'Common:Menu:Configuration',\n Contacts: 'Common:Menu:Contacts',\n Platform: 'Common:Menu:Platform',\n /** Administration > Content (Promotions, Page Builder, Dashboards) */\n Content: 'Common:Menu:Administration:Content',\n /** Administration > Workflows (Workflow Definitions, Instances, Studio, Activities) */\n Workflows: 'Common:Menu:Administration:Workflows',\n /** Commerce (Products, Orders, Supplier Products) */\n Commerce: 'Common:Menu:Commerce',\n /** Configuration > Meeting (Meeting Types, Meeting Role Types) */\n Meeting: 'Common:Menu:Configuration:Meeting',\n /** Organization (Teams, Positions, Employees, Leave - merged with Staff) */\n Organization: 'Common:Menu:Organization',\n /** Configuration > Organization (Job Definitions, Employment Types, etc.) */\n OrganizationConfig: 'Common:Menu:Configuration:Organization',\n /** Configuration > Help Desk (Issue Types) */\n HelpDeskConfig: 'Common:Menu:Configuration:HelpDesk',\n /** Configuration > Document Management (Document Types) */\n DocumentManagementConfig: 'Common:Menu:Configuration:DocumentManagement',\n /** Configuration > Forms & Assessments (Question Bank, Questionnaires, Form Templates) */\n FormsAndAssessments: 'Common:Menu:Configuration:FormsAndAssessments',\n /** Configuration > Reservation (Types, Statuses, Classes) */\n ReservationConfig: 'Common:Menu:Configuration:Reservation',\n /** Configuration > Date and Time (Timezones, Calendars, Calendar Event Types) */\n DateAndTime: 'Common:Menu:Configuration:DateAndTime',\n /** Configuration > Region and Locale (Location Types, Geographic Regions, Languages) */\n Region: 'Common:Menu:Configuration:Region',\n /** Configuration > People and Demographics (personal reference data) */\n PeopleAndDemographics: 'Common:Menu:Configuration:PeopleAndDemographics',\n /** Configuration > Health (health reference data and catalogs) */\n Health: 'Common:Menu:Configuration:Health',\n /** Configuration > Projects (Project + Task reference data) */\n Projects: 'Common:Menu:Configuration:Projects',\n /** Configuration > Scheduling and Events (Meeting + Reservation types) */\n SchedulingAndEvents: 'Common:Menu:Configuration:SchedulingAndEvents',\n /** Configuration > Data and Content (Documents + Data Definitions) */\n DataAndContent: 'Common:Menu:Configuration:DataAndContent',\n /** Configuration > Intelligence (AI Management) */\n AiManagementConfig: 'Common:Menu:Configuration:AiManagement',\n /** Plant & Equipment (top-level menu group) */\n PlantEquipment: 'Common:Menu:PlantEquipment',\n} as const;\n","export enum AXMLockSystemSettings {\n LockSystem = 'Common:Setting:LockSystem.Enabled',\n}\n\nexport enum AXMCommonSettings {\n QuickSearchEnabled = 'Common:Setting:Entity.QuickSearchEnabled',\n}\n","const config = {\n i18n: 'common',\n module: 'Common',\n};\n\nexport const RootConfig = {\n config,\n module: {\n route: 'common',\n name: config.module,\n title: '@general:common.module.title',\n icon: 'fa-light fa-file-invoice',\n },\n entities: {},\n} as const;\n","/**\n * Common module domain layer.\n * Entity types live in feature modules; this package satisfies the workspace graph.\n */\n\nexport {};\n","//#region ---- Contracts barrel ----\n\nexport * from './catalog-scope.keys';\nexport * from './commands.keys';\nexport * from './features.keys';\nexport * from './menu.keys';\nexport * from './settings.keys';\n\nexport * from './root-config';\n\n//#endregion\n\nexport * from './entities';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;AACO,MAAM,4BAA4B,GAAG;;ACD5C;AAEO,MAAM,oBAAoB,GAAG;AAClC,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,gBAAgB;AACzB,QAAA,OAAO,EAAE,wBAAwB;AACjC,QAAA,WAAW,EAAE,qBAAqB;AAClC,QAAA,WAAW,EAAE,6BAA6B;AAC3C,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,gBAAgB;AACzB,QAAA,MAAM,EAAE,eAAe;AACvB,QAAA,WAAW,EAAE,qBAAqB;AAClC,QAAA,UAAU,EAAE,oBAAoB;AACjC,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,KAAK,EAAE,cAAc;AACtB,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,aAAa,EAAE,wBAAwB;AACvC,QAAA,oBAAoB,EAAE,gCAAgC;AACvD,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,IAAI,EAAE,eAAe;AACtB,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,MAAM,EAAE,gBAAgB;AACzB,KAAA;;AAGH;;AC/BO,MAAM,oBAAoB,GAAG;AAChC,IAAA,YAAY,EAAE,6BAA6B;AAC3C,IAAA,cAAc,EAAE,+BAA+B;AAC/C,IAAA,WAAW,EAAE,4BAA4B;AACzC,IAAA,UAAU,EAAE,2BAA2B;AACvC,IAAA,cAAc,EAAE,+BAA+B;AAC/C,IAAA,iBAAiB,EAAE,kCAAkC;AACrD,IAAA,mBAAmB,EAAE,oCAAoC;;;ACPtD,MAAM,iBAAiB,GAAG;AAC/B,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,cAAc,EAAE,4BAA4B;AAC5C,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAA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A,MAAM,EAAE;AACN,QAAA,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,MAAM,CAAC,MAAM;AACnB,QAAA,KAAK,EAAE,8BAA8B;AACrC,QAAA,IAAI,EAAE,0BAA0B;AACjC,KAAA;AACD,IAAA,QAAQ,EAAE,EAAE;;;ACbd;;;AAGG;;ACHH;;ACAA;;AAEG;;;;"}
@@ -0,0 +1,57 @@
1
+ import { AXTranslationService } from '@acorex/core/translation';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, Injectable } from '@angular/core';
4
+ import { A as AXPDisableEntityCommandHelper, n as normalizeDisableSingleInput, b as buildDisablePatch, a as buildDisableRefreshMeta } from './acorex-platform-module-common-client-disable-entity.command.util-BBwY9Q30.mjs';
5
+
6
+ class AXPDisableEntityCommand {
7
+ constructor() {
8
+ this.helper = inject(AXPDisableEntityCommandHelper);
9
+ this.translationService = inject(AXTranslationService);
10
+ }
11
+ async execute(input) {
12
+ const context = normalizeDisableSingleInput(input);
13
+ if (!context) {
14
+ return {
15
+ success: false,
16
+ message: {
17
+ text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),
18
+ },
19
+ };
20
+ }
21
+ const confirmed = await this.helper.confirm('@general:actions.disable.confirm.title', '@general:actions.disable.confirm.message');
22
+ if (!confirmed) {
23
+ return { success: false };
24
+ }
25
+ const loadingDialog = this.helper.showLoading(await this.translationService.translateAsync('@general:actions.disable.confirm.processing'), 'Disabling...');
26
+ try {
27
+ const entityDefinition = await this.helper.resolveEntity(context.refType);
28
+ const patch = buildDisablePatch(true);
29
+ await this.helper.applyPatch(context.refType, context.refId, patch);
30
+ const meta = buildDisableRefreshMeta(entityDefinition, context.rowData);
31
+ this.helper.dispatchDisabled(context.refType, context.refId, meta);
32
+ await this.helper.showSuccessToast('@general:workflow.entity-disabled', '@general:workflow.entity-disabled-body');
33
+ return { success: true };
34
+ }
35
+ catch (error) {
36
+ console.error('Disable operation failed:', error);
37
+ return {
38
+ success: false,
39
+ message: {
40
+ text: error instanceof Error ? error.message : 'Disable operation failed',
41
+ },
42
+ };
43
+ }
44
+ finally {
45
+ loadingDialog.close();
46
+ }
47
+ }
48
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
49
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommand, providedIn: 'root' }); }
50
+ }
51
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommand, decorators: [{
52
+ type: Injectable,
53
+ args: [{ providedIn: 'root' }]
54
+ }] });
55
+
56
+ export { AXPDisableEntityCommand };
57
+ //# sourceMappingURL=acorex-platform-module-common-client-disable-entity.command-DWyqAAwo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-common-client-disable-entity.command-DWyqAAwo.mjs","sources":["../../../../libs/modules/common/client/src/lib/features/disable-plugin/commands/disable-entity.command.ts"],"sourcesContent":["import { AXPCommand } from '@acorex-platform/framework-shared/runtime';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPExecuteCommandResult, type AXPContextData } from '@acorex-platform/framework-shared/core';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPDisableEntityCommandHelper } from './disable-entity.command.helper';\nimport { buildDisablePatch, buildDisableRefreshMeta, normalizeDisableSingleInput } from './disable-entity.command.util';\n\n@Injectable({ providedIn: 'root' })\nexport class AXPDisableEntityCommand implements AXPCommand<AXPContextData, void> {\n private readonly helper = inject(AXPDisableEntityCommandHelper);\n private readonly translationService = inject(AXTranslationService);\n\n async execute(input: AXPContextData): Promise<AXPExecuteCommandResult<void>> {\n const context = normalizeDisableSingleInput(input);\n if (!context) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n const confirmed = await this.helper.confirm(\n '@general:actions.disable.confirm.title',\n '@general:actions.disable.confirm.message',\n );\n if (!confirmed) {\n return { success: false };\n }\n\n const loadingDialog = this.helper.showLoading(\n await this.translationService.translateAsync('@general:actions.disable.confirm.processing'),\n 'Disabling...',\n );\n\n try {\n const entityDefinition = await this.helper.resolveEntity(context.refType);\n const patch = buildDisablePatch(true);\n await this.helper.applyPatch(context.refType, context.refId, patch);\n\n const meta = buildDisableRefreshMeta(entityDefinition, context.rowData);\n this.helper.dispatchDisabled(context.refType, context.refId, meta);\n await this.helper.showSuccessToast(\n '@general:workflow.entity-disabled',\n '@general:workflow.entity-disabled-body',\n );\n\n return { success: true };\n } catch (error) {\n console.error('Disable operation failed:', error);\n return {\n success: false,\n message: {\n text: error instanceof Error ? error.message : 'Disable operation failed',\n },\n };\n } finally {\n loadingDialog.close();\n }\n }\n}\n"],"names":[],"mappings":";;;;;MASa,uBAAuB,CAAA;AADpC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,6BAA6B,CAAC;AAC9C,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAmDnE,IAAA;IAjDC,MAAM,OAAO,CAAC,KAAqB,EAAA;AACjC,QAAA,MAAM,OAAO,GAAG,2BAA2B,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,uCAAuC,CAAC;AAC5F,iBAAA;aACF;QACH;AAEA,QAAA,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACzC,wCAAwC,EACxC,0CAA0C,CAC3C;QACD,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;QAC3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UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,cADV,MAAM,EAAA,CAAA,CAAA;;2FACnB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
@@ -0,0 +1,146 @@
1
+ import { AXDialogService } from '@acorex/components/dialog';
2
+ import { AXLoadingDialogService } from '@acorex/components/loading-dialog';
3
+ import { AXToastService } from '@acorex/components/toast';
4
+ import { AXTranslationService } from '@acorex/core/translation';
5
+ import { AXPSettingsService, AXPCommonSettings, AXPRefreshEvent } from '@acorex-platform/framework-client/common';
6
+ import { AXPEntityDefinitionRegistryService } from '@acorex-platform/framework-client/layout/entity';
7
+ import { createWorkFlowEvent, AXPWorkflowEventService } from '@acorex-platform/framework-client/workflow';
8
+ import * as i0 from '@angular/core';
9
+ import { inject, Injectable } from '@angular/core';
10
+
11
+ const AXPEntityDisabledEvent = createWorkFlowEvent('[Entity] Disabled');
12
+ const AXPEntityEnabledEvent = createWorkFlowEvent('[Entity] Enabled');
13
+ const AXPEntityBulkDisabledEvent = createWorkFlowEvent('[Entity] Bulk Disabled');
14
+ const AXPEntityBulkEnabledEvent = createWorkFlowEvent('[Entity] Bulk Enabled');
15
+
16
+ class AXPDisableEntityCommandHelper {
17
+ constructor() {
18
+ this.entityRegistry = inject(AXPEntityDefinitionRegistryService);
19
+ this.dialogService = inject(AXDialogService);
20
+ this.loadingDialog = inject(AXLoadingDialogService);
21
+ this.translationService = inject(AXTranslationService);
22
+ this.toastService = inject(AXToastService);
23
+ this.settingsService = inject(AXPSettingsService);
24
+ this.workflowEventService = inject(AXPWorkflowEventService);
25
+ }
26
+ async resolveEntity(refType) {
27
+ const [moduleName, entityName] = refType.split('.');
28
+ return this.entityRegistry.resolve(moduleName, entityName);
29
+ }
30
+ async applyPatch(refType, refId, patch) {
31
+ const entityDefinition = await this.resolveEntity(refType);
32
+ const updateExec = entityDefinition.commands?.update?.execute;
33
+ if (!updateExec) {
34
+ throw new Error('Entity does not support update operation');
35
+ }
36
+ await updateExec({ id: refId, ...patch });
37
+ }
38
+ async confirm(titleKey, messageKey, messageParams, color = 'warning') {
39
+ const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync(titleKey), await this.translationService.translateAsync(messageKey, { params: messageParams }), color, 'horizontal', false, 'cancel');
40
+ return dialogResult.result === true;
41
+ }
42
+ showLoading(title, status) {
43
+ return this.loadingDialog.show({
44
+ title,
45
+ mode: 'indeterminate',
46
+ status,
47
+ });
48
+ }
49
+ async showSuccessToast(titleKey, contentKey) {
50
+ const enabled = await this.settingsService.get(AXPCommonSettings.EnableOperationToasts);
51
+ if (!enabled) {
52
+ return;
53
+ }
54
+ this.toastService.show({
55
+ color: 'success',
56
+ title: await this.translationService.translateAsync(titleKey),
57
+ content: contentKey ? await this.translationService.translateAsync(contentKey) : undefined,
58
+ });
59
+ }
60
+ async showErrorToast(message) {
61
+ const enabled = await this.settingsService.get(AXPCommonSettings.EnableOperationToasts);
62
+ if (!enabled || !message.trim()) {
63
+ return;
64
+ }
65
+ this.toastService.show({
66
+ color: 'danger',
67
+ title: await this.translationService.translateAsync('@general:state-message.error.title'),
68
+ content: message,
69
+ closeButton: true,
70
+ timeOut: 6000,
71
+ timeOutProgress: true,
72
+ });
73
+ }
74
+ dispatchDisabled(refType, id, meta) {
75
+ this.workflowEventService.dispatch(AXPEntityDisabledEvent({ entity: refType, id, meta }));
76
+ this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta }));
77
+ }
78
+ dispatchEnabled(refType, id, meta) {
79
+ this.workflowEventService.dispatch(AXPEntityEnabledEvent({ entity: refType, id, meta }));
80
+ this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta }));
81
+ }
82
+ dispatchBulkDisabled(refType, ids, meta) {
83
+ this.workflowEventService.dispatch(AXPEntityBulkDisabledEvent({ entity: refType, ids, meta }));
84
+ this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta: { refreshType: 'bulk-disable', ...meta } }));
85
+ }
86
+ dispatchBulkEnabled(refType, ids, meta) {
87
+ this.workflowEventService.dispatch(AXPEntityBulkEnabledEvent({ entity: refType, ids, meta }));
88
+ this.workflowEventService.dispatch(AXPRefreshEvent({ entity: refType, meta: { refreshType: 'bulk-enable', ...meta } }));
89
+ }
90
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommandHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
91
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommandHelper, providedIn: 'root' }); }
92
+ }
93
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPDisableEntityCommandHelper, decorators: [{
94
+ type: Injectable,
95
+ args: [{ providedIn: 'root' }]
96
+ }] });
97
+
98
+ const DEFAULT_DISABLE_FIELD = 'isDisabled';
99
+ const DISABLE_TIMESTAMP_FIELD = 'disabledAt';
100
+ const ENABLE_TIMESTAMP_FIELD = 'enabledAt';
101
+ function normalizeDisableSingleInput(input) {
102
+ const ctx = input['__context__'];
103
+ const options = (input['options'] ?? ctx?.['options'] ?? input);
104
+ const data = ctx?.['data'] ?? input;
105
+ const rowData = Array.isArray(data)
106
+ ? data[0]
107
+ : data;
108
+ const refType = String(options['refType'] ?? ctx?.['entity'] ?? ctx?.['entityInfo']?.['source'] ?? '');
109
+ const rawId = options['refId'] ?? rowData?.['id'] ?? rowData?.['_id'] ?? input['refId'];
110
+ if (!refType || rawId == null || rawId === '') {
111
+ return null;
112
+ }
113
+ return { refId: String(rawId), refType, rowData };
114
+ }
115
+ function normalizeDisableBulkInput(input) {
116
+ const ctx = input['__context__'];
117
+ const options = (input['options'] ?? ctx?.['options'] ?? input);
118
+ const data = ctx?.['data'] ?? input['data'] ?? input;
119
+ const rows = (Array.isArray(data) ? data : data ? [data] : []);
120
+ const refType = String(options['refType'] ?? ctx?.['entity'] ?? ctx?.['entityInfo']?.['source'] ?? '');
121
+ const ids = rows.map((row) => row?.['id']).filter((id) => id != null && id !== '');
122
+ if (!refType || ids.length === 0) {
123
+ return null;
124
+ }
125
+ return { refType, ids, rows };
126
+ }
127
+ function buildDisablePatch(disabled) {
128
+ if (disabled) {
129
+ return { [DEFAULT_DISABLE_FIELD]: true, [DISABLE_TIMESTAMP_FIELD]: new Date() };
130
+ }
131
+ return {
132
+ [DEFAULT_DISABLE_FIELD]: false,
133
+ [DISABLE_TIMESTAMP_FIELD]: null,
134
+ [ENABLE_TIMESTAMP_FIELD]: new Date(),
135
+ };
136
+ }
137
+ function buildDisableRefreshMeta(entityDefinition, rowData) {
138
+ const meta = {};
139
+ if (entityDefinition.parentKey && rowData?.[entityDefinition.parentKey] != null) {
140
+ meta['refreshTargetId'] = rowData[entityDefinition.parentKey];
141
+ }
142
+ return meta;
143
+ }
144
+
145
+ export { AXPDisableEntityCommandHelper as A, buildDisableRefreshMeta as a, buildDisablePatch as b, normalizeDisableBulkInput as c, normalizeDisableSingleInput as n };
146
+ //# sourceMappingURL=acorex-platform-module-common-client-disable-entity.command.util-BBwY9Q30.mjs.map