@acorex-platform/module-workplacesafety-management-client 0.0.21

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 (27) hide show
  1. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs +1646 -0
  2. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs.map +1 -0
  3. package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-C-qrrqOV.mjs +203 -0
  4. package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-C-qrrqOV.mjs.map +1 -0
  5. package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-BBhH7KP1.mjs +119 -0
  6. package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-BBhH7KP1.mjs.map +1 -0
  7. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-o4bAwYcq.mjs +42 -0
  8. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-o4bAwYcq.mjs.map +1 -0
  9. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-ppe-rule-status.provider-DtqzcWh0.mjs +42 -0
  10. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-ppe-rule-status.provider-DtqzcWh0.mjs.map +1 -0
  11. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-status.provider-B6IkRYbW.mjs +42 -0
  12. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-status.provider-B6IkRYbW.mjs.map +1 -0
  13. package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-kF37zgd4.mjs +1900 -0
  14. package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-kF37zgd4.mjs.map +1 -0
  15. package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-C2X3VpEt.mjs +175 -0
  16. package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-C2X3VpEt.mjs.map +1 -0
  17. package/fesm2022/acorex-platform-module-workplacesafety-management-client-publish-safety-plan.command-Ci-zcrmO.mjs +106 -0
  18. package/fesm2022/acorex-platform-module-workplacesafety-management-client-publish-safety-plan.command-Ci-zcrmO.mjs.map +1 -0
  19. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-status.provider-BpWx3gIf.mjs +51 -0
  20. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-status.provider-BpWx3gIf.mjs.map +1 -0
  21. package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BJsg3pHZ.mjs +461 -0
  22. package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BJsg3pHZ.mjs.map +1 -0
  23. package/fesm2022/acorex-platform-module-workplacesafety-management-client.mjs +461 -0
  24. package/fesm2022/acorex-platform-module-workplacesafety-management-client.mjs.map +1 -0
  25. package/package.json +28 -0
  26. package/types/acorex-platform-module-workplacesafety-management-client-contracts.d.ts +1111 -0
  27. package/types/acorex-platform-module-workplacesafety-management-client.d.ts +20 -0
@@ -0,0 +1,106 @@
1
+ import { AXToastService } from '@acorex/components/toast';
2
+ import { AXTranslationService } from '@acorex/core/translation';
3
+ import { AXPHookService, AXPEntityBroadcastService } from '@acorex-platform/framework-client/core';
4
+ import { AXPRuntimeRemoteHookKeys } from '@acorex-platform/framework-client/runtime';
5
+ import { AXMWorkplaceSafetyManagementCommandKeys } from '@acorex-platform/module-workplacesafety-management-contracts';
6
+ import * as i0 from '@angular/core';
7
+ import { inject, Injectable } from '@angular/core';
8
+
9
+ //#endregion
10
+ //#region ---- Helpers ----
11
+ function resolveSafetyPlanId(input) {
12
+ if (!input) {
13
+ return undefined;
14
+ }
15
+ const context = input.__context__;
16
+ const candidate = context?.options?.id ?? context?.data?.id ?? input.id;
17
+ return typeof candidate === 'string' && candidate.trim() ? candidate.trim() : undefined;
18
+ }
19
+ function resolveEntitySource(input) {
20
+ return input?.__context__?.entity;
21
+ }
22
+ async function resolveCommandMessage(translationService, message) {
23
+ const text = message?.text;
24
+ if (typeof text === 'string' && text.startsWith('@')) {
25
+ return translationService.translateAsync(text);
26
+ }
27
+ if (typeof text === 'string' && text.trim()) {
28
+ return text;
29
+ }
30
+ return translationService.translateAsync('@general:messages.generic.error.description');
31
+ }
32
+ //#endregion
33
+ //#region ---- Publish safety plan command ----
34
+ class AXMPublishSafetyPlanCommand {
35
+ constructor() {
36
+ this.hooks = inject(AXPHookService);
37
+ this.toastService = inject(AXToastService);
38
+ this.translationService = inject(AXTranslationService);
39
+ this.entityEvents = inject(AXPEntityBroadcastService);
40
+ }
41
+ async execute(input = {}) {
42
+ const id = resolveSafetyPlanId(input);
43
+ if (!id) {
44
+ return {
45
+ success: false,
46
+ message: {
47
+ text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),
48
+ },
49
+ };
50
+ }
51
+ try {
52
+ const payload = await this.hooks.runAsync(AXPRuntimeRemoteHookKeys.CommandExecute, {
53
+ name: AXMWorkplaceSafetyManagementCommandKeys.SafetyPlan.Publish,
54
+ input: { id, __context__: input.__context__ },
55
+ });
56
+ if (!payload.handled) {
57
+ const content = await this.translationService.translateAsync('@general:messages.generic.error.description');
58
+ await this.showErrorToast(content);
59
+ return { success: false, message: { text: content } };
60
+ }
61
+ const result = payload.result;
62
+ if (!result?.success) {
63
+ const content = await resolveCommandMessage(this.translationService, result?.message);
64
+ await this.showErrorToast(content);
65
+ return { success: false, message: { text: content } };
66
+ }
67
+ const entity = resolveEntitySource(input);
68
+ if (entity) {
69
+ this.entityEvents.publishLayoutRefresh(entity, { highlightRowId: id });
70
+ }
71
+ this.toastService.show({
72
+ color: 'success',
73
+ title: await this.translationService.translateAsync('@general:messages.generic.success.title'),
74
+ content: await this.translationService.translateAsync('@workplacesafety-management:safety-plans.messages.publish.success'),
75
+ closeButton: true,
76
+ timeOut: 5000,
77
+ });
78
+ return { success: true, kind: 'object', data: undefined };
79
+ }
80
+ catch (error) {
81
+ const content = error instanceof Error
82
+ ? error.message
83
+ : await this.translationService.translateAsync('@general:messages.generic.error.description');
84
+ await this.showErrorToast(content);
85
+ return { success: false, message: { text: content } };
86
+ }
87
+ }
88
+ async showErrorToast(content) {
89
+ this.toastService.show({
90
+ color: 'danger',
91
+ title: await this.translationService.translateAsync('@general:messages.generic.error.title'),
92
+ content,
93
+ closeButton: true,
94
+ timeOut: 7000,
95
+ });
96
+ }
97
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPublishSafetyPlanCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
98
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPublishSafetyPlanCommand, providedIn: 'root' }); }
99
+ }
100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPublishSafetyPlanCommand, decorators: [{
101
+ type: Injectable,
102
+ args: [{ providedIn: 'root' }]
103
+ }] });
104
+
105
+ export { AXMPublishSafetyPlanCommand };
106
+ //# sourceMappingURL=acorex-platform-module-workplacesafety-management-client-publish-safety-plan.command-Ci-zcrmO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-publish-safety-plan.command-Ci-zcrmO.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/safety-plan/commands/publish-safety-plan.command.ts"],"sourcesContent":["import { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPEntityBroadcastService, AXPHookService } from '@acorex-platform/framework-client/core';\nimport { AXPRuntimeRemoteHookKeys, type AXPRuntimeCommandExecuteHookPayload } from '@acorex-platform/framework-client/runtime';\nimport type { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport type { AXPCommand } from '@acorex-platform/framework-shared/runtime';\nimport { AXMWorkplaceSafetyManagementCommandKeys } from '@acorex-platform/module-workplacesafety-management-contracts';\nimport { inject, Injectable } from '@angular/core';\n\n//#region ---- Types ----\n\nexport interface AXMPublishSafetyPlanCommandInput {\n id?: string;\n __context__?: {\n entity?: string;\n data?: { id?: string };\n options?: { id?: string };\n };\n}\n\n//#endregion\n\n//#region ---- Helpers ----\n\nfunction resolveSafetyPlanId(input?: AXMPublishSafetyPlanCommandInput | null): string | undefined {\n if (!input) {\n return undefined;\n }\n\n const context = input.__context__;\n const candidate = context?.options?.id ?? context?.data?.id ?? input.id;\n return typeof candidate === 'string' && candidate.trim() ? candidate.trim() : undefined;\n}\n\nfunction resolveEntitySource(input?: AXMPublishSafetyPlanCommandInput | null): string | undefined {\n return input?.__context__?.entity;\n}\n\nasync function resolveCommandMessage(\n translationService: AXTranslationService,\n message?: AXPRuntimeCommandResult['message'],\n): Promise<string> {\n const text = message?.text;\n if (typeof text === 'string' && text.startsWith('@')) {\n return translationService.translateAsync(text);\n }\n if (typeof text === 'string' && text.trim()) {\n return text;\n }\n return translationService.translateAsync('@general:messages.generic.error.description');\n}\n\n//#endregion\n\n//#region ---- Publish safety plan command ----\n\n@Injectable({ providedIn: 'root' })\nexport class AXMPublishSafetyPlanCommand\n implements AXPCommand<AXMPublishSafetyPlanCommandInput, void>\n{\n private readonly hooks = inject(AXPHookService);\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n private readonly entityEvents = inject(AXPEntityBroadcastService);\n\n async execute(input: AXMPublishSafetyPlanCommandInput = {}): Promise<AXPRuntimeCommandResult<void>> {\n const id = resolveSafetyPlanId(input);\n if (!id) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n try {\n const payload = await this.hooks.runAsync<AXPRuntimeCommandExecuteHookPayload>(\n AXPRuntimeRemoteHookKeys.CommandExecute,\n {\n name: AXMWorkplaceSafetyManagementCommandKeys.SafetyPlan.Publish,\n input: { id, __context__: input.__context__ },\n },\n );\n\n if (!payload.handled) {\n const content = await this.translationService.translateAsync(\n '@general:messages.generic.error.description',\n );\n await this.showErrorToast(content);\n return { success: false, message: { text: content } };\n }\n\n const result = payload.result;\n if (!result?.success) {\n const content = await resolveCommandMessage(this.translationService, result?.message);\n await this.showErrorToast(content);\n return { success: false, message: { text: content } };\n }\n\n const entity = resolveEntitySource(input);\n if (entity) {\n this.entityEvents.publishLayoutRefresh(entity, { highlightRowId: id });\n }\n\n this.toastService.show({\n color: 'success',\n title: await this.translationService.translateAsync('@general:messages.generic.success.title'),\n content: await this.translationService.translateAsync(\n '@workplacesafety-management:safety-plans.messages.publish.success',\n ),\n closeButton: true,\n timeOut: 5000,\n });\n\n return { success: true, kind: 'object', data: undefined };\n } catch (error: unknown) {\n const content =\n error instanceof Error\n ? error.message\n : await this.translationService.translateAsync('@general:messages.generic.error.description');\n await this.showErrorToast(content);\n return { success: false, message: { text: content } };\n }\n }\n\n private async showErrorToast(content: string): Promise<void> {\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content,\n closeButton: true,\n timeOut: 7000,\n });\n }\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;AAoBA;AAEA;AAEA,SAAS,mBAAmB,CAAC,KAA+C,EAAA;IAC1E,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW;AACjC,IAAA,MAAM,SAAS,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,KAAK,CAAC,EAAE;IACvE,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,SAAS;AACzF;AAEA,SAAS,mBAAmB,CAAC,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StatusToDefinition } from '@acorex-platform/framework-shared/core';
2
+
3
+ //#region ---- Imports ----
4
+ //#endregion
5
+ //#region ---- Safety plan status provider ----
6
+ /**
7
+ * Safety plan lifecycle statuses: Draft, Published, Archived.
8
+ * Used by the status plugin (`workplacesafety-management.status.safety-plan`).
9
+ */
10
+ class AXMWorkplaceSafetyManagementSafetyPlanStatusProvider extends AXPStatusProvider {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.key = 'workplacesafety-management.status.safety-plan';
14
+ this.defaultStatus = AXPSystemStatusType.Draft;
15
+ this.statuses = [
16
+ systemStatusToDefinition(AXPSystemStatusType.Draft, {
17
+ title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.draft',
18
+ generateView: true,
19
+ }),
20
+ systemStatusToDefinition(AXPSystemStatusType.Published, {
21
+ title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.published',
22
+ generateView: true,
23
+ }),
24
+ systemStatusToDefinition(AXPSystemStatusType.Archived, {
25
+ title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.archived',
26
+ generateView: true,
27
+ }),
28
+ ];
29
+ this.transitions = [
30
+ // {
31
+ // from: AXPSystemStatusType.Draft,
32
+ // to: AXPSystemStatusType.Published,
33
+ // title: '@general:statuses.transitions.publish',
34
+ // },
35
+ {
36
+ from: AXPSystemStatusType.Published,
37
+ to: AXPSystemStatusType.Archived,
38
+ title: '@general:statuses.transitions.archive',
39
+ },
40
+ {
41
+ from: AXPSystemStatusType.Archived,
42
+ to: AXPSystemStatusType.Draft,
43
+ title: '@general:statuses.transitions.reopen',
44
+ },
45
+ ];
46
+ }
47
+ }
48
+ //#endregion
49
+
50
+ export { AXMWorkplaceSafetyManagementSafetyPlanStatusProvider };
51
+ //# sourceMappingURL=acorex-platform-module-workplacesafety-management-client-safety-plan-status.provider-BpWx3gIf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-safety-plan-status.provider-BpWx3gIf.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/safety-plan-status.provider.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPStatusProvider, AXPStatusTransition, AXPSystemStatusType, systemStatusToDefinition } from '@acorex-platform/framework-shared/core';\n\n//#endregion\n\n//#region ---- Safety plan status provider ----\n\n/**\n * Safety plan lifecycle statuses: Draft, Published, Archived.\n * Used by the status plugin (`workplacesafety-management.status.safety-plan`).\n */\nexport class AXMWorkplaceSafetyManagementSafetyPlanStatusProvider extends AXPStatusProvider {\n readonly key = 'workplacesafety-management.status.safety-plan';\n\n readonly defaultStatus = AXPSystemStatusType.Draft;\n\n readonly statuses = [\n systemStatusToDefinition(AXPSystemStatusType.Draft, {\n title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.draft',\n generateView: true,\n }),\n systemStatusToDefinition(AXPSystemStatusType.Published, {\n title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.published',\n generateView: true,\n }),\n systemStatusToDefinition(AXPSystemStatusType.Archived, {\n title: '@workplacesafety-management:safety-plans.entities.safety-plan.fields.status.options.archived',\n generateView: true,\n }),\n ];\n\n readonly transitions: AXPStatusTransition[] = [\n // {\n // from: AXPSystemStatusType.Draft,\n // to: AXPSystemStatusType.Published,\n // title: '@general:statuses.transitions.publish',\n // },\n {\n from: AXPSystemStatusType.Published,\n to: AXPSystemStatusType.Archived,\n title: '@general:statuses.transitions.archive',\n },\n {\n from: AXPSystemStatusType.Archived,\n to: AXPSystemStatusType.Draft,\n title: '@general:statuses.transitions.reopen',\n },\n ];\n}\n\n//#endregion\n"],"names":[],"mappings":";;AAAA;AAIA;AAEA;AAEA;;;AAGG;AACG,MAAO,oDAAqD,SAAQ,iBAAiB,CAAA;AAA3F,IAAA,WAAA,GAAA;;QACW,IAAA,CAAA,GAAG,GAAG,+CAA+C;AAErD,QAAA,IAAA,CAAA,aAAa,GAAG,mBAAmB,CAAC,KAAK;AAEzC,QAAA,IAAA,CAAA,QAAQ,GAAG;AAClB,YAAA,wBAAwB,CAAC,mBAAmB,CAAC,KAAK,EAAE;AAClD,gBAAA,KAAK,EAAE,2FAA2F;AAClG,gBAAA,YAAY,EAAE,IAAI;aACnB,CAAC;AACF,YAAA,wBAAwB,CAAC,mBAAmB,CAAC,SAAS,EAAE;AACtD,gBAAA,KAAK,EAAE,+FAA+F;AACtG,gBAAA,YAAY,EAAE,IAAI;aACnB,CAAC;AACF,YAAA,wBAAwB,CAAC,mBAAmB,CAAC,QAAQ,EAAE;AACrD,gBAAA,KAAK,EAAE,8FAA8F;AACrG,gBAAA,YAAY,EAAE,IAAI;aACnB,CAAC;SACH;AAEQ,QAAA,IAAA,CAAA,WAAW,GAA0B;;;;;;AAM5C,YAAA;gBACE,IAAI,EAAE,mBAAmB,CAAC,SAAS;gBACnC,EAAE,EAAE,mBAAmB,CAAC,QAAQ;AAChC,gBAAA,KAAK,EAAE,uCAAuC;AAC/C,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,mBAAmB,CAAC,QAAQ;gBAClC,EAAE,EAAE,mBAAmB,CAAC,KAAK;AAC7B,gBAAA,KAAK,EAAE,sCAAsC;AAC9C,aAAA;SACF;IACH;AAAC;AAED;;;;"}
@@ -0,0 +1,461 @@
1
+ import { AXPEntityService, isAXPMiddlewareAbortError, mapEntityStorageErrorToCommandResult } from '@acorex-platform/framework-client/layout/entity';
2
+ import { extractRequestErrorInfo } from '@acorex-platform/framework-client/common';
3
+ import { AXTranslationService } from '@acorex/core/translation';
4
+ import * as i0 from '@angular/core';
5
+ import { inject, Injectable } from '@angular/core';
6
+ import { resolveEntityRefId, enrichSectionTypeSnapshot, isStepTableSectionType, normalizeStepTableColumns, normalizeStepTableRows, stepTableColumnTitle, RootConfig, dedupeSafetyPlanSectionStructure, findDuplicateSafetyPlanSectionTypeId, SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_MESSAGE_KEY, SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_CODE, collectBuiltInRepeatableSectionTypeIds } from '@acorex-platform/module-workplacesafety-management-client/contracts';
7
+ import { AXPDataGenerator } from '@acorex-platform/framework-client/core';
8
+
9
+ function createSafetyPlanSectionBuilderDefaultValue() {
10
+ return { sections: [] };
11
+ }
12
+ function normalizeSafetyPlanSectionBuilderValue(value) {
13
+ if (!value || !Array.isArray(value.sections)) {
14
+ return createSafetyPlanSectionBuilderDefaultValue();
15
+ }
16
+ return {
17
+ sections: value.sections.map((section, index) => normalizeSection(section, index)),
18
+ };
19
+ }
20
+ function safetyPlanSectionsToBuilderValue(rows) {
21
+ const ordered = [...rows].sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0) || String(a.code ?? '').localeCompare(String(b.code ?? '')));
22
+ return {
23
+ sections: ordered.map((row, index) => {
24
+ const legacyItem = row.items?.[0];
25
+ const sectionTypeId = resolveEntityRefId(legacyItem?.sectionTypeId) ??
26
+ resolveEntityRefId(legacyItem?.sectionType) ??
27
+ '';
28
+ const workStepTypeId = resolveEntityRefId(legacyItem?.workStepTypeId) ??
29
+ resolveEntityRefId(legacyItem?.workStepType) ??
30
+ undefined;
31
+ return {
32
+ id: row.id,
33
+ sectionTypeId,
34
+ sectionType: enrichSectionTypeSnapshot(sectionTypeId, legacyItem?.sectionType),
35
+ title: row.title,
36
+ description: row.description ?? '',
37
+ safetyPlanId: row.safetyPlanId,
38
+ code: row.code,
39
+ sourceSafetyPlanTypeSectionId: row.sourceSafetyPlanTypeSectionId,
40
+ sortOrder: row.sortOrder ?? index + 1,
41
+ workStepTypeId,
42
+ workStepType: legacyItem?.workStepType,
43
+ columns: [],
44
+ items: (row.items ?? []).map((item, itemIndex) => ({
45
+ id: `${row.id}__item_${itemIndex + 1}`,
46
+ itemIds: [...(item.itemIds ?? [])],
47
+ items: item.items ? [...item.items] : [],
48
+ })),
49
+ };
50
+ }),
51
+ };
52
+ }
53
+ /** Merges SafetyPlanWorkStep row entities into Step Table sections. */
54
+ function hydrateStepTableSectionsWithWorkSteps(value, workSteps, columnsByWorkStepTypeId) {
55
+ const bySection = new Map();
56
+ for (const step of workSteps) {
57
+ const sectionId = resolveEntityRefId(step.safetyPlanSectionId) ?? '';
58
+ if (!sectionId) {
59
+ continue;
60
+ }
61
+ const list = bySection.get(sectionId) ?? [];
62
+ list.push(step);
63
+ bySection.set(sectionId, list);
64
+ }
65
+ return {
66
+ sections: value.sections.map((section) => {
67
+ if (!isStepTableSectionType(section.sectionTypeId, section.sectionType)) {
68
+ return section;
69
+ }
70
+ const steps = [...(bySection.get(section.id) ?? [])].sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0) || String(a.code ?? '').localeCompare(String(b.code ?? '')));
71
+ const workStepTypeId = section.workStepTypeId ||
72
+ (steps[0] ? resolveEntityRefId(steps[0].workStepTypeId) ?? undefined : undefined);
73
+ const columns = (workStepTypeId && columnsByWorkStepTypeId?.get(workStepTypeId)) ||
74
+ normalizeStepTableColumns(steps[0]?.columns) ||
75
+ section.columns ||
76
+ [];
77
+ return {
78
+ ...section,
79
+ workStepTypeId,
80
+ workStepType: section.workStepType ?? steps[0]?.workStepType,
81
+ columns,
82
+ items: steps.map((step) => toBuilderItemFromWorkStepRow(step, columns)),
83
+ };
84
+ }),
85
+ };
86
+ }
87
+ function builderValueToSafetyPlanSectionPayloads(value, safetyPlanId) {
88
+ return value.sections.map((section, index) => ({
89
+ id: section.id,
90
+ safetyPlanId,
91
+ title: section.title,
92
+ description: section.description?.trim() ? section.description.trim() : undefined,
93
+ sectionTypeId: section.sectionTypeId,
94
+ sectionType: section.sectionType,
95
+ sourceSafetyPlanTypeSectionId: section.sourceSafetyPlanTypeSectionId,
96
+ sortOrder: typeof section.sortOrder === 'number' ? section.sortOrder : index + 1,
97
+ workStepTypeId: section.workStepTypeId,
98
+ workStepType: section.workStepType,
99
+ columns: section.columns,
100
+ items: section.items.map((item) => ({
101
+ ...item,
102
+ itemIds: [...(item.itemIds ?? [])],
103
+ items: item.items ? [...item.items] : [],
104
+ stepTableRow: item.stepTableRow ? normalizeStepTableRowPayload(item.stepTableRow) : undefined,
105
+ })),
106
+ }));
107
+ }
108
+ function toBuilderItemFromWorkStepRow(step, columns) {
109
+ const normalizedColumns = normalizeStepTableColumns(columns.length ? columns : step.columns);
110
+ const cells = normalizeStepTableRows([{ id: step.id, sortOrder: step.sortOrder ?? 1, cells: step.cells ?? [] }], normalizedColumns)[0]?.cells ??
111
+ step.cells ??
112
+ [];
113
+ const title = step.title?.trim() || summarizeStepTableRow(cells, normalizedColumns);
114
+ return {
115
+ id: step.id,
116
+ itemIds: [step.id],
117
+ items: [{ id: step.id, title, code: step.code }],
118
+ stepTableRow: {
119
+ cells,
120
+ code: step.code,
121
+ sortOrder: step.sortOrder,
122
+ title,
123
+ },
124
+ };
125
+ }
126
+ function summarizeStepTableRow(cells, columns) {
127
+ for (const column of columns) {
128
+ const key = column.sectionTypeId;
129
+ const cell = cells.find((entry) => entry.columnKey === key);
130
+ if (!cell) {
131
+ continue;
132
+ }
133
+ const fromRefs = cell.refs?.[0]?.title || cell.refs?.[0]?.code;
134
+ if (fromRefs) {
135
+ return fromRefs;
136
+ }
137
+ if (cell.textValue?.trim()) {
138
+ return cell.textValue.trim();
139
+ }
140
+ }
141
+ return columns[0] ? stepTableColumnTitle(columns[0]) : 'Row';
142
+ }
143
+ function normalizeSection(section, index) {
144
+ const id = typeof section.id === 'string' && section.id ? section.id : AXPDataGenerator.uuid();
145
+ const sectionTypeId = resolveEntityRefId(section.sectionTypeId) ?? '';
146
+ const workStepTypeId = resolveEntityRefId(section.workStepTypeId) ?? undefined;
147
+ return {
148
+ id,
149
+ sectionTypeId,
150
+ sectionType: enrichSectionTypeSnapshot(sectionTypeId, section.sectionType),
151
+ title: typeof section.title === 'string' ? section.title : '',
152
+ description: typeof section.description === 'string' ? section.description : '',
153
+ safetyPlanId: typeof section.safetyPlanId === 'string' ? section.safetyPlanId : undefined,
154
+ code: typeof section.code === 'string' ? section.code : undefined,
155
+ sourceSafetyPlanTypeSectionId: typeof section.sourceSafetyPlanTypeSectionId === 'string'
156
+ ? section.sourceSafetyPlanTypeSectionId
157
+ : undefined,
158
+ sortOrder: typeof section.sortOrder === 'number' ? section.sortOrder : index + 1,
159
+ required: section.required === true,
160
+ workStepTypeId,
161
+ workStepType: section.workStepType,
162
+ columns: normalizeStepTableColumns(section.columns),
163
+ items: Array.isArray(section.items)
164
+ ? section.items.map((item) => normalizeItem(item, id, sectionTypeId, section.sectionType))
165
+ : [],
166
+ };
167
+ }
168
+ function normalizeItem(item, sectionId, sectionTypeId, sectionType) {
169
+ const isStepTable = isStepTableSectionType(sectionTypeId, sectionType);
170
+ if (isStepTable && item.stepTableRow) {
171
+ const stepTableRow = normalizeStepTableRowPayload(item.stepTableRow);
172
+ const stepId = typeof item.id === 'string' && item.id && !item.id.includes('__item_') && !item.id.includes('__entity_')
173
+ ? item.id
174
+ : AXPDataGenerator.uuid();
175
+ const title = stepTableRow.title?.trim() || 'Row';
176
+ return {
177
+ id: stepId,
178
+ itemIds: [stepId],
179
+ items: [{ id: stepId, title, code: stepTableRow.code }],
180
+ stepTableRow,
181
+ };
182
+ }
183
+ const id = typeof item.id === 'string' && item.id ? item.id : AXPDataGenerator.uuid();
184
+ return {
185
+ id: id.includes('__item_') || id.includes('__entity_') ? id : `${sectionId}__item_${id}`,
186
+ itemIds: Array.isArray(item.itemIds) ? item.itemIds.filter((x) => typeof x === 'string') : [],
187
+ items: Array.isArray(item.items) ? item.items : [],
188
+ };
189
+ }
190
+ function normalizeStepTableRowPayload(payload) {
191
+ return {
192
+ cells: Array.isArray(payload.cells) ? payload.cells : [],
193
+ code: typeof payload.code === 'string' ? payload.code : undefined,
194
+ sortOrder: typeof payload.sortOrder === 'number' ? payload.sortOrder : undefined,
195
+ title: typeof payload.title === 'string' ? payload.title : undefined,
196
+ };
197
+ }
198
+
199
+ const SAFETY_PLAN_SECTIONS_SAVE_COMMAND = 'SafetyPlan:Sections:Save';
200
+ class AXMSaveSafetyPlanSectionsCommand {
201
+ constructor() {
202
+ this.entityService = inject(AXPEntityService);
203
+ this.translationService = inject(AXTranslationService);
204
+ }
205
+ async execute(input) {
206
+ const safetyPlanId = input?.id;
207
+ const rawValue = input?.value ?? { sections: [] };
208
+ if (!safetyPlanId) {
209
+ return {
210
+ success: false,
211
+ message: {
212
+ text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),
213
+ },
214
+ };
215
+ }
216
+ const sectionEntityRef = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanSection.name}`;
217
+ const sectionTypeEntityRef = `${RootConfig.module.name}.${RootConfig.entities.sectionType.name}`;
218
+ const workStepEntityRef = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanWorkStep.name}`;
219
+ const sectionData = this.entityService.withEntity(sectionEntityRef).data();
220
+ const workStepData = this.entityService.withEntity(workStepEntityRef).data();
221
+ try {
222
+ const repeatableSectionTypeIds = await this.loadRepeatableSectionTypeIds(sectionTypeEntityRef);
223
+ // Dedupe accidental ghost rows first so uniqueness runs on the cleaned structure.
224
+ const value = dedupeSafetyPlanSectionStructure(rawValue, { repeatableSectionTypeIds });
225
+ const duplicateTypeId = findDuplicateSafetyPlanSectionTypeId(value.sections ?? [], {
226
+ repeatableSectionTypeIds,
227
+ });
228
+ if (duplicateTypeId) {
229
+ return {
230
+ success: false,
231
+ message: {
232
+ type: 'error',
233
+ text: SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_MESSAGE_KEY,
234
+ },
235
+ };
236
+ }
237
+ const existing = await this.queryPlanSections(sectionData, safetyPlanId);
238
+ const existingRows = existing.items ?? [];
239
+ const existingIds = new Set(existingRows.map((row) => String(row.id ?? '')));
240
+ const nextIds = new Set(value.sections.map((section) => section.id));
241
+ for (const row of existingRows) {
242
+ const rowId = String(row.id ?? '');
243
+ if (rowId && !nextIds.has(rowId)) {
244
+ await this.deleteWorkStepsForSection(workStepData, rowId);
245
+ await sectionData.delete(rowId);
246
+ }
247
+ }
248
+ const payloads = builderValueToSafetyPlanSectionPayloads(value, safetyPlanId);
249
+ for (const payload of payloads) {
250
+ const isStepTable = isStepTableSectionType(payload.sectionTypeId, payload.sectionType);
251
+ const columns = normalizeStepTableColumns(payload.columns);
252
+ if (isStepTable) {
253
+ await this.syncWorkStepsForSection(workStepData, safetyPlanId, payload.id, payload.workStepTypeId, payload.workStepType, columns, payload.items);
254
+ }
255
+ const itemRows = isStepTable
256
+ ? [
257
+ {
258
+ sectionTypeId: payload.sectionTypeId,
259
+ sectionType: payload.sectionType,
260
+ workStepTypeId: payload.workStepTypeId,
261
+ workStepType: payload.workStepType,
262
+ itemIds: payload.items
263
+ .map((item) => item.id)
264
+ .filter((id) => typeof id === 'string' && id.length > 0),
265
+ items: payload.items.map((item) => ({
266
+ id: item.id,
267
+ title: item.stepTableRow?.title ??
268
+ summarizeStepTableRow(item.stepTableRow?.cells ?? [], columns) ??
269
+ item.items?.[0]?.title,
270
+ code: item.stepTableRow?.code ?? item.items?.[0]?.code,
271
+ })),
272
+ },
273
+ ]
274
+ : payload.items.length > 0
275
+ ? payload.items.map(({ itemIds, items }) => ({
276
+ sectionTypeId: payload.sectionTypeId,
277
+ sectionType: payload.sectionType,
278
+ itemIds,
279
+ items,
280
+ }))
281
+ : [
282
+ {
283
+ sectionTypeId: payload.sectionTypeId,
284
+ sectionType: payload.sectionType,
285
+ itemIds: [],
286
+ items: [],
287
+ },
288
+ ];
289
+ const entityPayload = {
290
+ safetyPlanId: payload.safetyPlanId,
291
+ title: payload.title,
292
+ description: payload.description,
293
+ sourceSafetyPlanTypeSectionId: payload.sourceSafetyPlanTypeSectionId,
294
+ sortOrder: payload.sortOrder,
295
+ items: itemRows,
296
+ };
297
+ if (existingIds.has(payload.id)) {
298
+ await sectionData.update(payload.id, entityPayload);
299
+ }
300
+ else {
301
+ await sectionData.create({ ...entityPayload, id: payload.id });
302
+ }
303
+ }
304
+ const refreshed = await this.queryPlanSections(sectionData, safetyPlanId);
305
+ const deduped = dedupeSafetyPlanSectionStructure(safetyPlanSectionsToBuilderValue((refreshed.items ?? [])), { repeatableSectionTypeIds });
306
+ const keepIds = new Set(deduped.sections.map((section) => section.id));
307
+ for (const row of refreshed.items ?? []) {
308
+ const rowId = String(row.id ?? '');
309
+ if (rowId && !keepIds.has(rowId)) {
310
+ await this.deleteWorkStepsForSection(workStepData, rowId);
311
+ await sectionData.delete(rowId);
312
+ }
313
+ }
314
+ const cleaned = keepIds.size === (refreshed.items ?? []).length
315
+ ? refreshed
316
+ : await this.queryPlanSections(sectionData, safetyPlanId);
317
+ const sections = (cleaned.items ?? []).filter((row) => keepIds.has(String(row.id ?? '')));
318
+ return {
319
+ success: true,
320
+ kind: 'object',
321
+ data: { id: safetyPlanId, value, sections },
322
+ message: {
323
+ text: await this.translationService.translateAsync('@general:messages.generic.success.description'),
324
+ },
325
+ };
326
+ }
327
+ catch (error) {
328
+ if (isAXPMiddlewareAbortError(error)) {
329
+ return mapEntityStorageErrorToCommandResult(error);
330
+ }
331
+ const httpInfo = extractRequestErrorInfo(error);
332
+ if (httpInfo?.code === SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_CODE) {
333
+ return {
334
+ success: false,
335
+ message: {
336
+ type: 'error',
337
+ code: SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_CODE,
338
+ text: SAFETY_PLAN_SECTION_DUPLICATE_SECTION_TYPE_MESSAGE_KEY,
339
+ },
340
+ };
341
+ }
342
+ const text = (typeof httpInfo?.message === 'string' && httpInfo.message.startsWith('@')
343
+ ? httpInfo.message
344
+ : null) ??
345
+ (error instanceof Error && error.message.startsWith('@') ? error.message : null) ??
346
+ (await this.translationService.translateAsync('@general:messages.generic.error.description'));
347
+ return {
348
+ success: false,
349
+ message: { type: 'error', text },
350
+ };
351
+ }
352
+ }
353
+ async syncWorkStepsForSection(workStepData, safetyPlanId, sectionId, workStepTypeId, workStepType, columns, items) {
354
+ const existing = await workStepData.query({
355
+ skip: 0,
356
+ take: 1000,
357
+ filter: {
358
+ logic: 'and',
359
+ filters: [{ field: 'safetyPlanSectionId', operator: { type: 'equal' }, value: sectionId }],
360
+ },
361
+ });
362
+ const existingRows = existing.items ?? [];
363
+ const existingIds = new Set(existingRows.map((row) => String(row.id ?? '')));
364
+ const nextIds = new Set(items.map((item) => item.id).filter((id) => typeof id === 'string' && id.length > 0));
365
+ for (const row of existingRows) {
366
+ const rowId = String(row.id ?? '');
367
+ if (rowId && !nextIds.has(rowId)) {
368
+ await workStepData.delete(rowId);
369
+ }
370
+ }
371
+ if (!workStepTypeId) {
372
+ return;
373
+ }
374
+ for (const [index, item] of items.entries()) {
375
+ const stepTableRow = item.stepTableRow;
376
+ if (!stepTableRow || !item.id) {
377
+ continue;
378
+ }
379
+ const title = stepTableRow.title?.trim() ||
380
+ summarizeStepTableRow(stepTableRow.cells ?? [], columns) ||
381
+ item.items?.[0]?.title;
382
+ const entityPayload = {
383
+ safetyPlanId,
384
+ safetyPlanSectionId: sectionId,
385
+ workStepTypeId,
386
+ workStepType: workStepType ?? { id: workStepTypeId },
387
+ title,
388
+ columns,
389
+ cells: stepTableRow.cells ?? [],
390
+ sortOrder: stepTableRow.sortOrder ?? index + 1,
391
+ };
392
+ if (existingIds.has(item.id)) {
393
+ await workStepData.update(item.id, entityPayload);
394
+ }
395
+ else {
396
+ await workStepData.create({ ...entityPayload, id: item.id });
397
+ }
398
+ }
399
+ }
400
+ async deleteWorkStepsForSection(workStepData, sectionId) {
401
+ const existing = await workStepData.query({
402
+ skip: 0,
403
+ take: 1000,
404
+ filter: {
405
+ logic: 'and',
406
+ filters: [{ field: 'safetyPlanSectionId', operator: { type: 'equal' }, value: sectionId }],
407
+ },
408
+ });
409
+ for (const row of existing.items ?? []) {
410
+ const rowId = String(row.id ?? '');
411
+ if (rowId) {
412
+ await workStepData.delete(rowId);
413
+ }
414
+ }
415
+ }
416
+ async loadRepeatableSectionTypeIds(sectionTypeEntityRef) {
417
+ const builtIn = collectBuiltInRepeatableSectionTypeIds();
418
+ try {
419
+ // Prefer client-side filtering — boolean equality filters can miss stored values.
420
+ const result = await this.entityService.withEntity(sectionTypeEntityRef).data().query({
421
+ skip: 0,
422
+ take: 1000,
423
+ });
424
+ const fromQuery = (result.items ?? [])
425
+ .filter((row) => row.isRepeatable === true)
426
+ .map((row) => resolveEntityRefId(row.id))
427
+ .filter((id) => !!id);
428
+ return [...new Set([...fromQuery, ...builtIn])];
429
+ }
430
+ catch {
431
+ return builtIn;
432
+ }
433
+ }
434
+ queryPlanSections(sectionData, safetyPlanId) {
435
+ return sectionData.query({
436
+ skip: 0,
437
+ take: 1000,
438
+ filter: {
439
+ logic: 'and',
440
+ filters: [{ field: 'safetyPlanId', operator: { type: 'equal' }, value: safetyPlanId }],
441
+ },
442
+ });
443
+ }
444
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMSaveSafetyPlanSectionsCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
445
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMSaveSafetyPlanSectionsCommand, providedIn: 'root' }); }
446
+ }
447
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMSaveSafetyPlanSectionsCommand, decorators: [{
448
+ type: Injectable,
449
+ args: [{
450
+ providedIn: 'root',
451
+ }]
452
+ }] });
453
+
454
+ var saveSafetyPlanSections_command = /*#__PURE__*/Object.freeze({
455
+ __proto__: null,
456
+ AXMSaveSafetyPlanSectionsCommand: AXMSaveSafetyPlanSectionsCommand,
457
+ SAFETY_PLAN_SECTIONS_SAVE_COMMAND: SAFETY_PLAN_SECTIONS_SAVE_COMMAND
458
+ });
459
+
460
+ export { AXMSaveSafetyPlanSectionsCommand as A, SAFETY_PLAN_SECTIONS_SAVE_COMMAND as S, safetyPlanSectionsToBuilderValue as a, saveSafetyPlanSections_command as b, hydrateStepTableSectionsWithWorkSteps as h, normalizeSafetyPlanSectionBuilderValue as n, summarizeStepTableRow as s };
461
+ //# sourceMappingURL=acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BJsg3pHZ.mjs.map