@acorex-platform/module-workplacesafety-management-client 0.0.30 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-mzaaZ6T3.mjs +549 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-mzaaZ6T3.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-hierarchy-levels.mjs +509 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-hierarchy-levels.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-measure.mjs +297 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-measure.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-ppe-rule.mjs +431 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-ppe-rule.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-register.mjs +416 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-register.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-risk.mjs +476 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-risk.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard.mjs +482 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-ppe-item.mjs +345 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-ppe-item.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-section.mjs +1458 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-section.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.mjs +1313 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type.mjs +295 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-work-step.mjs +542 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-work-step.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan.mjs +470 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-template.mjs +369 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-template.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-section-type.mjs +299 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-section-type.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-work-step-type.mjs +1358 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-work-step-type.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-CeTmhod5.mjs +170 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-CeTmhod5.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-Dae2kkZe.mjs +372 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-Dae2kkZe.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-CpNcN6Pf.mjs +160 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-CpNcN6Pf.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-BcsAnO9h.mjs +294 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-BcsAnO9h.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-C9wGZ3hB.mjs +279 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-C9wGZ3hB.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-AUr2GVLU.mjs +339 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-AUr2GVLU.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-J6fveZKA.mjs +345 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-J6fveZKA.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-3fQPlBBf.mjs +208 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-3fQPlBBf.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-BRGcQo7H.mjs +971 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-BRGcQo7H.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-BPx-3rYX.mjs +356 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-BPx-3rYX.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-_nG09ZpE.mjs +211 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-_nG09ZpE.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-CIH7W9R7.mjs +158 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-CIH7W9R7.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-DmFYsBhI.mjs +405 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-DmFYsBhI.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-CUDh_ZfQ.mjs +333 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-CUDh_ZfQ.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-BxNUXvae.mjs +232 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-BxNUXvae.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-73MUyaIk.mjs +162 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-73MUyaIk.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-Ujxum2GY.mjs +256 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-Ujxum2GY.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog.mjs +2 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs +739 -806
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-CnTEwf_l.mjs +93 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-CnTEwf_l.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-BI9VkzNw.mjs +117 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-BI9VkzNw.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-BBhH7KP1.mjs → acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-tMrUDnCb.mjs} +48 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-tMrUDnCb.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-workplacesafety-management-client-index-kF37zgd4.mjs → acorex-platform-module-workplacesafety-management-client-index-LxP1eZLY.mjs} +391 -92
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-LxP1eZLY.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-local-entities.mjs +43 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-local-entities.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-column.component-D2Mmow12.mjs +42 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-column.component-D2Mmow12.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-CQtVhCgw.mjs +101 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-CQtVhCgw.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-YS8FHiRu.mjs +221 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-YS8FHiRu.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.util-2Kl3_3sg.mjs +61 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.util-2Kl3_3sg.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-C2X3VpEt.mjs → acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-Dd9xdo_y.mjs} +3 -7
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-Dd9xdo_y.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-6i0RkG3L.mjs +557 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-6i0RkG3L.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BJsg3pHZ.mjs → acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BlPzzCc2.mjs} +13 -25
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BlPzzCc2.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client.mjs +1 -460
- package/fesm2022/acorex-platform-module-workplacesafety-management-client.mjs.map +1 -1
- package/package.json +70 -2
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-hierarchy-levels.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-measure.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-ppe-rule.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-register.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-risk.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-ppe-item.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-section.d.ts +9 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-work-step.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-template.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-section-type.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entities-work-step-type.d.ts +5 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog.d.ts +10 -0
- package/types/acorex-platform-module-workplacesafety-management-client-contracts.d.ts +89 -140
- package/types/acorex-platform-module-workplacesafety-management-client-local-entities.d.ts +12 -0
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-C-qrrqOV.mjs +0 -203
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-C-qrrqOV.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-BBhH7KP1.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-ppe-rule-status.provider-DtqzcWh0.mjs +0 -42
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-ppe-rule-status.provider-DtqzcWh0.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-kF37zgd4.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-C2X3VpEt.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BJsg3pHZ.mjs.map +0 -1
|
@@ -0,0 +1,1313 @@
|
|
|
1
|
+
import { createRandomUuid, AXPWidgetsList } from '@acorex-platform/framework-shared/core';
|
|
2
|
+
import { createAllQueryView, entityMasterCrudActions, entityMasterRecordActions } from '@acorex-platform/framework-shared/entity';
|
|
3
|
+
|
|
4
|
+
const config = {
|
|
5
|
+
i18n: 'workplacesafety-management',
|
|
6
|
+
module: 'WorkplaceSafetyManagement',
|
|
7
|
+
};
|
|
8
|
+
const RootConfig = {
|
|
9
|
+
config,
|
|
10
|
+
module: {
|
|
11
|
+
name: config.module,
|
|
12
|
+
title: `@${config.i18n}:module.title`,
|
|
13
|
+
icon: 'fa-light fa-building-shield',
|
|
14
|
+
},
|
|
15
|
+
entities: {
|
|
16
|
+
hazard: {
|
|
17
|
+
name: 'Hazard',
|
|
18
|
+
source: `${config.module}.Hazard`,
|
|
19
|
+
title: `@${config.i18n}:hazards.entities.hazard.title`,
|
|
20
|
+
titlePlural: `@${config.i18n}:hazards.entities.hazard.plural`,
|
|
21
|
+
icon: 'fa-light fa-triangle-exclamation',
|
|
22
|
+
},
|
|
23
|
+
hazardRegister: {
|
|
24
|
+
name: 'HazardRegister',
|
|
25
|
+
source: `${config.module}.HazardRegister`,
|
|
26
|
+
title: `@${config.i18n}:hazard-registers.entities.hazard-register.title`,
|
|
27
|
+
titlePlural: `@${config.i18n}:hazard-registers.entities.hazard-register.plural`,
|
|
28
|
+
icon: 'fa-light fa-clipboard-list',
|
|
29
|
+
},
|
|
30
|
+
ppeItem: {
|
|
31
|
+
name: 'PpeItem',
|
|
32
|
+
source: `${config.module}.PpeItem`,
|
|
33
|
+
title: `@${config.i18n}:ppe-items.entities.ppe-item.title`,
|
|
34
|
+
titlePlural: `@${config.i18n}:ppe-items.entities.ppe-item.plural`,
|
|
35
|
+
icon: 'fa-light fa-helmet-safety',
|
|
36
|
+
},
|
|
37
|
+
hazardPpeRule: {
|
|
38
|
+
name: 'HazardPpeRule',
|
|
39
|
+
source: `${config.module}.HazardPpeRule`,
|
|
40
|
+
title: `@${config.i18n}:hazard-ppe-rules.entities.hazard-ppe-rule.title`,
|
|
41
|
+
titlePlural: `@${config.i18n}:hazard-ppe-rules.entities.hazard-ppe-rule.plural`,
|
|
42
|
+
icon: 'fa-light fa-user-helmet-safety',
|
|
43
|
+
},
|
|
44
|
+
hazardRisk: {
|
|
45
|
+
name: 'HazardRisk',
|
|
46
|
+
source: `${config.module}.HazardRisk`,
|
|
47
|
+
title: `@${config.i18n}:hazard-risks.entities.hazard-risk.title`,
|
|
48
|
+
titlePlural: `@${config.i18n}:hazard-risks.entities.hazard-risk.plural`,
|
|
49
|
+
icon: 'fa-light fa-shield-exclamation',
|
|
50
|
+
},
|
|
51
|
+
controlHierarchyLevels: {
|
|
52
|
+
name: 'ControlHierarchyLevels',
|
|
53
|
+
source: `${config.module}.ControlHierarchyLevels`,
|
|
54
|
+
title: `@${config.i18n}:control-measure-types.entities.control-measure-type.title`,
|
|
55
|
+
titlePlural: `@${config.i18n}:control-measure-types.entities.control-measure-type.plural`,
|
|
56
|
+
icon: 'fa-light fa-layer-group',
|
|
57
|
+
},
|
|
58
|
+
controlMeasure: {
|
|
59
|
+
name: 'ControlMeasure',
|
|
60
|
+
source: `${config.module}.ControlMeasure`,
|
|
61
|
+
title: `@${config.i18n}:control-measures.entities.control-measure.title`,
|
|
62
|
+
titlePlural: `@${config.i18n}:control-measures.entities.control-measure.plural`,
|
|
63
|
+
icon: 'fa-light fa-shield-check',
|
|
64
|
+
},
|
|
65
|
+
safetyPlan: {
|
|
66
|
+
name: 'SafetyPlan',
|
|
67
|
+
source: `${config.module}.SafetyPlan`,
|
|
68
|
+
title: `@${config.i18n}:safety-plans.entities.safety-plan.title`,
|
|
69
|
+
titlePlural: `@${config.i18n}:safety-plans.entities.safety-plan.plural`,
|
|
70
|
+
icon: 'fa-light fa-file-shield',
|
|
71
|
+
},
|
|
72
|
+
safetyPlanType: {
|
|
73
|
+
name: 'SafetyPlanType',
|
|
74
|
+
source: `${config.module}.SafetyPlanType`,
|
|
75
|
+
title: `@${config.i18n}:safety-plan-types.entities.safety-plan-type.title`,
|
|
76
|
+
titlePlural: `@${config.i18n}:safety-plan-types.entities.safety-plan-type.plural`,
|
|
77
|
+
icon: 'fa-light fa-file-lines',
|
|
78
|
+
},
|
|
79
|
+
safetyPlanTypeSection: {
|
|
80
|
+
name: 'SafetyPlanTypeSection',
|
|
81
|
+
source: `${config.module}.SafetyPlanTypeSection`,
|
|
82
|
+
title: `@${config.i18n}:safety-plan-type-sections.entities.safety-plan-type-section.title`,
|
|
83
|
+
titlePlural: `@${config.i18n}:safety-plan-type-sections.entities.safety-plan-type-section.plural`,
|
|
84
|
+
icon: 'fa-light fa-list-ol',
|
|
85
|
+
},
|
|
86
|
+
sectionType: {
|
|
87
|
+
name: 'SectionType',
|
|
88
|
+
source: `${config.module}.SectionType`,
|
|
89
|
+
title: `@${config.i18n}:section-types.entities.section-type.title`,
|
|
90
|
+
titlePlural: `@${config.i18n}:section-types.entities.section-type.plural`,
|
|
91
|
+
icon: 'fa-light fa-list-tree',
|
|
92
|
+
},
|
|
93
|
+
safetyTemplate: {
|
|
94
|
+
name: 'SafetyTemplate',
|
|
95
|
+
source: `${config.module}.SafetyTemplate`,
|
|
96
|
+
title: `@${config.i18n}:safety-templates.entities.safety-template.title`,
|
|
97
|
+
titlePlural: `@${config.i18n}:safety-templates.entities.safety-template.plural`,
|
|
98
|
+
icon: 'fa-light fa-file-lines',
|
|
99
|
+
},
|
|
100
|
+
safetyPlanSection: {
|
|
101
|
+
name: 'SafetyPlanSection',
|
|
102
|
+
source: `${config.module}.SafetyPlanSection`,
|
|
103
|
+
title: `@${config.i18n}:safety-plan-sections.entities.safety-plan-section.title`,
|
|
104
|
+
titlePlural: `@${config.i18n}:safety-plan-sections.entities.safety-plan-section.plural`,
|
|
105
|
+
icon: 'fa-light fa-list-ol',
|
|
106
|
+
},
|
|
107
|
+
workStepType: {
|
|
108
|
+
name: 'WorkStepType',
|
|
109
|
+
source: `${config.module}.WorkStepType`,
|
|
110
|
+
title: `@${config.i18n}:work-step-types.entities.work-step-type.title`,
|
|
111
|
+
titlePlural: `@${config.i18n}:work-step-types.entities.work-step-type.plural`,
|
|
112
|
+
icon: 'fa-light fa-list-tree',
|
|
113
|
+
},
|
|
114
|
+
safetyPlanWorkStep: {
|
|
115
|
+
name: 'SafetyPlanWorkStep',
|
|
116
|
+
source: `${config.module}.SafetyPlanWorkStep`,
|
|
117
|
+
title: `@${config.i18n}:safety-plan-work-steps.entities.safety-plan-work-step.title`,
|
|
118
|
+
titlePlural: `@${config.i18n}:safety-plan-work-steps.entities.safety-plan-work-step.plural`,
|
|
119
|
+
icon: 'fa-light fa-list-check',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
queries: {
|
|
123
|
+
dashboard: {
|
|
124
|
+
openHazardsKpi: `${config.module}:Dashboard:OpenHazardsKpi`,
|
|
125
|
+
highRisksKpi: `${config.module}:Dashboard:HighRisksKpi`,
|
|
126
|
+
activeSafetyPlansKpi: `${config.module}:Dashboard:ActiveSafetyPlansKpi`,
|
|
127
|
+
take5ChecklistsKpi: `${config.module}:Dashboard:Take5ChecklistsKpi`,
|
|
128
|
+
take5CompletedKpi: `${config.module}:Dashboard:Take5CompletedKpi`,
|
|
129
|
+
hazardsByCategoryDonut: `${config.module}:Dashboard:HazardsByCategoryDonut`,
|
|
130
|
+
risksByRatingBar: `${config.module}:Dashboard:RisksByRatingBar`,
|
|
131
|
+
plansByTypeBar: `${config.module}:Dashboard:PlansByTypeBar`,
|
|
132
|
+
hazardsByStatusBar: `${config.module}:Dashboard:HazardsByStatusBar`,
|
|
133
|
+
ppeCoverageDonut: `${config.module}:Dashboard:PpeCoverageDonut`,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#region ---- Imports ----
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region ---- Built-in section type IDs ----
|
|
141
|
+
/** Stable IDs for seeded built-in section types (shared by server mocks and client lookups). */
|
|
142
|
+
const WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS = {
|
|
143
|
+
hazard: 'c1d2e3f4-a5b6-4789-c001-000000000001',
|
|
144
|
+
hazardRisk: 'c1d2e3f4-a5b6-4789-c001-000000000002',
|
|
145
|
+
ppe: 'c1d2e3f4-a5b6-4789-c001-000000000003',
|
|
146
|
+
control: 'c1d2e3f4-a5b6-4789-c001-000000000004',
|
|
147
|
+
hierarchyLevel: 'c1d2e3f4-a5b6-4789-c001-000000000005',
|
|
148
|
+
custom: 'c1d2e3f4-a5b6-4789-c001-000000000006',
|
|
149
|
+
ppeHazards: 'c1d2e3f4-a5b6-4789-c001-000000000007',
|
|
150
|
+
riskMatrix: 'c1d2e3f4-a5b6-4789-c001-000000000008',
|
|
151
|
+
hazardRiskPpe: 'c1d2e3f4-a5b6-4789-c001-000000000009',
|
|
152
|
+
stepTable: 'c1d2e3f4-a5b6-4789-c001-00000000000a',
|
|
153
|
+
};
|
|
154
|
+
const moduleName = RootConfig.module.name;
|
|
155
|
+
/** Maps section type codes to the entity that supplies selectable items. */
|
|
156
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE = {
|
|
157
|
+
Hazard: `${moduleName}.${RootConfig.entities.hazard.name}`,
|
|
158
|
+
HazardRisk: `${moduleName}.${RootConfig.entities.hazardRisk.name}`,
|
|
159
|
+
Ppe: `${moduleName}.${RootConfig.entities.ppeItem.name}`,
|
|
160
|
+
PpeHazards: `${moduleName}.${RootConfig.entities.hazardPpeRule.name}`,
|
|
161
|
+
HazardRiskPpe: undefined,
|
|
162
|
+
Control: `${moduleName}.${RootConfig.entities.controlMeasure.name}`,
|
|
163
|
+
HierarchyLevel: `${moduleName}.${RootConfig.entities.controlHierarchyLevels.name}`,
|
|
164
|
+
RiskMatrix: 'RiskManagement.RiskMatrixCell',
|
|
165
|
+
Custom: undefined,
|
|
166
|
+
/** Host section for SafetyPlanWorkStep rows (managed by the section builder, not a catalog picker). */
|
|
167
|
+
StepTable: undefined,
|
|
168
|
+
};
|
|
169
|
+
/** Built-in section types resolved by stable section type id. */
|
|
170
|
+
const WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID = {
|
|
171
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazard]: {
|
|
172
|
+
sectionTypeKey: 'Hazard',
|
|
173
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.Hazard,
|
|
174
|
+
},
|
|
175
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRisk]: {
|
|
176
|
+
sectionTypeKey: 'HazardRisk',
|
|
177
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.HazardRisk,
|
|
178
|
+
},
|
|
179
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppe]: {
|
|
180
|
+
sectionTypeKey: 'Ppe',
|
|
181
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.Ppe,
|
|
182
|
+
},
|
|
183
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards]: {
|
|
184
|
+
sectionTypeKey: 'PpeHazards',
|
|
185
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.PpeHazards,
|
|
186
|
+
},
|
|
187
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe]: {
|
|
188
|
+
sectionTypeKey: 'HazardRiskPpe',
|
|
189
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.HazardRiskPpe,
|
|
190
|
+
},
|
|
191
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.control]: {
|
|
192
|
+
sectionTypeKey: 'Control',
|
|
193
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.Control,
|
|
194
|
+
},
|
|
195
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hierarchyLevel]: {
|
|
196
|
+
sectionTypeKey: 'HierarchyLevel',
|
|
197
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.HierarchyLevel,
|
|
198
|
+
},
|
|
199
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.riskMatrix]: {
|
|
200
|
+
sectionTypeKey: 'RiskMatrix',
|
|
201
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.RiskMatrix,
|
|
202
|
+
},
|
|
203
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.custom]: {
|
|
204
|
+
sectionTypeKey: 'Custom',
|
|
205
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.Custom,
|
|
206
|
+
isRepeatable: true,
|
|
207
|
+
},
|
|
208
|
+
[WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.stepTable]: {
|
|
209
|
+
sectionTypeKey: 'StepTable',
|
|
210
|
+
itemEntityName: WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_BY_CODE.StepTable,
|
|
211
|
+
isRepeatable: true,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
/** Default entity so the lookup widget mounts before a section type is chosen. */
|
|
215
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_FALLBACK = `${moduleName}.${RootConfig.entities.hazard.name}`;
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region ---- Snapshot helpers ----
|
|
218
|
+
function resolveSectionTypeKey(sectionTypeId, snapshot) {
|
|
219
|
+
const fromSnapshot = snapshot?.sectionTypeKey;
|
|
220
|
+
if (typeof fromSnapshot === 'string' && fromSnapshot.length > 0) {
|
|
221
|
+
return fromSnapshot;
|
|
222
|
+
}
|
|
223
|
+
if (!sectionTypeId) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
return WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID[sectionTypeId]
|
|
227
|
+
?.sectionTypeKey;
|
|
228
|
+
}
|
|
229
|
+
function resolveSectionItemEntityName(sectionTypeId, snapshot) {
|
|
230
|
+
const fromSnapshot = snapshot?.itemEntityName;
|
|
231
|
+
if (typeof fromSnapshot === 'string' && fromSnapshot.length > 0) {
|
|
232
|
+
return fromSnapshot;
|
|
233
|
+
}
|
|
234
|
+
if (!sectionTypeId) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
return WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID[sectionTypeId]
|
|
238
|
+
?.itemEntityName;
|
|
239
|
+
}
|
|
240
|
+
/** Adds runtime lookup metadata (`sectionTypeKey`, `itemEntityName`) from built-in id map. */
|
|
241
|
+
function enrichSectionTypeSnapshot(sectionTypeId, snapshot) {
|
|
242
|
+
if (!sectionTypeId) {
|
|
243
|
+
return snapshot;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
...snapshot,
|
|
247
|
+
id: sectionTypeId,
|
|
248
|
+
sectionTypeKey: resolveSectionTypeKey(sectionTypeId, snapshot),
|
|
249
|
+
itemEntityName: resolveSectionItemEntityName(sectionTypeId, snapshot),
|
|
250
|
+
isRepeatable: snapshot?.isRepeatable ??
|
|
251
|
+
WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID[sectionTypeId]?.isRepeatable,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region ---- Dynamic entity expressions ----
|
|
256
|
+
function buildSectionTypeEntityExpressionById(sectionTypeIdPath) {
|
|
257
|
+
const parts = Object.entries(WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID)
|
|
258
|
+
.filter(([, meta]) => meta.itemEntityName)
|
|
259
|
+
.map(([id, meta]) => `context.eval('${sectionTypeIdPath}') === '${id}' ? '${meta.itemEntityName}'`);
|
|
260
|
+
return `{{ ${parts.join(' : ')} : '${WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_FALLBACK}' }}`;
|
|
261
|
+
}
|
|
262
|
+
function buildSectionTypeEntityExpressionWithSnapshotFallback(sectionTypeIdPath, itemEntityNamePath) {
|
|
263
|
+
const byId = buildSectionTypeEntityExpressionById(sectionTypeIdPath).slice(3, -2);
|
|
264
|
+
return `{{ context.eval('${itemEntityNamePath}') || (${byId}) }}`;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* For repeater / nested FormField widgets — `>` walks up to the row where `sectionType` is exposed.
|
|
268
|
+
*/
|
|
269
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_EXPRESSION = buildSectionTypeEntityExpressionWithSnapshotFallback('>sectionType.id', '>sectionType.itemEntityName');
|
|
270
|
+
/**
|
|
271
|
+
* For flat dialog / dynamic forms — sibling fields share the same context (no parent path).
|
|
272
|
+
*/
|
|
273
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_ENTITY_EXPRESSION_SIBLING = buildSectionTypeEntityExpressionWithSnapshotFallback('sectionType.id', 'sectionType.itemEntityName');
|
|
274
|
+
//#endregion
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Shared helpers for Safety Plan Section type identity (repeatable vs one-off).
|
|
278
|
+
* Leaf module — imports only other contract leaves (no client/server layers).
|
|
279
|
+
*/
|
|
280
|
+
//#region ---- Helpers ----
|
|
281
|
+
function resolveRefId(raw) {
|
|
282
|
+
if (typeof raw === 'string' && raw.trim().length > 0) {
|
|
283
|
+
return raw.trim();
|
|
284
|
+
}
|
|
285
|
+
if (typeof raw === 'number' && Number.isFinite(raw)) {
|
|
286
|
+
return String(raw);
|
|
287
|
+
}
|
|
288
|
+
if (raw && typeof raw === 'object') {
|
|
289
|
+
const id = raw.id;
|
|
290
|
+
if (typeof id === 'string' && id.trim().length > 0) {
|
|
291
|
+
return id.trim();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return '';
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* True when this section type may appear more than once in a Safety Plan.
|
|
298
|
+
* Checks (in order): snapshot flag, explicit allow-list, built-in section type meta.
|
|
299
|
+
*/
|
|
300
|
+
function isSafetyPlanSectionTypeRepeatable(sectionTypeId, options) {
|
|
301
|
+
const id = resolveRefId(sectionTypeId);
|
|
302
|
+
if (!id) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (options?.sectionType?.isRepeatable === true) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const allowList = new Set((options?.repeatableSectionTypeIds ?? []).map((entry) => resolveRefId(entry)).filter(Boolean));
|
|
309
|
+
if (allowList.has(id)) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
return WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID[id]?.isRepeatable === true;
|
|
313
|
+
}
|
|
314
|
+
/** Built-in section type ids that are always treated as repeatable. */
|
|
315
|
+
function collectBuiltInRepeatableSectionTypeIds() {
|
|
316
|
+
return Object.entries(WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID)
|
|
317
|
+
.filter(([, meta]) => meta.isRepeatable === true)
|
|
318
|
+
.map(([id]) => id);
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
|
|
322
|
+
//#region ---- Imports ----
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region ---- Display helpers ----
|
|
325
|
+
/** Coerces a stored string or locale map into a single display string. */
|
|
326
|
+
function asSafetyPlanDisplayText(value) {
|
|
327
|
+
if (typeof value === 'string') {
|
|
328
|
+
return value.trim();
|
|
329
|
+
}
|
|
330
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
331
|
+
const rec = value;
|
|
332
|
+
for (const locale of ['en-US', 'en-AU', 'en', 'fa-IR']) {
|
|
333
|
+
const part = rec[locale];
|
|
334
|
+
if (typeof part === 'string' && part.trim()) {
|
|
335
|
+
return part.trim();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
for (const part of Object.values(rec)) {
|
|
339
|
+
if (typeof part === 'string' && part.trim()) {
|
|
340
|
+
return part.trim();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return '';
|
|
345
|
+
}
|
|
346
|
+
function buildSectionTypeRelationSnapshot(sectionTypeId, snapshot) {
|
|
347
|
+
const title = asSafetyPlanDisplayText(snapshot?.title);
|
|
348
|
+
const code = asSafetyPlanDisplayText(snapshot?.code);
|
|
349
|
+
const description = asSafetyPlanDisplayText(snapshot?.description);
|
|
350
|
+
return {
|
|
351
|
+
id: sectionTypeId,
|
|
352
|
+
...(title ? { title } : {}),
|
|
353
|
+
...(code ? { code } : {}),
|
|
354
|
+
...(description ? { description } : {}),
|
|
355
|
+
...(snapshot?.isRepeatable === true ? { isRepeatable: true } : {}),
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function resolveSectionTypeTitle(sectionTypeId, sectionType) {
|
|
359
|
+
const title = asSafetyPlanDisplayText(sectionType?.title);
|
|
360
|
+
if (title) {
|
|
361
|
+
return title;
|
|
362
|
+
}
|
|
363
|
+
const code = asSafetyPlanDisplayText(sectionType?.code);
|
|
364
|
+
if (code) {
|
|
365
|
+
return code;
|
|
366
|
+
}
|
|
367
|
+
const builtIn = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID[sectionTypeId]?.sectionTypeKey;
|
|
368
|
+
if (builtIn) {
|
|
369
|
+
return builtIn;
|
|
370
|
+
}
|
|
371
|
+
return sectionTypeId;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Title persisted on SafetyPlanSection. Never stores a bare UUID — the UI translate
|
|
375
|
+
* pipe treats unknown keys as empty, which made seeded section headers blank.
|
|
376
|
+
*/
|
|
377
|
+
function resolveSafetyPlanSectionPersistedTitle(sectionTitle, sectionTypeId, snapshot) {
|
|
378
|
+
const explicit = asSafetyPlanDisplayText(sectionTitle);
|
|
379
|
+
if (explicit && explicit !== sectionTypeId) {
|
|
380
|
+
return explicit;
|
|
381
|
+
}
|
|
382
|
+
const fromType = resolveSectionTypeTitle(sectionTypeId, snapshot);
|
|
383
|
+
if (fromType && fromType !== sectionTypeId) {
|
|
384
|
+
return fromType;
|
|
385
|
+
}
|
|
386
|
+
return 'Section';
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region ---- Ref helpers ----
|
|
390
|
+
/** True when a type-section row is marked as the plan-type default template. */
|
|
391
|
+
function isSafetyPlanTypeSectionDefault(row) {
|
|
392
|
+
const value = row?.isDefault;
|
|
393
|
+
return value === true || value === 1 || value === 'true';
|
|
394
|
+
}
|
|
395
|
+
/** Extracts a stable entity id from a raw lookup / context value. */
|
|
396
|
+
function resolveEntityRefId(raw) {
|
|
397
|
+
if (typeof raw === 'string' && raw.trim().length > 0) {
|
|
398
|
+
return raw.trim();
|
|
399
|
+
}
|
|
400
|
+
if (typeof raw === 'number' && Number.isFinite(raw)) {
|
|
401
|
+
return String(raw);
|
|
402
|
+
}
|
|
403
|
+
if (raw && typeof raw === 'object') {
|
|
404
|
+
const id = raw.id;
|
|
405
|
+
if (typeof id === 'string' && id.trim().length > 0) {
|
|
406
|
+
return id.trim();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
function resolveSectionTypeId(typeRow) {
|
|
412
|
+
if (!typeRow) {
|
|
413
|
+
return '';
|
|
414
|
+
}
|
|
415
|
+
return (resolveEntityRefId(typeRow.sectionTypeId) ??
|
|
416
|
+
resolveEntityRefId(typeRow.sectionType) ??
|
|
417
|
+
resolveEntityRefId(typeRow.sectionType?.id) ??
|
|
418
|
+
'');
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region ---- Build from type sections ----
|
|
422
|
+
let structureIdSeq = 0;
|
|
423
|
+
function nextStructureId(prefix) {
|
|
424
|
+
structureIdSeq += 1;
|
|
425
|
+
const rand = createRandomUuid();
|
|
426
|
+
return prefix ? `${prefix}-${rand}` : rand;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Builds an empty editable section structure from SafetyPlanTypeSection rows for one plan type.
|
|
430
|
+
*
|
|
431
|
+
* Uses `isDefault` rows when present; otherwise falls back to all active rows for that type
|
|
432
|
+
* (so a mis-flagged template still produces a structure). One plan section per `sectionTypeIds`
|
|
433
|
+
* entry, titled from the Section Type, ordered by type-section `sortOrder` then repeater order.
|
|
434
|
+
*/
|
|
435
|
+
function buildSectionStructureFromTypeSections(typeSections, options) {
|
|
436
|
+
const createId = options?.createId ?? (() => nextStructureId(''));
|
|
437
|
+
const active = typeSections
|
|
438
|
+
.filter((row) => row && row.isArchived !== true)
|
|
439
|
+
.slice()
|
|
440
|
+
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0) || String(a.title ?? '').localeCompare(String(b.title ?? '')));
|
|
441
|
+
const defaults = active.filter((row) => isSafetyPlanTypeSectionDefault(row));
|
|
442
|
+
const sourceRows = defaults.length > 0 ? defaults : active;
|
|
443
|
+
const sections = [];
|
|
444
|
+
const seenSourceTypePairs = new Set();
|
|
445
|
+
let sortOrder = 1;
|
|
446
|
+
for (const typeSection of sourceRows) {
|
|
447
|
+
const typeRows = Array.isArray(typeSection.sectionTypeIds) ? typeSection.sectionTypeIds : [];
|
|
448
|
+
if (!typeRows.length) {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
for (const typeRow of typeRows) {
|
|
452
|
+
const sectionTypeId = resolveSectionTypeId(typeRow);
|
|
453
|
+
if (!sectionTypeId) {
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
// One plan section per (type-section source, section type) — prevents
|
|
457
|
+
// accidental double expansion when the same type is listed twice.
|
|
458
|
+
const sourceId = typeof typeSection.id === 'string' ? typeSection.id : '';
|
|
459
|
+
const pairKey = sourceId ? `${sourceId}|${sectionTypeId}` : sectionTypeId;
|
|
460
|
+
if (seenSourceTypePairs.has(pairKey)) {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
seenSourceTypePairs.add(pairKey);
|
|
464
|
+
const sectionType = buildSectionTypeRelationSnapshot(sectionTypeId, typeRow.sectionType);
|
|
465
|
+
const sectionId = createId();
|
|
466
|
+
sections.push({
|
|
467
|
+
id: sectionId,
|
|
468
|
+
sectionTypeId,
|
|
469
|
+
sectionType,
|
|
470
|
+
title: resolveSafetyPlanSectionPersistedTitle(undefined, sectionTypeId, sectionType),
|
|
471
|
+
description: asSafetyPlanDisplayText(sectionType.description),
|
|
472
|
+
sourceSafetyPlanTypeSectionId: typeSection.id,
|
|
473
|
+
sortOrder: sortOrder++,
|
|
474
|
+
required: isSafetyPlanTypeSectionDefault(typeSection) || defaults.length === 0,
|
|
475
|
+
items: [
|
|
476
|
+
{
|
|
477
|
+
id: `${sectionId}__item_1`,
|
|
478
|
+
itemIds: [],
|
|
479
|
+
items: [],
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return { sections };
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Removes accidental ghost rows from double materialization of the same type-section
|
|
489
|
+
* source. Distinct sections of the same type are kept. Reassigns contiguous 1-based
|
|
490
|
+
* `sortOrder` to preserve display order.
|
|
491
|
+
*/
|
|
492
|
+
function dedupeSafetyPlanSectionStructure(structure, _options) {
|
|
493
|
+
const sections = Array.isArray(structure?.sections)
|
|
494
|
+
? structure.sections
|
|
495
|
+
: [];
|
|
496
|
+
const seenSourceTypePairs = new Set();
|
|
497
|
+
const deduped = [];
|
|
498
|
+
for (const section of sections) {
|
|
499
|
+
const sectionTypeId = resolveEntityRefId(section.sectionTypeId) ?? String(section.sectionTypeId ?? '').trim();
|
|
500
|
+
if (!sectionTypeId) {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
const sourceId = String(section.sourceSafetyPlanTypeSectionId ?? '').trim();
|
|
504
|
+
const sourcePairKey = sourceId ? `${sourceId}|${sectionTypeId}` : '';
|
|
505
|
+
// Same type-section source + section type must never appear twice (double materialization).
|
|
506
|
+
if (sourcePairKey && seenSourceTypePairs.has(sourcePairKey)) {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
if (sourcePairKey) {
|
|
510
|
+
seenSourceTypePairs.add(sourcePairKey);
|
|
511
|
+
}
|
|
512
|
+
deduped.push(section);
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
...structure,
|
|
516
|
+
sections: deduped.map((section, index) => ({
|
|
517
|
+
...section,
|
|
518
|
+
sortOrder: index + 1,
|
|
519
|
+
})),
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function collectAllowedSectionTypeIds(typeSections) {
|
|
523
|
+
const ids = new Set();
|
|
524
|
+
for (const typeSection of typeSections) {
|
|
525
|
+
if (typeSection.isArchived === true) {
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
for (const row of typeSection.sectionTypeIds ?? []) {
|
|
529
|
+
const id = resolveSectionTypeId(row);
|
|
530
|
+
if (id) {
|
|
531
|
+
ids.add(id);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return [...ids];
|
|
536
|
+
}
|
|
537
|
+
function collectRequiredSourceTypeSectionIds(typeSections) {
|
|
538
|
+
return typeSections
|
|
539
|
+
.filter((row) => row.isArchived !== true && isSafetyPlanTypeSectionDefault(row))
|
|
540
|
+
.map((row) => row.id)
|
|
541
|
+
.filter((id) => typeof id === 'string' && id.length > 0);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Validates that a plan-type section template does not list the same
|
|
545
|
+
* non-repeatable section type more than once (across rows and within a single row's repeater).
|
|
546
|
+
*/
|
|
547
|
+
function validateSafetyPlanTypeSectionTemplate(typeSections, repeatableSectionTypeIds = []) {
|
|
548
|
+
const seen = new Map();
|
|
549
|
+
const issues = [];
|
|
550
|
+
for (const typeSection of typeSections) {
|
|
551
|
+
if (typeSection.isArchived === true) {
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
for (const row of typeSection.sectionTypeIds ?? []) {
|
|
555
|
+
const sectionTypeId = resolveSectionTypeId(row);
|
|
556
|
+
if (!sectionTypeId ||
|
|
557
|
+
isSafetyPlanSectionTypeRepeatable(sectionTypeId, {
|
|
558
|
+
repeatableSectionTypeIds,
|
|
559
|
+
sectionType: row.sectionType,
|
|
560
|
+
})) {
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
const sectionTypeTitle = resolveSafetyPlanSectionPersistedTitle(undefined, sectionTypeId, row.sectionType);
|
|
564
|
+
if (seen.has(sectionTypeId)) {
|
|
565
|
+
issues.push({
|
|
566
|
+
code: 'INVALID_TYPE_SECTION_TEMPLATE',
|
|
567
|
+
messageKey: '@workplacesafety-management:safety-plans.messages.section-structure.invalid-type-template-duplicate',
|
|
568
|
+
details: {
|
|
569
|
+
sectionTypeId,
|
|
570
|
+
sectionTypeTitle,
|
|
571
|
+
sourceSafetyPlanTypeSectionId: typeSection.id,
|
|
572
|
+
previousSourceSafetyPlanTypeSectionId: seen.get(sectionTypeId)?.sourceSafetyPlanTypeSectionId,
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
seen.set(sectionTypeId, {
|
|
578
|
+
title: sectionTypeTitle,
|
|
579
|
+
sourceSafetyPlanTypeSectionId: typeSection.id,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return issues;
|
|
584
|
+
}
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region ---- Validation ----
|
|
587
|
+
function validateSafetyPlanSectionStructure(structure, context) {
|
|
588
|
+
const sections = Array.isArray(structure?.sections) ? structure.sections : [];
|
|
589
|
+
const issues = [];
|
|
590
|
+
const presentSourceIds = new Set(sections
|
|
591
|
+
.map((s) => s.sourceSafetyPlanTypeSectionId)
|
|
592
|
+
.filter((id) => typeof id === 'string' && id.length > 0));
|
|
593
|
+
for (const requiredSourceId of context.requiredSourceTypeSectionIds) {
|
|
594
|
+
if (!presentSourceIds.has(requiredSourceId)) {
|
|
595
|
+
issues.push({
|
|
596
|
+
code: 'REQUIRED_SECTION_MISSING',
|
|
597
|
+
messageKey: '@workplacesafety-management:safety-plans.messages.section-structure.required-section-missing',
|
|
598
|
+
details: { sourceSafetyPlanTypeSectionId: requiredSourceId },
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const allowed = new Set(context.allowedSectionTypeIds);
|
|
603
|
+
const sortOrders = [];
|
|
604
|
+
for (const section of sections) {
|
|
605
|
+
const sectionTypeId = resolveEntityRefId(section.sectionTypeId) ??
|
|
606
|
+
String(section.sectionTypeId ?? '').trim();
|
|
607
|
+
if (!sectionTypeId) {
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
const sectionType = section
|
|
611
|
+
.sectionType;
|
|
612
|
+
const sectionTypeTitle = resolveSafetyPlanSectionPersistedTitle(undefined, sectionTypeId, sectionType);
|
|
613
|
+
if (allowed.size > 0 && !allowed.has(sectionTypeId)) {
|
|
614
|
+
issues.push({
|
|
615
|
+
code: 'SECTION_TYPE_NOT_ALLOWED',
|
|
616
|
+
messageKey: '@workplacesafety-management:safety-plans.messages.section-structure.section-type-not-allowed',
|
|
617
|
+
details: { sectionTypeId, sectionTypeTitle, sectionId: section.id },
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
const sortOrder = section.sortOrder;
|
|
621
|
+
if (typeof sortOrder === 'number' && Number.isFinite(sortOrder)) {
|
|
622
|
+
sortOrders.push(sortOrder);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (sortOrders.length !== sections.length) {
|
|
626
|
+
issues.push({
|
|
627
|
+
code: 'INVALID_SORT_ORDER',
|
|
628
|
+
messageKey: '@workplacesafety-management:safety-plans.messages.section-structure.invalid-sort-order',
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
const unique = new Set(sortOrders);
|
|
633
|
+
if (unique.size !== sortOrders.length) {
|
|
634
|
+
issues.push({
|
|
635
|
+
code: 'INVALID_SORT_ORDER',
|
|
636
|
+
messageKey: '@workplacesafety-management:safety-plans.messages.section-structure.invalid-sort-order',
|
|
637
|
+
details: { reason: 'duplicate' },
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return issues;
|
|
642
|
+
}
|
|
643
|
+
function toBuilderValueFromStructure(structure) {
|
|
644
|
+
return {
|
|
645
|
+
sections: structure.sections.map((section) => ({
|
|
646
|
+
id: section.id,
|
|
647
|
+
sectionTypeId: section.sectionTypeId,
|
|
648
|
+
sectionType: section.sectionType,
|
|
649
|
+
title: section.title,
|
|
650
|
+
description: section.description ?? '',
|
|
651
|
+
safetyPlanId: section.safetyPlanId,
|
|
652
|
+
code: section.code,
|
|
653
|
+
sourceSafetyPlanTypeSectionId: section.sourceSafetyPlanTypeSectionId,
|
|
654
|
+
sortOrder: section.sortOrder,
|
|
655
|
+
required: section.required,
|
|
656
|
+
items: section.items.map((item) => ({
|
|
657
|
+
id: item.id,
|
|
658
|
+
itemIds: [...(item.itemIds ?? [])],
|
|
659
|
+
items: item.items ? [...item.items] : [],
|
|
660
|
+
})),
|
|
661
|
+
})),
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
//#endregion
|
|
665
|
+
|
|
666
|
+
//#region ---- Imports ----
|
|
667
|
+
/** Declarative section-type dependencies resolved from prior sections in plan order. */
|
|
668
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_DEPENDENCIES = {
|
|
669
|
+
HazardRisk: {
|
|
670
|
+
kind: 'parentFilter',
|
|
671
|
+
parentSectionTypeKey: 'Hazard',
|
|
672
|
+
filterField: 'hazardId',
|
|
673
|
+
},
|
|
674
|
+
PpeHazards: {
|
|
675
|
+
kind: 'parentFilter',
|
|
676
|
+
parentSectionTypeKey: 'Hazard',
|
|
677
|
+
filterField: 'hazardId',
|
|
678
|
+
},
|
|
679
|
+
HazardRiskPpe: {
|
|
680
|
+
kind: 'parentFilter',
|
|
681
|
+
parentSectionTypeKey: 'HazardRisk',
|
|
682
|
+
filterField: 'hazardRiskId',
|
|
683
|
+
},
|
|
684
|
+
RiskMatrix: {
|
|
685
|
+
kind: 'derivedFromParent',
|
|
686
|
+
parentSectionTypeKey: 'HazardRisk',
|
|
687
|
+
resolveField: 'riskMatrixId',
|
|
688
|
+
filterField: 'id',
|
|
689
|
+
},
|
|
690
|
+
};
|
|
691
|
+
/** Section types cleared when upstream hazard selections change. */
|
|
692
|
+
const WORKPLACE_SAFETY_DOWNSTREAM_FROM_HAZARD = [
|
|
693
|
+
'HazardRisk',
|
|
694
|
+
'PpeHazards',
|
|
695
|
+
'HazardRiskPpe',
|
|
696
|
+
'RiskMatrix',
|
|
697
|
+
];
|
|
698
|
+
/** Section types cleared when upstream hazard-risk selections change. */
|
|
699
|
+
const WORKPLACE_SAFETY_DOWNSTREAM_FROM_HAZARD_RISK = [
|
|
700
|
+
'HazardRiskPpe',
|
|
701
|
+
'RiskMatrix',
|
|
702
|
+
];
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region ---- Lookup helpers ----
|
|
705
|
+
const PARENT_HAZARD_IDS_CONTEXT_KEY = 'parentHazardIds';
|
|
706
|
+
const PARENT_HAZARD_RISK_IDS_CONTEXT_KEY = 'parentHazardRiskIds';
|
|
707
|
+
/** Expose paths when a section type is selected (shared by entity repeater and builder dialog). */
|
|
708
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_LOOKUP_EXPOSE = [
|
|
709
|
+
{ source: 'id', target: 'sectionType.id' },
|
|
710
|
+
{ source: 'title', target: 'sectionType.title' },
|
|
711
|
+
{ source: 'code', target: 'sectionType.code' },
|
|
712
|
+
{ source: 'description', target: 'sectionType.description' },
|
|
713
|
+
{ source: 'isRepeatable', target: 'sectionType.isRepeatable' },
|
|
714
|
+
];
|
|
715
|
+
/** Auto-fill section description when section type is selected. */
|
|
716
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_DESCRIPTION_SYNC_TRIGGERS = [
|
|
717
|
+
{
|
|
718
|
+
event: "{{ events.context('sectionTypeId') }}",
|
|
719
|
+
action: "{{ const items = widget.output('selectedItems'); const selectedDescription = Array.isArray(items) ? items[0]?.description : undefined; const d = selectedDescription || context.eval('sectionType.description') || ''; context.set('sectionTypeDescription', d); const descriptionWidget = widget.find('sectionTypeDescription'); if (descriptionWidget) { descriptionWidget.setValue(d); } }}",
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
event: "{{ events.context('sectionType.description') }}",
|
|
723
|
+
action: "{{ const d = context.eval('sectionType.description') || ''; context.set('sectionTypeDescription', d); const descriptionWidget = widget.find('sectionTypeDescription'); if (descriptionWidget) { descriptionWidget.setValue(d); } }}",
|
|
724
|
+
},
|
|
725
|
+
];
|
|
726
|
+
/** Auto-fill section title when section type is selected. */
|
|
727
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_TITLE_SYNC_TRIGGERS = [
|
|
728
|
+
{
|
|
729
|
+
event: "{{ events.context('sectionTypeId') }}",
|
|
730
|
+
action: "{{ const items = widget.output('selectedItems'); const selectedTitle = Array.isArray(items) ? items[0]?.title : undefined; const t = selectedTitle || context.eval('sectionType.title') || ''; if (t) { context.set('title', t); const titleWidget = widget.find('title'); if (titleWidget) { titleWidget.setValue(t); } } }}",
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
event: "{{ events.context('sectionType.title') }}",
|
|
734
|
+
action: "{{ const t = context.eval('sectionType.title') || ''; if (t) { context.set('title', t); const titleWidget = widget.find('title'); if (titleWidget) { titleWidget.setValue(t); } } }}",
|
|
735
|
+
},
|
|
736
|
+
];
|
|
737
|
+
/** Shared lookup widget options for section type pickers (builder dialog and entity forms). */
|
|
738
|
+
const WORKPLACE_SAFETY_SECTION_TYPE_LOOKUP_WIDGET_OPTIONS = {
|
|
739
|
+
look: 'select',
|
|
740
|
+
allowSearch: true,
|
|
741
|
+
textField: 'code',
|
|
742
|
+
textTemplate: '{code} — {description}',
|
|
743
|
+
valueField: 'id',
|
|
744
|
+
columns: ['code', 'title', 'description'],
|
|
745
|
+
expose: WORKPLACE_SAFETY_SECTION_TYPE_LOOKUP_EXPOSE,
|
|
746
|
+
triggers: [
|
|
747
|
+
...WORKPLACE_SAFETY_SECTION_TYPE_TITLE_SYNC_TRIGGERS,
|
|
748
|
+
...WORKPLACE_SAFETY_SECTION_TYPE_DESCRIPTION_SYNC_TRIGGERS,
|
|
749
|
+
],
|
|
750
|
+
};
|
|
751
|
+
//#endregion
|
|
752
|
+
//#region ---- Resolver API ----
|
|
753
|
+
function getSectionTypeDependency(sectionTypeKey) {
|
|
754
|
+
if (!sectionTypeKey) {
|
|
755
|
+
return undefined;
|
|
756
|
+
}
|
|
757
|
+
return WORKPLACE_SAFETY_SECTION_TYPE_DEPENDENCIES[sectionTypeKey];
|
|
758
|
+
}
|
|
759
|
+
function sectionTypeKeyFromSection(section) {
|
|
760
|
+
const sectionTypeId = section.sectionTypeId || section.sectionType?.id;
|
|
761
|
+
const key = resolveSectionTypeKey(sectionTypeId, section.sectionType);
|
|
762
|
+
return key;
|
|
763
|
+
}
|
|
764
|
+
function collectSectionItemIds(section, sectionTypeKey) {
|
|
765
|
+
if (!section?.items?.length || sectionTypeKeyFromSection(section) !== sectionTypeKey) {
|
|
766
|
+
return [];
|
|
767
|
+
}
|
|
768
|
+
const ids = new Set();
|
|
769
|
+
for (const item of section.items) {
|
|
770
|
+
for (const id of item.itemIds ?? []) {
|
|
771
|
+
if (typeof id === 'string' && id.length > 0) {
|
|
772
|
+
ids.add(id);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return [...ids];
|
|
777
|
+
}
|
|
778
|
+
/** Collects item IDs from sections up to `sectionIndex` whose type matches `parentSectionTypeKey`. */
|
|
779
|
+
function resolveParentItemIds(sections, sectionIndex, parentSectionTypeKey) {
|
|
780
|
+
const ids = new Set();
|
|
781
|
+
const lastIndex = Math.min(sectionIndex, sections.length - 1);
|
|
782
|
+
for (let index = 0; index <= lastIndex; index += 1) {
|
|
783
|
+
collectSectionItemIds(sections[index], parentSectionTypeKey).forEach((id) => ids.add(id));
|
|
784
|
+
}
|
|
785
|
+
return [...ids];
|
|
786
|
+
}
|
|
787
|
+
/** Collects hazard IDs from earlier sections and Hazard rows in the current section. */
|
|
788
|
+
function resolveParentHazardIds(sections, sectionIndex, parentSectionTypeKey = 'Hazard') {
|
|
789
|
+
return resolveParentItemIds(sections, sectionIndex, parentSectionTypeKey);
|
|
790
|
+
}
|
|
791
|
+
/** Collects hazard-risk IDs from prior HazardRisk sections up to `sectionIndex`. */
|
|
792
|
+
function resolveParentHazardRiskIds(sections, sectionIndex) {
|
|
793
|
+
return resolveParentItemIds(sections, sectionIndex, 'HazardRisk');
|
|
794
|
+
}
|
|
795
|
+
function parentItemSignature(sections, sectionIndex, parentSectionTypeKey) {
|
|
796
|
+
return resolveParentItemIds(sections, sectionIndex, parentSectionTypeKey).sort().join('|');
|
|
797
|
+
}
|
|
798
|
+
function shouldClearSectionOnParentChange(section, sectionIndex, changeIndex, parentTypeKey, downstreamTypes) {
|
|
799
|
+
if (sectionIndex < changeIndex) {
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
const sectionKey = sectionTypeKeyFromSection(section);
|
|
803
|
+
if (!sectionKey || !downstreamTypes.includes(sectionKey)) {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
if (sectionIndex === changeIndex && sectionKey === parentTypeKey) {
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
return section.items.some((item) => (item.itemIds?.length ?? 0) > 0);
|
|
810
|
+
}
|
|
811
|
+
function clearSectionItems(section) {
|
|
812
|
+
return {
|
|
813
|
+
...section,
|
|
814
|
+
items: section.items.map((item) => ({ ...item, itemIds: [], items: [] })),
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* When upstream hazard or hazard-risk selections change, clears item rows in later dependent sections.
|
|
819
|
+
*/
|
|
820
|
+
function clearDependentItemsOnParentChange(previous, next) {
|
|
821
|
+
if (!next.sections.length) {
|
|
822
|
+
return next;
|
|
823
|
+
}
|
|
824
|
+
let changeIndex = next.sections.length;
|
|
825
|
+
let hazardChanged = false;
|
|
826
|
+
let hazardRiskChanged = false;
|
|
827
|
+
for (let index = 0; index < next.sections.length; index += 1) {
|
|
828
|
+
const prevHazardSig = parentItemSignature(previous.sections, index, 'Hazard');
|
|
829
|
+
const nextHazardSig = parentItemSignature(next.sections, index, 'Hazard');
|
|
830
|
+
if (prevHazardSig !== nextHazardSig) {
|
|
831
|
+
changeIndex = Math.min(changeIndex, index);
|
|
832
|
+
hazardChanged = true;
|
|
833
|
+
}
|
|
834
|
+
const prevRiskSig = parentItemSignature(previous.sections, index, 'HazardRisk');
|
|
835
|
+
const nextRiskSig = parentItemSignature(next.sections, index, 'HazardRisk');
|
|
836
|
+
if (prevRiskSig !== nextRiskSig) {
|
|
837
|
+
changeIndex = Math.min(changeIndex, index);
|
|
838
|
+
hazardRiskChanged = true;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (changeIndex === next.sections.length) {
|
|
842
|
+
return next;
|
|
843
|
+
}
|
|
844
|
+
return {
|
|
845
|
+
sections: next.sections.map((section, sectionIndex) => {
|
|
846
|
+
const clearFromHazard = hazardChanged &&
|
|
847
|
+
shouldClearSectionOnParentChange(section, sectionIndex, changeIndex, 'Hazard', WORKPLACE_SAFETY_DOWNSTREAM_FROM_HAZARD);
|
|
848
|
+
const clearFromHazardRisk = hazardRiskChanged &&
|
|
849
|
+
shouldClearSectionOnParentChange(section, sectionIndex, changeIndex, 'HazardRisk', WORKPLACE_SAFETY_DOWNSTREAM_FROM_HAZARD_RISK);
|
|
850
|
+
if (!clearFromHazard && !clearFromHazardRisk) {
|
|
851
|
+
return section;
|
|
852
|
+
}
|
|
853
|
+
return clearSectionItems(section);
|
|
854
|
+
}),
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
function extractRiskMatrixIdsFromHazardRisks(records) {
|
|
858
|
+
const ids = new Set();
|
|
859
|
+
for (const record of records) {
|
|
860
|
+
const id = record['riskMatrixId'];
|
|
861
|
+
if (typeof id === 'string' && id.length > 0) {
|
|
862
|
+
ids.add(id);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return [...ids];
|
|
866
|
+
}
|
|
867
|
+
function buildInFilter(field, values) {
|
|
868
|
+
const unique = [...new Set(values.filter((id) => id.length > 0))];
|
|
869
|
+
if (!unique.length) {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
field,
|
|
874
|
+
operator: { type: 'in' },
|
|
875
|
+
value: unique,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
/** Filter that matches no records when parent context exists but derived IDs are empty. */
|
|
879
|
+
function buildEmptyResultFilter(field) {
|
|
880
|
+
return {
|
|
881
|
+
field,
|
|
882
|
+
operator: { type: 'in' },
|
|
883
|
+
value: ['00000000-0000-0000-0000-000000000000'],
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function resolveSafetyPlanSectionItemFilter(sectionTypeId, parentHazardIds, parentHazardRiskIds = []) {
|
|
887
|
+
const sectionTypeKey = resolveSectionTypeKey(sectionTypeId);
|
|
888
|
+
const dependency = getSectionTypeDependency(sectionTypeKey);
|
|
889
|
+
if (!dependency || dependency.kind !== 'parentFilter') {
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
const parentIds = dependency.parentSectionTypeKey === 'Hazard' ? parentHazardIds : parentHazardRiskIds;
|
|
893
|
+
if (!parentIds.length) {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
return buildInFilter(dependency.filterField, parentIds);
|
|
897
|
+
}
|
|
898
|
+
async function resolveSafetyPlanSectionItemFilterAsync(sectionTypeId, sections, sectionIndex, loadHazardRisks) {
|
|
899
|
+
const sectionTypeKey = resolveSectionTypeKey(sectionTypeId);
|
|
900
|
+
const dependency = getSectionTypeDependency(sectionTypeKey);
|
|
901
|
+
if (!dependency) {
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
904
|
+
if (dependency.kind === 'parentFilter') {
|
|
905
|
+
const parentIds = resolveParentItemIds(sections, sectionIndex, dependency.parentSectionTypeKey);
|
|
906
|
+
if (!parentIds.length) {
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
return buildInFilter(dependency.filterField, parentIds);
|
|
910
|
+
}
|
|
911
|
+
const parentIds = resolveParentItemIds(sections, sectionIndex, dependency.parentSectionTypeKey);
|
|
912
|
+
if (!parentIds.length) {
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
const records = await loadHazardRisks(parentIds);
|
|
916
|
+
const derivedIds = extractRiskMatrixIdsFromHazardRisks(records);
|
|
917
|
+
if (!derivedIds.length) {
|
|
918
|
+
return buildEmptyResultFilter(dependency.filterField);
|
|
919
|
+
}
|
|
920
|
+
return buildInFilter(dependency.filterField, derivedIds);
|
|
921
|
+
}
|
|
922
|
+
const defaultItemIdsPlaceholderKey = '@workplacesafety-management:safety-plan-sections.entities.safety-plan-section.fields.item-ids.placeholder';
|
|
923
|
+
/** Clears item selection when section type changes in item dialog context. */
|
|
924
|
+
const WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_CLEAR_ON_SECTION_TYPE_TRIGGERS = [
|
|
925
|
+
{
|
|
926
|
+
event: "{{ events.context('sectionType.id') }}",
|
|
927
|
+
action: "{{ widget.setValue([]); context.set('items', []); }}",
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
event: "{{ events.context('sectionTypeId') }}",
|
|
931
|
+
action: "{{ widget.setValue([]); context.set('items', []); }}",
|
|
932
|
+
},
|
|
933
|
+
];
|
|
934
|
+
/**
|
|
935
|
+
* Reloads lookup data after section type is resolved (`sectionType.id`, `itemEntityName`).
|
|
936
|
+
*/
|
|
937
|
+
const WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_REFRESH_ON_SECTION_TYPE_EXPOSE_TRIGGERS = [
|
|
938
|
+
{
|
|
939
|
+
event: "{{ events.context('sectionType.id') }}",
|
|
940
|
+
action: '{{ widget.refresh(); }}',
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
event: "{{ events.context('sectionType.itemEntityName') }}",
|
|
944
|
+
action: '{{ widget.refresh(); }}',
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
event: "{{ events.context('sectionTypeId') }}",
|
|
948
|
+
action: '{{ widget.refresh(); }}',
|
|
949
|
+
},
|
|
950
|
+
];
|
|
951
|
+
const WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_SECTION_TYPE_TRIGGERS = [
|
|
952
|
+
...WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_CLEAR_ON_SECTION_TYPE_TRIGGERS,
|
|
953
|
+
...WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_REFRESH_ON_SECTION_TYPE_EXPOSE_TRIGGERS,
|
|
954
|
+
];
|
|
955
|
+
function isPpeRuleSectionType(sectionTypeId) {
|
|
956
|
+
return (sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards ||
|
|
957
|
+
sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe);
|
|
958
|
+
}
|
|
959
|
+
function buildSectionTypeItemTextFieldExpression(sectionTypeIdPath) {
|
|
960
|
+
const ppeHazardsId = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards;
|
|
961
|
+
const hazardRiskPpeId = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe;
|
|
962
|
+
return `{{ [ '${ppeHazardsId}', '${hazardRiskPpeId}' ].includes(context.eval('${sectionTypeIdPath}')) ? 'ppeItem.title' : 'title' }}`;
|
|
963
|
+
}
|
|
964
|
+
function buildSectionTypeItemColumnsExpression(sectionTypeIdPath) {
|
|
965
|
+
const ppeHazardsId = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards;
|
|
966
|
+
const hazardRiskPpeId = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe;
|
|
967
|
+
const riskMatrixId = WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.riskMatrix;
|
|
968
|
+
return `{{ context.eval('${sectionTypeIdPath}') === '${riskMatrixId}' ? ['code', 'title', 'matrix'] : [ '${ppeHazardsId}', '${hazardRiskPpeId}' ].includes(context.eval('${sectionTypeIdPath}')) ? ['code', 'ppeItem.title', 'requirementType'] : ['code', 'title'] }}`;
|
|
969
|
+
}
|
|
970
|
+
function buildSectionTypeDependentParentFilter(sectionTypeIdPath, parentIdsContextKey, parentSectionTypeKey) {
|
|
971
|
+
const dependentSectionTypeIds = Object.entries(WORKPLACE_SAFETY_SECTION_TYPE_DEPENDENCIES)
|
|
972
|
+
.filter(([, config]) => config.kind === 'parentFilter' && config.parentSectionTypeKey === parentSectionTypeKey)
|
|
973
|
+
.map(([key]) => {
|
|
974
|
+
const id = Object.entries(WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_BY_ID).find(([, meta]) => meta.sectionTypeKey === key)?.[0];
|
|
975
|
+
return id ? `'${id}'` : undefined;
|
|
976
|
+
})
|
|
977
|
+
.filter((id) => Boolean(id))
|
|
978
|
+
.join(',');
|
|
979
|
+
return {
|
|
980
|
+
field: parentSectionTypeKey === 'Hazard' ? 'hazardId' : 'hazardRiskId',
|
|
981
|
+
operator: { type: 'in' },
|
|
982
|
+
value: `{{ [${dependentSectionTypeIds}].includes(context.eval('${sectionTypeIdPath}')) ? ((context.eval('${parentIdsContextKey}') || []).length ? context.eval('${parentIdsContextKey}') : undefined) : undefined }}`,
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function buildSectionTypeDependentHazardFilter(sectionTypeIdPath, parentHazardIdsContextKey) {
|
|
986
|
+
return buildSectionTypeDependentParentFilter(sectionTypeIdPath, parentHazardIdsContextKey, 'Hazard');
|
|
987
|
+
}
|
|
988
|
+
const sectionItemLookupExpose = [
|
|
989
|
+
{ source: 'id', target: 'items.{id}' },
|
|
990
|
+
{ source: 'title', target: 'items.{title}' },
|
|
991
|
+
{ source: 'code', target: 'items.{code}' },
|
|
992
|
+
{ source: 'ppeItem.id', target: 'items.{id}' },
|
|
993
|
+
{ source: 'ppeItem.title', target: 'items.{title}' },
|
|
994
|
+
{ source: 'ppeItem.code', target: 'items.{code}' },
|
|
995
|
+
];
|
|
996
|
+
/** Shared item lookup options for builder item dialog (`sectionType.*` in dialog context). */
|
|
997
|
+
function buildSafetyPlanSectionItemLookupOptions(entityExpression, options) {
|
|
998
|
+
const sectionTypeIdPath = options?.sectionTypeIdPath ?? 'sectionType.id';
|
|
999
|
+
const lookup = {
|
|
1000
|
+
entity: entityExpression,
|
|
1001
|
+
look: 'lookup',
|
|
1002
|
+
multiple: true,
|
|
1003
|
+
allowSearch: true,
|
|
1004
|
+
textField: buildSectionTypeItemTextFieldExpression(sectionTypeIdPath),
|
|
1005
|
+
columns: buildSectionTypeItemColumnsExpression(sectionTypeIdPath),
|
|
1006
|
+
placeholder: options?.defaultPlaceholderKey ?? defaultItemIdsPlaceholderKey,
|
|
1007
|
+
expose: sectionItemLookupExpose,
|
|
1008
|
+
triggers: WORKPLACE_SAFETY_SECTION_ITEM_LOOKUP_SECTION_TYPE_TRIGGERS,
|
|
1009
|
+
};
|
|
1010
|
+
const filters = [];
|
|
1011
|
+
if (options?.parentHazardIdsContextKey) {
|
|
1012
|
+
filters.push(buildSectionTypeDependentHazardFilter(sectionTypeIdPath, options.parentHazardIdsContextKey));
|
|
1013
|
+
}
|
|
1014
|
+
if (options?.parentHazardRiskIdsContextKey) {
|
|
1015
|
+
filters.push(buildSectionTypeDependentParentFilter(sectionTypeIdPath, options.parentHazardRiskIdsContextKey, 'HazardRisk'));
|
|
1016
|
+
}
|
|
1017
|
+
if (filters.length === 1) {
|
|
1018
|
+
lookup['filter'] = filters[0];
|
|
1019
|
+
}
|
|
1020
|
+
else if (filters.length > 1) {
|
|
1021
|
+
lookup['filter'] = { logic: 'and', filters };
|
|
1022
|
+
}
|
|
1023
|
+
return lookup;
|
|
1024
|
+
}
|
|
1025
|
+
/** Lookup options with entity data-selector popup UI (`look: 'lookup'`). */
|
|
1026
|
+
function buildSafetyPlanSectionItemSelectorOptions(entityExpression, options) {
|
|
1027
|
+
return {
|
|
1028
|
+
...buildSafetyPlanSectionItemLookupOptions(entityExpression, options),
|
|
1029
|
+
look: 'lookup',
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function resolveSafetyPlanSectionItemColumns(sectionTypeId) {
|
|
1033
|
+
if (sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards) {
|
|
1034
|
+
return ['code', 'ppeItem.title', 'requirementType'];
|
|
1035
|
+
}
|
|
1036
|
+
if (sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe) {
|
|
1037
|
+
return ['code', 'hazardRisk.title', 'ppeItem.title', 'requirementType'];
|
|
1038
|
+
}
|
|
1039
|
+
if (sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.riskMatrix) {
|
|
1040
|
+
return [
|
|
1041
|
+
'code',
|
|
1042
|
+
'title',
|
|
1043
|
+
'matrix',
|
|
1044
|
+
{ name: 'likelihoodIds', visible: false },
|
|
1045
|
+
{ name: 'severityIds', visible: false },
|
|
1046
|
+
{ name: 'likelihoodId', visible: false },
|
|
1047
|
+
{ name: 'severityId', visible: false },
|
|
1048
|
+
{ name: 'matrixOrientation', visible: false },
|
|
1049
|
+
];
|
|
1050
|
+
}
|
|
1051
|
+
return ['code', 'title'];
|
|
1052
|
+
}
|
|
1053
|
+
function resolveSafetyPlanSectionItemEntityKey(sectionTypeId, sectionType) {
|
|
1054
|
+
return resolveSectionItemEntityName(sectionTypeId, sectionType);
|
|
1055
|
+
}
|
|
1056
|
+
function mapSafetyPlanSectionSelectedItems(sectionTypeId, selectedItems) {
|
|
1057
|
+
const isPpeHazards = sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.ppeHazards;
|
|
1058
|
+
const isHazardRiskPpe = sectionTypeId === WORKPLACE_SAFETY_BUILT_IN_SECTION_TYPE_IDS.hazardRiskPpe;
|
|
1059
|
+
return selectedItems
|
|
1060
|
+
.map((item) => {
|
|
1061
|
+
if (isPpeHazards || isHazardRiskPpe) {
|
|
1062
|
+
const ppeItem = item['ppeItem'];
|
|
1063
|
+
const id = String(ppeItem?.['id'] ?? item['id'] ?? '');
|
|
1064
|
+
return {
|
|
1065
|
+
id,
|
|
1066
|
+
title: asSafetyPlanDisplayText(ppeItem?.['title']) || undefined,
|
|
1067
|
+
code: asSafetyPlanDisplayText(ppeItem?.['code']) || undefined,
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
return {
|
|
1071
|
+
id: String(item['id'] ?? ''),
|
|
1072
|
+
title: asSafetyPlanDisplayText(item['title']) || undefined,
|
|
1073
|
+
code: asSafetyPlanDisplayText(item['code']) || undefined,
|
|
1074
|
+
};
|
|
1075
|
+
})
|
|
1076
|
+
.filter((item) => item.id.length > 0);
|
|
1077
|
+
}
|
|
1078
|
+
function dedupeSafetyPlanSectionItemSelection(item) {
|
|
1079
|
+
const seen = new Set();
|
|
1080
|
+
const itemIds = [];
|
|
1081
|
+
const items = [];
|
|
1082
|
+
for (let index = 0; index < (item.itemIds?.length ?? 0); index += 1) {
|
|
1083
|
+
const id = item.itemIds?.[index];
|
|
1084
|
+
if (typeof id !== 'string' || !id || seen.has(id)) {
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
seen.add(id);
|
|
1088
|
+
itemIds.push(id);
|
|
1089
|
+
const snapshot = item.items?.find((entry) => entry?.id === id) ??
|
|
1090
|
+
(item.items?.[index]?.id === id || !item.items?.[index]?.id ? item.items?.[index] : undefined);
|
|
1091
|
+
items.push({
|
|
1092
|
+
id,
|
|
1093
|
+
title: asSafetyPlanDisplayText(snapshot?.title) || undefined,
|
|
1094
|
+
code: asSafetyPlanDisplayText(snapshot?.code) || undefined,
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
return { ...item, itemIds, items };
|
|
1098
|
+
}
|
|
1099
|
+
function isPpeRuleSectionTypeId(sectionTypeId) {
|
|
1100
|
+
return isPpeRuleSectionType(sectionTypeId);
|
|
1101
|
+
}
|
|
1102
|
+
//#endregion
|
|
1103
|
+
|
|
1104
|
+
//#region ---- Imports ----
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region ---- Constants ----
|
|
1107
|
+
const listSortAndFilterOptions = {
|
|
1108
|
+
sort: { enabled: true },
|
|
1109
|
+
filter: { advance: { enabled: true }, inline: { enabled: true } },
|
|
1110
|
+
};
|
|
1111
|
+
/** Flat LookupBox row — same pattern as work-package `workOrderIds`. */
|
|
1112
|
+
const SECTION_TYPE_IDS_REPEATER_CHILDREN = [
|
|
1113
|
+
{
|
|
1114
|
+
type: AXPWidgetsList.Editors.LookupBox,
|
|
1115
|
+
mode: 'edit',
|
|
1116
|
+
path: 'sectionTypeId',
|
|
1117
|
+
name: 'sectionTypeId',
|
|
1118
|
+
options: {
|
|
1119
|
+
entity: `${RootConfig.module.name}.${RootConfig.entities.sectionType.name}`,
|
|
1120
|
+
look: 'select',
|
|
1121
|
+
allowSearch: true,
|
|
1122
|
+
textField: 'code',
|
|
1123
|
+
textTemplate: '{code} — {description}',
|
|
1124
|
+
valueField: 'id',
|
|
1125
|
+
columns: ['code', 'title', 'description'],
|
|
1126
|
+
expose: WORKPLACE_SAFETY_SECTION_TYPE_LOOKUP_EXPOSE,
|
|
1127
|
+
},
|
|
1128
|
+
},
|
|
1129
|
+
];
|
|
1130
|
+
const sectionTypeIdsPropertyLayout = {
|
|
1131
|
+
name: 'sectionTypeIds',
|
|
1132
|
+
layout: { label: { visible: false }, order: 1, positions: { lg: { colSpan: 12 } } },
|
|
1133
|
+
};
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region ---- Entity factory ----
|
|
1136
|
+
async function safetyPlanTypeSectionEntityFactory() {
|
|
1137
|
+
const entityDef = {
|
|
1138
|
+
module: RootConfig.module.name,
|
|
1139
|
+
name: RootConfig.entities.safetyPlanTypeSection.name,
|
|
1140
|
+
title: RootConfig.entities.safetyPlanTypeSection.title,
|
|
1141
|
+
icon: RootConfig.entities.safetyPlanTypeSection.icon,
|
|
1142
|
+
relatedEntities: [],
|
|
1143
|
+
formats: {
|
|
1144
|
+
individual: RootConfig.entities.safetyPlanTypeSection.title,
|
|
1145
|
+
plural: RootConfig.entities.safetyPlanTypeSection.titlePlural,
|
|
1146
|
+
searchResult: {
|
|
1147
|
+
title: '{{ title }}',
|
|
1148
|
+
description: '{{ safetyPlanType.title }}',
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
plugins: [{ name: 'archive' }],
|
|
1152
|
+
groups: [
|
|
1153
|
+
{
|
|
1154
|
+
id: 'basic-info',
|
|
1155
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.groups.basic-info',
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
id: 'sections',
|
|
1159
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.groups.sections',
|
|
1160
|
+
},
|
|
1161
|
+
],
|
|
1162
|
+
properties: [
|
|
1163
|
+
{
|
|
1164
|
+
name: 'id',
|
|
1165
|
+
title: '@general:terms.common.id',
|
|
1166
|
+
groupId: 'basic-info',
|
|
1167
|
+
schema: { dataType: 'uuid', visible: false, nullable: false, readonly: true, unique: { enabled: true } },
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
name: 'safetyPlanTypeId',
|
|
1171
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.fields.safety-plan-type.title',
|
|
1172
|
+
groupId: 'basic-info',
|
|
1173
|
+
options: listSortAndFilterOptions,
|
|
1174
|
+
schema: {
|
|
1175
|
+
dataType: 'string',
|
|
1176
|
+
interface: {
|
|
1177
|
+
type: AXPWidgetsList.Editors.LookupBox,
|
|
1178
|
+
options: {
|
|
1179
|
+
entity: `${RootConfig.module.name}.${RootConfig.entities.safetyPlanType.name}`,
|
|
1180
|
+
look: 'select',
|
|
1181
|
+
allowSearch: true,
|
|
1182
|
+
textField: 'title',
|
|
1183
|
+
valueField: 'id',
|
|
1184
|
+
columns: ['code', 'title'],
|
|
1185
|
+
expose: [
|
|
1186
|
+
{ source: 'id', target: 'safetyPlanType.id' },
|
|
1187
|
+
{ source: 'title', target: 'safetyPlanType.title' },
|
|
1188
|
+
{ source: 'code', target: 'safetyPlanType.code' },
|
|
1189
|
+
],
|
|
1190
|
+
},
|
|
1191
|
+
},
|
|
1192
|
+
},
|
|
1193
|
+
validations: [{ rule: 'required' }],
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
name: 'title',
|
|
1197
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.fields.title.title',
|
|
1198
|
+
groupId: 'basic-info',
|
|
1199
|
+
options: listSortAndFilterOptions,
|
|
1200
|
+
schema: {
|
|
1201
|
+
dataType: 'string',
|
|
1202
|
+
interface: {
|
|
1203
|
+
type: AXPWidgetsList.Editors.TextBox,
|
|
1204
|
+
options: {
|
|
1205
|
+
placeholder: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.fields.title.placeholder',
|
|
1206
|
+
},
|
|
1207
|
+
},
|
|
1208
|
+
},
|
|
1209
|
+
validations: [{ rule: 'required' }],
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: 'isDefault',
|
|
1213
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.fields.is-default.title',
|
|
1214
|
+
groupId: 'basic-info',
|
|
1215
|
+
options: listSortAndFilterOptions,
|
|
1216
|
+
schema: {
|
|
1217
|
+
dataType: 'boolean',
|
|
1218
|
+
defaultValue: false,
|
|
1219
|
+
interface: {
|
|
1220
|
+
type: AXPWidgetsList.Editors.ToggleSwitch,
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
name: 'sectionTypeIds',
|
|
1226
|
+
title: '',
|
|
1227
|
+
groupId: 'sections',
|
|
1228
|
+
options: {
|
|
1229
|
+
sort: { enabled: false },
|
|
1230
|
+
filter: { advance: { enabled: false }, inline: { enabled: false } },
|
|
1231
|
+
},
|
|
1232
|
+
schema: {
|
|
1233
|
+
dataType: 'array',
|
|
1234
|
+
defaultValue: [],
|
|
1235
|
+
nullable: true,
|
|
1236
|
+
interface: {
|
|
1237
|
+
type: AXPWidgetsList.Layouts.RepeaterLayout,
|
|
1238
|
+
options: { hasControls: true, allowReorder: true },
|
|
1239
|
+
children: [...SECTION_TYPE_IDS_REPEATER_CHILDREN],
|
|
1240
|
+
},
|
|
1241
|
+
},
|
|
1242
|
+
},
|
|
1243
|
+
/**
|
|
1244
|
+
* List sort order only (hidden / not edited in create-update UI).
|
|
1245
|
+
*/
|
|
1246
|
+
{
|
|
1247
|
+
name: 'sortOrder',
|
|
1248
|
+
title: '@workplacesafety-management:safety-plan-type-sections.entities.safety-plan-type-section.fields.sort-order.title',
|
|
1249
|
+
groupId: 'basic-info',
|
|
1250
|
+
schema: {
|
|
1251
|
+
dataType: 'number',
|
|
1252
|
+
visible: false,
|
|
1253
|
+
nullable: true,
|
|
1254
|
+
readonly: true,
|
|
1255
|
+
},
|
|
1256
|
+
},
|
|
1257
|
+
],
|
|
1258
|
+
columns: [
|
|
1259
|
+
{ name: 'title', options: { width: '200px', order: 1 } },
|
|
1260
|
+
{ name: 'sectionTypeIds', options: { width: '280px', order: 2 } },
|
|
1261
|
+
{ name: 'isDefault', options: { width: '120px', order: 3 } },
|
|
1262
|
+
],
|
|
1263
|
+
interfaces: {
|
|
1264
|
+
master: {
|
|
1265
|
+
create: {
|
|
1266
|
+
sections: [{ id: 'basic-info' }, { id: 'sections' }],
|
|
1267
|
+
properties: [
|
|
1268
|
+
{ name: 'safetyPlanTypeId', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
|
|
1269
|
+
{ name: 'title', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
|
|
1270
|
+
{ name: 'isDefault', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
|
|
1271
|
+
sectionTypeIdsPropertyLayout,
|
|
1272
|
+
],
|
|
1273
|
+
},
|
|
1274
|
+
update: {
|
|
1275
|
+
sections: [{ id: 'basic-info' }, { id: 'sections' }],
|
|
1276
|
+
properties: [
|
|
1277
|
+
{ name: 'safetyPlanTypeId', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
|
|
1278
|
+
{ name: 'title', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
|
|
1279
|
+
{ name: 'isDefault', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
|
|
1280
|
+
sectionTypeIdsPropertyLayout,
|
|
1281
|
+
],
|
|
1282
|
+
},
|
|
1283
|
+
single: {
|
|
1284
|
+
title: '{{ title }}',
|
|
1285
|
+
sections: [
|
|
1286
|
+
{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
|
|
1287
|
+
{ id: 'sections', layout: { positions: { lg: { colSpan: 12 } } } },
|
|
1288
|
+
],
|
|
1289
|
+
properties: [
|
|
1290
|
+
{ name: 'safetyPlanTypeId', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
|
|
1291
|
+
{ name: 'title', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
|
|
1292
|
+
{ name: 'isDefault', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
|
|
1293
|
+
sectionTypeIdsPropertyLayout,
|
|
1294
|
+
],
|
|
1295
|
+
actions: [...entityMasterRecordActions()],
|
|
1296
|
+
},
|
|
1297
|
+
list: {
|
|
1298
|
+
actions: [...entityMasterCrudActions()],
|
|
1299
|
+
views: [createAllQueryView({ sorts: [{ name: 'sortOrder', dir: 'asc' }] })],
|
|
1300
|
+
},
|
|
1301
|
+
},
|
|
1302
|
+
},
|
|
1303
|
+
};
|
|
1304
|
+
return entityDef;
|
|
1305
|
+
}
|
|
1306
|
+
//#endregion
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Generated bundle index. Do not edit.
|
|
1310
|
+
*/
|
|
1311
|
+
|
|
1312
|
+
export { safetyPlanTypeSectionEntityFactory };
|
|
1313
|
+
//# sourceMappingURL=acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.mjs.map
|