@acorex-platform/module-workplacesafety-management-client 0.0.33 → 0.0.38

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 (102) hide show
  1. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-mzaaZ6T3.mjs → acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-Ds0Fkspp.mjs} +20 -12
  2. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-mzaaZ6T3.mjs.map → acorex-platform-module-workplacesafety-management-client-acorex-platform-module-workplacesafety-management-client-Ds0Fkspp.mjs.map} +1 -1
  3. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-hierarchy-levels.mjs.map +1 -1
  4. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-control-measure.mjs.map +1 -1
  5. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-ppe-rule.mjs +1 -1
  6. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-ppe-rule.mjs.map +1 -1
  7. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-register.mjs.map +1 -1
  8. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard-risk.mjs.map +1 -1
  9. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard.mjs +71 -88
  10. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-hazard.mjs.map +1 -1
  11. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-ppe-item.mjs.map +1 -1
  12. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-section.mjs +35 -1
  13. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-section.mjs.map +1 -1
  14. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.mjs +35 -1
  15. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type-section.mjs.map +1 -1
  16. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-type.mjs.map +1 -1
  17. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan-work-step.mjs.map +1 -1
  18. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan.mjs +70 -11
  19. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-plan.mjs.map +1 -1
  20. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-template.mjs +3 -3
  21. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-safety-template.mjs.map +1 -1
  22. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-section-type.mjs.map +1 -1
  23. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-work-step-type.mjs +35 -1
  24. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entities-work-step-type.mjs.map +1 -1
  25. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-CeTmhod5.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-BI4TLvSE.mjs} +16 -16
  26. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-CeTmhod5.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-BI4TLvSE.mjs.map} +1 -1
  27. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-Dae2kkZe.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-COlCNnyK.mjs} +2 -2
  28. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-Dae2kkZe.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-hierarchy-levels.entity-COlCNnyK.mjs.map} +1 -1
  29. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-CpNcN6Pf.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-BrXGzqZU.mjs} +2 -2
  30. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-CpNcN6Pf.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-control-measure.entity-BrXGzqZU.mjs.map} +1 -1
  31. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-BcsAnO9h.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-DHJus7OP.mjs} +3 -3
  32. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-DHJus7OP.mjs.map +1 -0
  33. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-C9wGZ3hB.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-CogjoDox.mjs} +2 -2
  34. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-C9wGZ3hB.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-register.entity-CogjoDox.mjs.map} +1 -1
  35. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-AUr2GVLU.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-9UWHmIXV.mjs} +2 -2
  36. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-AUr2GVLU.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-risk.entity-9UWHmIXV.mjs.map} +1 -1
  37. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-J6fveZKA.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-CNPbxULL.mjs} +12 -29
  38. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-CNPbxULL.mjs.map +1 -0
  39. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-3fQPlBBf.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-D5iOBl3P.mjs} +2 -2
  40. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-3fQPlBBf.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-ppe-item.entity-D5iOBl3P.mjs.map} +1 -1
  41. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-BRGcQo7H.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-TdIMIkM7.mjs} +37 -3
  42. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-TdIMIkM7.mjs.map +1 -0
  43. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-BPx-3rYX.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-DJAI-7lB.mjs} +3 -3
  44. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-BPx-3rYX.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section.entity-DJAI-7lB.mjs.map} +1 -1
  45. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-_nG09ZpE.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-BGZ1VAW3.mjs} +3 -3
  46. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-_nG09ZpE.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type-section.entity-BGZ1VAW3.mjs.map} +1 -1
  47. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-CIH7W9R7.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-B6NYL4xi.mjs} +2 -2
  48. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-CIH7W9R7.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-type.entity-B6NYL4xi.mjs.map} +1 -1
  49. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-DmFYsBhI.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-BlCbf5qP.mjs} +2 -2
  50. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-DmFYsBhI.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-work-step.entity-BlCbf5qP.mjs.map} +1 -1
  51. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-CUDh_ZfQ.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-BSUR9jqs.mjs} +72 -13
  52. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-BSUR9jqs.mjs.map +1 -0
  53. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-BxNUXvae.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-CIHy_hLh.mjs} +5 -5
  54. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-CIHy_hLh.mjs.map +1 -0
  55. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-73MUyaIk.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-Cs4nIHou.mjs} +2 -2
  56. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-73MUyaIk.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-section-type.entity-Cs4nIHou.mjs.map} +1 -1
  57. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-Ujxum2GY.mjs → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-CJFWDOoh.mjs} +3 -3
  58. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-Ujxum2GY.mjs.map → acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-work-step-type.entity-CJFWDOoh.mjs.map} +1 -1
  59. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog.mjs +1 -1
  60. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs +38 -3
  61. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts.mjs.map +1 -1
  62. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-CnTEwf_l.mjs → acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-eDWG-sJ7.mjs} +2 -2
  63. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-CnTEwf_l.mjs.map → acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram-widget-view.component-eDWG-sJ7.mjs.map} +1 -1
  64. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-BI9VkzNw.mjs → acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-CfxHwZtH.mjs} +3 -3
  65. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-BI9VkzNw.mjs.map → acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.component-CfxHwZtH.mjs.map} +1 -1
  66. package/fesm2022/acorex-platform-module-workplacesafety-management-client-control-hierarchy-diagram.service-tMrUDnCb.mjs.map +1 -1
  67. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-o4bAwYcq.mjs → acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-6ZWaO5DG.mjs} +3 -3
  68. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-6ZWaO5DG.mjs.map +1 -0
  69. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-risk-status.provider-B6IkRYbW.mjs.map +1 -1
  70. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-index-LxP1eZLY.mjs → acorex-platform-module-workplacesafety-management-client-index-gbDgxqrV.mjs} +316 -375
  71. package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-gbDgxqrV.mjs.map +1 -0
  72. package/fesm2022/acorex-platform-module-workplacesafety-management-client-local-entities.mjs.map +1 -1
  73. package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-column.component-D2Mmow12.mjs.map +1 -1
  74. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-CQtVhCgw.mjs → acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-BqHXrGn9.mjs} +2 -2
  75. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-CQtVhCgw.mjs.map → acorex-platform-module-workplacesafety-management-client-ppe-item-viewer-widget-edit.component-BqHXrGn9.mjs.map} +1 -1
  76. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-YS8FHiRu.mjs → acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-BxcGph1I.mjs} +3 -3
  77. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-YS8FHiRu.mjs.map → acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-BxcGph1I.mjs.map} +1 -1
  78. package/fesm2022/acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.util-2Kl3_3sg.mjs.map +1 -1
  79. package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-Dd9xdo_y.mjs.map +1 -1
  80. package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-safety-plan.command-BU95c4xb.mjs +254 -0
  81. package/fesm2022/acorex-platform-module-workplacesafety-management-client-preview-safety-plan.command-BU95c4xb.mjs.map +1 -0
  82. package/fesm2022/acorex-platform-module-workplacesafety-management-client-publish-safety-plan.command-Ci-zcrmO.mjs.map +1 -1
  83. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-6i0RkG3L.mjs → acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-CQ2xB7Va.mjs} +10 -10
  84. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-6i0RkG3L.mjs.map → acorex-platform-module-workplacesafety-management-client-safety-plan-preview-modal.component-CQ2xB7Va.mjs.map} +1 -1
  85. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-preview.service-DJP41MuL.mjs +36 -0
  86. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-preview.service-DJP41MuL.mjs.map +1 -0
  87. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-section-builder.types-LaN1NIgc.mjs +204 -0
  88. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-section-builder.types-LaN1NIgc.mjs.map +1 -0
  89. package/fesm2022/acorex-platform-module-workplacesafety-management-client-safety-plan-status.provider-BpWx3gIf.mjs.map +1 -1
  90. package/fesm2022/{acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BlPzzCc2.mjs → acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-CLj3y_JD.mjs} +4 -209
  91. package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-CLj3y_JD.mjs.map +1 -0
  92. package/fesm2022/acorex-platform-module-workplacesafety-management-client.mjs +1 -1
  93. package/package.json +2 -2
  94. package/types/acorex-platform-module-workplacesafety-management-client-contracts.d.ts +26 -3
  95. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard-ppe-rule.entity-BcsAnO9h.mjs.map +0 -1
  96. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-hazard.entity-J6fveZKA.mjs.map +0 -1
  97. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan-section-dependency-BRGcQo7H.mjs.map +0 -1
  98. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-plan.entity-CUDh_ZfQ.mjs.map +0 -1
  99. package/fesm2022/acorex-platform-module-workplacesafety-management-client-contracts-entity-catalog-safety-template.entity-BxNUXvae.mjs.map +0 -1
  100. package/fesm2022/acorex-platform-module-workplacesafety-management-client-hazard-ppe-rule-status.provider-o4bAwYcq.mjs.map +0 -1
  101. package/fesm2022/acorex-platform-module-workplacesafety-management-client-index-LxP1eZLY.mjs.map +0 -1
  102. package/fesm2022/acorex-platform-module-workplacesafety-management-client-save-safety-plan-sections.command-BlPzzCc2.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-YS8FHiRu.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-card.component.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-card.component.html","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.component.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.component.html","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.service.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { AXValueChangedEvent } from '@acorex/cdk/common';\nimport { AXCheckBoxModule } from '@acorex/components/check-box';\nimport { AXDecoratorModule } from '@acorex/components/decorators';\nimport { ChangeDetectionStrategy, Component, computed, input, output, ViewEncapsulation } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport type { AXMPpeItemViewerDisplayItem, AXMPpeItemViewerLook } from './ppe-item-viewer.types';\nimport { ppeItemViewerStandardText } from './ppe-item-viewer.util';\n\n//#endregion\n\n//#region ----- Component -----\n\n@Component({\n selector: 'axm-ppe-item-card',\n templateUrl: './ppe-item-card.component.html',\n styleUrl: './ppe-item-card.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AXCheckBoxModule, AXDecoratorModule, FormsModule],\n host: {\n class: 'axm-ppe-item-card',\n '[class.axm-ppe-item-card--list]': 'look() === \"list\"',\n '[class.axm-ppe-item-card--card]': 'look() === \"card\"',\n '[class.axm-ppe-item-card--selected]': 'selected()',\n '[class.axm-ppe-item-card--interactive]': 'interactive()',\n '[class.axm-ppe-item-card--disabled]': 'disabled()',\n },\n})\nexport class AXMPpeItemCardComponent {\n //#region ----- Inputs -----\n\n readonly item = input.required<AXMPpeItemViewerDisplayItem>();\n readonly look = input<AXMPpeItemViewerLook>('card');\n readonly selected = input(false);\n readonly disabled = input(false);\n readonly readonly = input(false);\n readonly showControl = input(true);\n\n //#endregion\n\n //#region ----- Outputs -----\n\n readonly selectedChange = output<boolean>();\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly interactive = computed(\n () => this.showControl() && !this.disabled() && !this.readonly(),\n );\n\n protected readonly standardText = computed(() => ppeItemViewerStandardText(this.item()));\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected onActivate(): void {\n if (!this.interactive()) {\n return;\n }\n this.selectedChange.emit(!this.selected());\n }\n\n protected onCheckChanged(event: AXValueChangedEvent<boolean>): void {\n if (!event.isUserInteraction || !this.interactive()) {\n return;\n }\n this.selectedChange.emit(Boolean(event.value));\n }\n\n protected onControlClick(event: Event): void {\n event.stopPropagation();\n }\n\n //#endregion\n}\n\n//#endregion\n","<div class=\"axm-ppe-item-card__body\" (click)=\"onActivate()\">\n <!-- ----- PPE icon ----- -->\n @if (item().imageUrl) {\n <div class=\"axm-ppe-item-card__icon\">\n <img [src]=\"item().imageUrl\" [alt]=\"item().title\" />\n </div>\n }\n <!-- ----- Fallback icon when the PPE item has no image ----- -->\n @else {\n <div class=\"axm-ppe-item-card__icon axm-ppe-item-card__icon--fallback\">\n <ax-icon icon=\"fa-light fa-helmet-safety\"></ax-icon>\n </div>\n }\n\n <div class=\"axm-ppe-item-card__content\">\n <span class=\"axm-ppe-item-card__title\">{{ item().title }}</span>\n <!--->\n <!-- ----- Standard / code when present ----- -->\n @if (standardText()) {\n <span class=\"axm-ppe-item-card__code\">{{ standardText() }}</span>\n }\n </div>\n\n <!-- ----- Selection checkbox ----- -->\n @if (showControl()) {\n <div class=\"axm-ppe-item-card__control\" (click)=\"onControlClick($event)\">\n <ax-check-box\n [ngModel]=\"selected()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (onValueChanged)=\"onCheckChanged($event)\"\n ></ax-check-box>\n </div>\n }\n</div>\n","//#region ----- Imports -----\n\nimport { AXLoadingModule } from '@acorex/components/loading';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { AsyncPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, input, output, ViewEncapsulation } from '@angular/core';\n\nimport { AXMPpeItemCardComponent } from './ppe-item-card.component';\nimport type {\n AXMPpeItemViewerDisplayItem,\n AXMPpeItemViewerLayout,\n AXMPpeItemViewerLook,\n} from './ppe-item-viewer.types';\nimport { resolvePpeItemViewerLook } from './ppe-item-viewer.util';\n\n//#endregion\n\n//#region ----- Component -----\n\n@Component({\n selector: 'axm-ppe-item-viewer',\n templateUrl: './ppe-item-viewer.component.html',\n styleUrl: './ppe-item-viewer.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AsyncPipe, AXLoadingModule, AXTranslationModule, AXMPpeItemCardComponent],\n host: {\n class: 'axm-ppe-item-viewer block w-full',\n },\n})\nexport class AXMPpeItemViewerComponent {\n //#region ----- Inputs -----\n\n readonly items = input<AXMPpeItemViewerDisplayItem[]>([]);\n readonly layout = input<AXMPpeItemViewerLayout>('horizontal');\n readonly selectedIds = input<readonly string[]>([]);\n readonly loading = input(false);\n readonly disabled = input(false);\n readonly readonly = input(false);\n readonly showControl = input(true);\n\n //#endregion\n\n //#region ----- Outputs -----\n\n readonly selectedIdsChange = output<string[]>();\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly look = computed<AXMPpeItemViewerLook>(() =>\n resolvePpeItemViewerLook(this.layout()),\n );\n\n protected readonly selectedIdSet = computed(() => new Set(this.selectedIds()));\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected isSelected(itemId: string): boolean {\n return this.selectedIdSet().has(itemId);\n }\n\n protected onItemSelectedChange(itemId: string, selected: boolean): void {\n if (this.disabled() || this.readonly()) {\n return;\n }\n const next = this.items()\n .map((item) => item.id)\n .filter((id) => (id === itemId ? selected : this.selectedIdSet().has(id)));\n this.selectedIdsChange.emit(next);\n }\n\n //#endregion\n}\n\n//#endregion\n","@if (loading()) {\n <!-- ----- Loading indicator while configured PPE items are fetched ----- -->\n <ax-loading></ax-loading>\n}\n<!-- ----- Empty state when no PPE items are configured ----- -->\n@else if (items().length === 0) {\n <p class=\"axm-ppe-item-viewer__empty\">\n {{ '@workplacesafety-management:ppe-items.components.ppe-item-viewer.empty' | translate | async }}\n </p>\n}\n<!-- ----- PPE items in card grid or checklist list ----- -->\n@else {\n <div\n class=\"axm-ppe-item-viewer__items\"\n [class.axm-ppe-item-viewer__items--card]=\"look() === 'card'\"\n [class.axm-ppe-item-viewer__items--list]=\"look() === 'list'\"\n >\n @for (item of items(); track item.id) {\n <axm-ppe-item-card\n [item]=\"item\"\n [look]=\"look()\"\n [selected]=\"isSelected(item.id)\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [showControl]=\"showControl()\"\n (selectedChange)=\"onItemSelectedChange(item.id, $event)\"\n />\n }\n </div>\n}\n","//#region ----- Imports -----\n\nimport { resolveMultiLanguageString } from '@acorex-platform/framework-shared/core';\nimport { AXPFileStorageService, isStoredImageFileId, resolveStoredImageDisplayUrl } from '@acorex-platform/framework-client/common';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { Injectable, inject } from '@angular/core';\n\nimport { RootConfig, type AXMWorkplaceSafetyManagementPpeItemEntityModel } from '@acorex-platform/module-workplacesafety-management-client/contracts';\n\nimport type { AXMPpeItemViewerDisplayItem } from './ppe-item-viewer.types';\n\n//#endregion\n\n//#region ----- Service -----\n\n@Injectable({ providedIn: 'root' })\nexport class AXMPpeItemViewerService {\n //#region ----- Services & Dependencies -----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly translationService = inject(AXTranslationService);\n private readonly fileStorage = inject(AXPFileStorageService, { optional: true });\n\n //#endregion\n\n //#region ----- Public API -----\n\n async loadDisplayItems(ids: string[]): Promise<AXMPpeItemViewerDisplayItem[]> {\n if (ids.length === 0) {\n return [];\n }\n\n const records = await this.queryByIds(ids);\n const byId = new Map(records.map((row) => [row.id, row]));\n const locale = this.translationService.getActiveLang() ?? 'en-US';\n\n return ids\n .map((id) => byId.get(id))\n .filter((row): row is AXMWorkplaceSafetyManagementPpeItemEntityModel => row != null)\n .map((row) => this.toDisplayItem(row, locale));\n }\n\n //#endregion\n\n //#region ----- Data Loading -----\n\n private async queryByIds(ids: string[]): Promise<AXMWorkplaceSafetyManagementPpeItemEntityModel[]> {\n const dataAccessor = this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.ppeItem.name)\n .data<string, AXMWorkplaceSafetyManagementPpeItemEntityModel>();\n\n try {\n const result = await dataAccessor.query({\n skip: 0,\n take: Math.max(ids.length, 100),\n filter:\n ids.length === 1\n ? { field: 'id', operator: { type: 'equal' }, value: ids[0] }\n : { field: 'id', operator: { type: 'in' }, value: ids },\n });\n return result?.items ?? [];\n } catch {\n const loaded: AXMWorkplaceSafetyManagementPpeItemEntityModel[] = [];\n for (const id of ids) {\n try {\n const row = await dataAccessor.byKey(id);\n if (row) {\n loaded.push(row);\n }\n } catch {\n /* skip missing rows */\n }\n }\n return loaded;\n }\n }\n\n private toDisplayItem(\n row: AXMWorkplaceSafetyManagementPpeItemEntityModel,\n locale: string,\n ): AXMPpeItemViewerDisplayItem {\n const title = resolveMultiLanguageString(row.title, locale);\n const code = typeof row.code === 'string' ? row.code.trim() : '';\n const serialNumber = typeof row.serialNumber === 'string' ? row.serialNumber.trim() : '';\n return {\n id: row.id,\n title,\n code: code.length > 0 ? code : undefined,\n serialNumber: serialNumber.length > 0 ? serialNumber : undefined,\n imageUrl: this.resolveIconUrl(row.icon),\n };\n }\n\n private resolveIconUrl(icon: string | undefined): string | null {\n const trimmed = icon?.trim();\n if (!trimmed) {\n return null;\n }\n if (this.fileStorage && isStoredImageFileId(trimmed)) {\n const displayUrl = resolveStoredImageDisplayUrl(trimmed, (fileId) =>\n this.fileStorage!.getDownloadUrl(fileId),\n );\n return displayUrl || null;\n }\n return resolveStoredImageDisplayUrl(trimmed, () => '') || null;\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":["i3","i2"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA;AAEA;MAkBa,uBAAuB,CAAA;AAhBpC,IAAA,WAAA,GAAA;;Q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AAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAvB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,cADV,MAAM,EAAA,CAAA,CAAA;;2FACnB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.service-BxcGph1I.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-card.component.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-card.component.html","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.component.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.component.html","../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.service.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { AXValueChangedEvent } from '@acorex/cdk/common';\nimport { AXCheckBoxModule } from '@acorex/components/check-box';\nimport { AXDecoratorModule } from '@acorex/components/decorators';\nimport { ChangeDetectionStrategy, Component, computed, input, output, ViewEncapsulation } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport type { AXMPpeItemViewerDisplayItem, AXMPpeItemViewerLook } from './ppe-item-viewer.types';\nimport { ppeItemViewerStandardText } from './ppe-item-viewer.util';\n\n//#endregion\n\n//#region ----- Component -----\n\n@Component({\n selector: 'axm-ppe-item-card',\n templateUrl: './ppe-item-card.component.html',\n styleUrl: './ppe-item-card.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AXCheckBoxModule, AXDecoratorModule, FormsModule],\n host: {\n class: 'axm-ppe-item-card',\n '[class.axm-ppe-item-card--list]': 'look() === \"list\"',\n '[class.axm-ppe-item-card--card]': 'look() === \"card\"',\n '[class.axm-ppe-item-card--selected]': 'selected()',\n '[class.axm-ppe-item-card--interactive]': 'interactive()',\n '[class.axm-ppe-item-card--disabled]': 'disabled()',\n },\n})\nexport class AXMPpeItemCardComponent {\n //#region ----- Inputs -----\n\n readonly item = input.required<AXMPpeItemViewerDisplayItem>();\n readonly look = input<AXMPpeItemViewerLook>('card');\n readonly selected = input(false);\n readonly disabled = input(false);\n readonly readonly = input(false);\n readonly showControl = input(true);\n\n //#endregion\n\n //#region ----- Outputs -----\n\n readonly selectedChange = output<boolean>();\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly interactive = computed(\n () => this.showControl() && !this.disabled() && !this.readonly(),\n );\n\n protected readonly standardText = computed(() => ppeItemViewerStandardText(this.item()));\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected onActivate(): void {\n if (!this.interactive()) {\n return;\n }\n this.selectedChange.emit(!this.selected());\n }\n\n protected onCheckChanged(event: AXValueChangedEvent<boolean>): void {\n if (!event.isUserInteraction || !this.interactive()) {\n return;\n }\n this.selectedChange.emit(Boolean(event.value));\n }\n\n protected onControlClick(event: Event): void {\n event.stopPropagation();\n }\n\n //#endregion\n}\n\n//#endregion\n","<div class=\"axm-ppe-item-card__body\" (click)=\"onActivate()\">\n <!-- ----- PPE icon ----- -->\n @if (item().imageUrl) {\n <div class=\"axm-ppe-item-card__icon\">\n <img [src]=\"item().imageUrl\" [alt]=\"item().title\" />\n </div>\n }\n <!-- ----- Fallback icon when the PPE item has no image ----- -->\n @else {\n <div class=\"axm-ppe-item-card__icon axm-ppe-item-card__icon--fallback\">\n <ax-icon icon=\"fa-light fa-helmet-safety\"></ax-icon>\n </div>\n }\n\n <div class=\"axm-ppe-item-card__content\">\n <span class=\"axm-ppe-item-card__title\">{{ item().title }}</span>\n <!--->\n <!-- ----- Standard / code when present ----- -->\n @if (standardText()) {\n <span class=\"axm-ppe-item-card__code\">{{ standardText() }}</span>\n }\n </div>\n\n <!-- ----- Selection checkbox ----- -->\n @if (showControl()) {\n <div class=\"axm-ppe-item-card__control\" (click)=\"onControlClick($event)\">\n <ax-check-box\n [ngModel]=\"selected()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (onValueChanged)=\"onCheckChanged($event)\"\n ></ax-check-box>\n </div>\n }\n</div>\n","//#region ----- Imports -----\n\nimport { AXLoadingModule } from '@acorex/components/loading';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { AsyncPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, input, output, ViewEncapsulation } from '@angular/core';\n\nimport { AXMPpeItemCardComponent } from './ppe-item-card.component';\nimport type {\n AXMPpeItemViewerDisplayItem,\n AXMPpeItemViewerLayout,\n AXMPpeItemViewerLook,\n} from './ppe-item-viewer.types';\nimport { resolvePpeItemViewerLook } from './ppe-item-viewer.util';\n\n//#endregion\n\n//#region ----- Component -----\n\n@Component({\n selector: 'axm-ppe-item-viewer',\n templateUrl: './ppe-item-viewer.component.html',\n styleUrl: './ppe-item-viewer.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AsyncPipe, AXLoadingModule, AXTranslationModule, AXMPpeItemCardComponent],\n host: {\n class: 'axm-ppe-item-viewer block w-full',\n },\n})\nexport class AXMPpeItemViewerComponent {\n //#region ----- Inputs -----\n\n readonly items = input<AXMPpeItemViewerDisplayItem[]>([]);\n readonly layout = input<AXMPpeItemViewerLayout>('horizontal');\n readonly selectedIds = input<readonly string[]>([]);\n readonly loading = input(false);\n readonly disabled = input(false);\n readonly readonly = input(false);\n readonly showControl = input(true);\n\n //#endregion\n\n //#region ----- Outputs -----\n\n readonly selectedIdsChange = output<string[]>();\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly look = computed<AXMPpeItemViewerLook>(() =>\n resolvePpeItemViewerLook(this.layout()),\n );\n\n protected readonly selectedIdSet = computed(() => new Set(this.selectedIds()));\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected isSelected(itemId: string): boolean {\n return this.selectedIdSet().has(itemId);\n }\n\n protected onItemSelectedChange(itemId: string, selected: boolean): void {\n if (this.disabled() || this.readonly()) {\n return;\n }\n const next = this.items()\n .map((item) => item.id)\n .filter((id) => (id === itemId ? selected : this.selectedIdSet().has(id)));\n this.selectedIdsChange.emit(next);\n }\n\n //#endregion\n}\n\n//#endregion\n","@if (loading()) {\n <!-- ----- Loading indicator while configured PPE items are fetched ----- -->\n <ax-loading></ax-loading>\n}\n<!-- ----- Empty state when no PPE items are configured ----- -->\n@else if (items().length === 0) {\n <p class=\"axm-ppe-item-viewer__empty\">\n {{ '@workplacesafety-management:ppe-items.components.ppe-item-viewer.empty' | translate | async }}\n </p>\n}\n<!-- ----- PPE items in card grid or checklist list ----- -->\n@else {\n <div\n class=\"axm-ppe-item-viewer__items\"\n [class.axm-ppe-item-viewer__items--card]=\"look() === 'card'\"\n [class.axm-ppe-item-viewer__items--list]=\"look() === 'list'\"\n >\n @for (item of items(); track item.id) {\n <axm-ppe-item-card\n [item]=\"item\"\n [look]=\"look()\"\n [selected]=\"isSelected(item.id)\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [showControl]=\"showControl()\"\n (selectedChange)=\"onItemSelectedChange(item.id, $event)\"\n />\n }\n </div>\n}\n","//#region ----- Imports -----\n\nimport { resolveMultiLanguageString } from '@acorex-platform/framework-shared/core';\nimport { AXPFileStorageService, isStoredImageFileId, resolveStoredImageDisplayUrl } from '@acorex-platform/framework-client/common';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { Injectable, inject } from '@angular/core';\n\nimport { RootConfig, type AXMWorkplaceSafetyManagementPpeItemEntityModel } from '@acorex-platform/module-workplacesafety-management-client/contracts';\n\nimport type { AXMPpeItemViewerDisplayItem } from './ppe-item-viewer.types';\n\n//#endregion\n\n//#region ----- Service -----\n\n@Injectable({ providedIn: 'root' })\nexport class AXMPpeItemViewerService {\n //#region ----- Services & Dependencies -----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly translationService = inject(AXTranslationService);\n private readonly fileStorage = inject(AXPFileStorageService, { optional: true });\n\n //#endregion\n\n //#region ----- Public API -----\n\n async loadDisplayItems(ids: string[]): Promise<AXMPpeItemViewerDisplayItem[]> {\n if (ids.length === 0) {\n return [];\n }\n\n const records = await this.queryByIds(ids);\n const byId = new Map(records.map((row) => [row.id, row]));\n const locale = this.translationService.getActiveLang() ?? 'en-US';\n\n return ids\n .map((id) => byId.get(id))\n .filter((row): row is AXMWorkplaceSafetyManagementPpeItemEntityModel => row != null)\n .map((row) => this.toDisplayItem(row, locale));\n }\n\n //#endregion\n\n //#region ----- Data Loading -----\n\n private async queryByIds(ids: string[]): Promise<AXMWorkplaceSafetyManagementPpeItemEntityModel[]> {\n const dataAccessor = this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.ppeItem.name)\n .data<string, AXMWorkplaceSafetyManagementPpeItemEntityModel>();\n\n try {\n const result = await dataAccessor.query({\n skip: 0,\n take: Math.max(ids.length, 100),\n filter:\n ids.length === 1\n ? { field: 'id', operator: { type: 'equal' }, value: ids[0] }\n : { field: 'id', operator: { type: 'in' }, value: ids },\n });\n return result?.items ?? [];\n } catch {\n const loaded: AXMWorkplaceSafetyManagementPpeItemEntityModel[] = [];\n for (const id of ids) {\n try {\n const row = await dataAccessor.byKey(id);\n if (row) {\n loaded.push(row);\n }\n } catch {\n /* skip missing rows */\n }\n }\n return loaded;\n }\n }\n\n private toDisplayItem(\n row: AXMWorkplaceSafetyManagementPpeItemEntityModel,\n locale: string,\n ): AXMPpeItemViewerDisplayItem {\n const title = resolveMultiLanguageString(row.title, locale);\n const code = typeof row.code === 'string' ? row.code.trim() : '';\n const serialNumber = typeof row.serialNumber === 'string' ? row.serialNumber.trim() : '';\n return {\n id: row.id,\n title,\n code: code.length > 0 ? code : undefined,\n serialNumber: serialNumber.length > 0 ? serialNumber : undefined,\n imageUrl: this.resolveIconUrl(row.icon),\n };\n }\n\n private resolveIconUrl(icon: string | undefined): string | null {\n const trimmed = icon?.trim();\n if (!trimmed) {\n return null;\n }\n if (this.fileStorage && isStoredImageFileId(trimmed)) {\n const displayUrl = resolveStoredImageDisplayUrl(trimmed, (fileId) =>\n this.fileStorage!.getDownloadUrl(fileId),\n );\n return displayUrl || null;\n }\n return resolveStoredImageDisplayUrl(trimmed, () => '') || null;\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":["i3","i2"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA;AAEA;MAkBa,uBAAuB,CAAA;AAhBpC,IAAA,WAAA,GAAA;;QAmBW,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,QAAQ;iFAA+B;QACpD,IAAA,CAAA,IAAI,GAAG,KAAK,CAAuB,MAAM;iFAAC;QAC1C,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,KAAK;qFAAC;QACvB,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,KAAK;qFAAC;QACvB,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,KAAK;qFAAC;QACvB,IAAA,CAAA,WAAW,GAAG,KAAK,CAAC,IAAI;wFAAC;;;QAMzB,IAAA,CAAA,cAAc,GAAG,MAAM,EAAW;;;QAMxB,IAAA,CAAA,WAAW,GAAG,QAAQ,CACvC,MAAM,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;wFACjE;AAEkB,QAAA,IAAA,CAAA,YAAY,GAAG,QAAQ,CAAC,MAAM,yBAAyB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;yFAAC;AAyBzF,IAAA;;;IAnBW,UAAU,GAAA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IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;SACxC;IACH;AAEQ,IAAA,cAAc,CAAC,IAAwB,EAAA;AAC7C,QAAA,MAAM,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE;QAC5B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,IAAI;QACb;QACA,IAAI,IAAI,CAAC,WAAW,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;YACpD,MAAM,UAAU,GAAG,4BAA4B,CAAC,OAAO,EAAE,CAAC,MAAM,KAC9D,IAAI,CAAC,WAAY,CAAC,cAAc,CAAC,MAAM,CAAC,CACzC;YACD,OAAO,UAAU,IAAI,IAAI;QAC3B;QACA,OAAO,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,IAAI,IAAI;IAChE;8GAzFW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAvB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,cADV,MAAM,EAAA,CAAA,CAAA;;2FACnB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.util-2Kl3_3sg.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.util.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport type {\n AXMPpeItemViewerDisplayItem,\n AXMPpeItemViewerLayout,\n AXMPpeItemViewerLayoutOption,\n AXMPpeItemViewerLook,\n} from './ppe-item-viewer.types';\n\n//#endregion\n\n//#region ----- Lookup id extraction -----\n\nfunction extractLookupId(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n }\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const id = (value as { id?: unknown }).id;\n if (typeof id === 'string' && id.trim().length > 0) {\n return id.trim();\n }\n }\n return null;\n}\n\n/**\n * Normalizes widget config or bound answer values to PPE item ids.\n * Lookup multiple may persist `string[]` or `{ id }[]`.\n */\nexport function extractPpeItemIds(value: unknown): string[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n const ids: string[] = [];\n const seen = new Set<string>();\n for (const entry of value) {\n const id = extractLookupId(entry);\n if (id && !seen.has(id)) {\n seen.add(id);\n ids.push(id);\n }\n }\n return ids;\n }\n const single = extractLookupId(value);\n return single ? [single] : [];\n}\n\n//#endregion\n\n//#region ----- Layout -----\n\nexport function resolvePpeItemViewerLayout(\n value: AXMPpeItemViewerLayoutOption | string | undefined,\n): AXMPpeItemViewerLayout {\n const raw = typeof value === 'string' ? value : value?.id;\n return raw === 'vertical' ? 'vertical' : 'horizontal';\n}\n\n/** Horizontal layout is a card grid; vertical layout is a checklist-style list. */\nexport function resolvePpeItemViewerLook(\n value: AXMPpeItemViewerLayoutOption | string | undefined,\n): AXMPpeItemViewerLook {\n return resolvePpeItemViewerLayout(value) === 'vertical' ? 'list' : 'card';\n}\n\nexport function ppeItemViewerStandardText(item: AXMPpeItemViewerDisplayItem): string {\n const code = item.code?.trim() ?? '';\n const serial = item.serialNumber?.trim() ?? '';\n if (code && serial && serial !== code) {\n return `${code} · ${serial}`;\n }\n return code || serial;\n}\n\n//#endregion\n"],"names":[],"mappings":"AAAA;AASA;AAEA;AAEA,SAAS,eAAe,CAAC,KAAc,EAAA;AACrC,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE;AAC5B,QAAA,OAAO,OAAO,CAAC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AAO,GAAG,KAAK,UAAU,GAAG,UAAU,GAAG,YAAY;AACvD;AAEA;AACM,SAAU,wBAAwB,CACtC,KAAwD,EAAA;AAExD,IAAA,OAAO,0BAA0B,CAAC,KAAK,CAAC,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM;AAC3E;AAEM,SAAU,yBAAyB,CAAC,IAAiC,EAAA;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;IAC9C,IAAI,IAAI,IAAI,MAAM,IAAI,MAAM,KAAK,IAAI,EAAE;AACrC,QAAA,OAAO,CAAA,EAAG,IAAI,CAAA,GAAA,EAAM,MAAM,EAAE;IAC9B;IACA,OAAO,IAAI,IAAI,MAAM;AACvB;AAEA;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-ppe-item-viewer.util-2Kl3_3sg.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/ppe-item-viewer/ppe-item-viewer.util.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport type {\n AXMPpeItemViewerDisplayItem,\n AXMPpeItemViewerLayout,\n AXMPpeItemViewerLayoutOption,\n AXMPpeItemViewerLook,\n} from './ppe-item-viewer.types';\n\n//#endregion\n\n//#region ----- Lookup id extraction -----\n\nfunction extractLookupId(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n }\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const id = (value as { id?: unknown }).id;\n if (typeof id === 'string' && id.trim().length > 0) {\n return id.trim();\n }\n }\n return null;\n}\n\n/**\n * Normalizes widget config or bound answer values to PPE item ids.\n * Lookup multiple may persist `string[]` or `{ id }[]`.\n */\nexport function extractPpeItemIds(value: unknown): string[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n const ids: string[] = [];\n const seen = new Set<string>();\n for (const entry of value) {\n const id = extractLookupId(entry);\n if (id && !seen.has(id)) {\n seen.add(id);\n ids.push(id);\n }\n }\n return ids;\n }\n const single = extractLookupId(value);\n return single ? [single] : [];\n}\n\n//#endregion\n\n//#region ----- Layout -----\n\nexport function resolvePpeItemViewerLayout(\n value: AXMPpeItemViewerLayoutOption | string | undefined,\n): AXMPpeItemViewerLayout {\n const raw = typeof value === 'string' ? value : value?.id;\n return raw === 'vertical' ? 'vertical' : 'horizontal';\n}\n\n/** Horizontal layout is a card grid; vertical layout is a checklist-style list. */\nexport function resolvePpeItemViewerLook(\n value: AXMPpeItemViewerLayoutOption | string | undefined,\n): AXMPpeItemViewerLook {\n return resolvePpeItemViewerLayout(value) === 'vertical' ? 'list' : 'card';\n}\n\nexport function ppeItemViewerStandardText(item: AXMPpeItemViewerDisplayItem): string {\n const code = item.code?.trim() ?? '';\n const serial = item.serialNumber?.trim() ?? '';\n if (code && serial && serial !== code) {\n return `${code} · ${serial}`;\n }\n return code || serial;\n}\n\n//#endregion\n"],"names":[],"mappings":"AAAA;AASA;AAEA;AAEA,SAAS,eAAe,CAAC,KAAc,EAAA;AACrC,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE;AAC5B,QAAA,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI;IAC5C;AACA,IAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAC/D,QAAA,MAAM,EAAE,GAAI,KAA0B,CAAC,EAAE;AACzC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;AAClD,YAAA,OAAO,EAAE,CAAC,IAAI,EAAE;QAClB;IACF;AACA,IAAA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,IAAI,IAAI,IAAI,MAAM,IAAI,MAAM,KAAK,IAAI,EAAE;AACrC,QAAA,OAAO,CAAA,EAAG,IAAI,CAAA,GAAA,EAAM,MAAM,EAAE;IAC9B;IACA,OAAO,IAAI,IAAI,MAAM;AACvB;AAEA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-Dd9xdo_y.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/control-hierarchy-diagram/control-hierarchy-diagram-viewer.service.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/control-hierarchy-diagram/commands/preview-control-hierarchy-diagram.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPWidgetsList } from '@acorex-platform/framework-shared/core';\nimport { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get } from 'lodash';\n\nimport { AXMControlHierarchyDiagramService } from './control-hierarchy-diagram.service';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface AXMControlHierarchyDiagramViewerOpenOptions {\n context: Record<string, unknown>;\n title?: string;\n}\n\n//#endregion\n\n//#region ---- Control Hierarchy Diagram Viewer Service ----\n\n/**\n * Opens a read-only control hierarchy diagram preview dialog from form or record context.\n */\n@Injectable({ providedIn: 'root' })\nexport class AXMControlHierarchyDiagramViewerService {\n //#region ---- Services & Dependencies ----\n\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly diagramService = inject(AXMControlHierarchyDiagramService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Public API ----\n\n async open(options: AXMControlHierarchyDiagramViewerOpenOptions): Promise<void> {\n const context = {\n hierarchyDiagramViewType: defaultTo(get(options.context, 'hierarchyDiagramViewType'), 'horizontal'),\n itemIds: defaultTo(get(options.context, 'itemIds'), []),\n id: get(options.context, 'id'),\n title: get(options.context, 'title'),\n hierarchyDiagram: null,\n };\n\n await this.layoutBuilder\n .create()\n .dialog((dialog) => {\n dialog\n .setTitle(this.resolveDialogTitle(options.title))\n .setSize('lg')\n .setCloseButton(true)\n .setContext(context)\n .content((layout) => {\n layout.flex((flex) => {\n flex.setDirection('column');\n flex.formField(\n '@workplacesafety-management:control-measure-types.components.control-hierarchy-diagram.fields.view-type.title',\n (field) => {\n field.path('hierarchyDiagramViewType').selectBox({\n valueField: 'id',\n textField: 'title',\n dataSource: this.diagramService.getViewTypeOptions(),\n });\n },\n );\n flex.formField('', (field) => {\n field\n .path('hierarchyDiagram')\n .setShowLabel(false)\n .mode('view')\n .customWidget(AXPWidgetsList.Editors.ControlHierarchyDiagram, {\n showLabel: false,\n showTitle: false,\n showViewTypeSelector: false,\n viewType: '{{ context.eval(\"hierarchyDiagramViewType\") ?? \"horizontal\" }}',\n triggers: [\n {\n event: \"{{ events.context('hierarchyDiagramViewType') }}\",\n action: '{{ widget.refresh() }}',\n },\n {\n event: \"{{ events.context('itemIds') }}\",\n action: '{{ widget.refresh() }}',\n },\n ],\n });\n });\n });\n });\n })\n .show();\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private resolveDialogTitle(title: string | undefined): string {\n const resolved = resolveEntityRowDisplayText(title, this.translation.getActiveLang() ?? 'en-US');\n return resolved || 'Hierarchy Diagram';\n }\n\n //#endregion\n}\n\n//#endregion\n","//#region ---- Imports ----\n\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\n\nimport { Injectable, inject } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { AXMControlHierarchyDiagramViewerService } from '../control-hierarchy-diagram-viewer.service';\n\n//#endregion\n\n//#region ---- Command Types ----\n\nexport interface AXMPreviewControlHierarchyDiagramCommandInput {\n title?: string;\n itemIds?: unknown;\n hierarchyDiagramViewType?: string;\n id?: string;\n data?: Record<string, unknown>;\n options?: Partial<AXMPreviewControlHierarchyDiagramCommandInput>;\n}\n\n//#endregion\n\n//#region ---- Command ----\n\n@Injectable()\nexport class AXMPreviewControlHierarchyDiagramCommand\n implements AXPCommand<AXMPreviewControlHierarchyDiagramCommandInput, void>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly translationService = inject(AXTranslationService);\n private readonly diagramViewer = inject(AXMControlHierarchyDiagramViewerService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: AXMPreviewControlHierarchyDiagramCommandInput): AXPCommandExecuteResultPromise<void> {\n try {\n const context = this.resolveContext(input);\n const dialogTitle = await this.resolveDialogTitle(input, context);\n\n await this.diagramViewer.open({\n context,\n title: dialogTitle,\n });\n\n return {\n success: true,\n kind: 'object',\n data: undefined,\n metadata: { refresh: false },\n };\n } catch {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.generic.error.description'),\n },\n };\n }\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private resolveContext(input: AXMPreviewControlHierarchyDiagramCommandInput): Record<string, unknown> {\n const ctxData = input.data;\n if (ctxData) {\n return {\n itemIds: defaultTo(get(ctxData, 'itemIds'), []),\n hierarchyDiagramViewType: defaultTo(get(ctxData, 'hierarchyDiagramViewType'), 'horizontal'),\n id: get(ctxData, 'id'),\n title: get(ctxData, 'title'),\n };\n }\n\n const ctxOpts = defaultTo(input.options, {});\n\n return {\n itemIds: defaultTo(get(input, 'itemIds'), defaultTo(get(ctxOpts, 'itemIds'), [])),\n hierarchyDiagramViewType: defaultTo(\n get(input, 'hierarchyDiagramViewType'),\n defaultTo(get(ctxOpts, 'hierarchyDiagramViewType'), 'horizontal'),\n ),\n id: defaultTo(get(input, 'id'), get(ctxOpts, 'id')),\n title: defaultTo(get(input, 'title'), get(ctxOpts, 'title')),\n };\n }\n\n private async resolveDialogTitle(\n input: AXMPreviewControlHierarchyDiagramCommandInput,\n context: Record<string, unknown>,\n ): Promise<string> {\n const previewLabel =\n (await this.translationService.translateAsync('@general:actions.preview.title')) || 'Preview';\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n\n const explicitTitle = defaultTo(input.title, get(input, 'options.title'));\n if (isString(explicitTitle) && explicitTitle.trim().length > 0) {\n return `${previewLabel}: ${resolveMultiLanguageString(explicitTitle, locale).trim()}`;\n }\n\n const contextTitle = get(context, 'title');\n if (contextTitle != null) {\n const recordTitle = resolveEntityRowDisplayText(contextTitle, locale).trim();\n if (recordTitle.length > 0) {\n return `${previewLabel}: ${recordTitle}`;\n }\n }\n\n const diagramTitle =\n (await this.translationService.translateAsync(\n '@workplacesafety-management:control-measure-types.components.control-hierarchy-diagram.title',\n )) || 'Hierarchy Diagram';\n\n return `${previewLabel}: ${diagramTitle}`;\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAoBA;AAEA;AAEA;;AAEG;MAEU,uCAAuC,CAAA;AADpD,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iCAAiC,CAAC;AAC1D,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0E5D,IAAA;;;IApEC,MAAM,IAAI,CAAC,OAAoD,EAAA;AAC7D,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,wBAAwB,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,0BAA0B,CAAC,EAAE,YAAY,CAAC;AACnG,YAAA,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;YACv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AAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,WAAW,EAAE;YAC1C;QACF;AAEA,QAAA,MAAM,YAAY,GAChB,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAC3C,8FAA8F,CAC/F,KAAK,mBAAmB;AAE3B,QAAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,YAAY,EAAE;IAC3C;8GA7FW,wCAAwC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAxC,wCAAwC,EAAA,CAAA,CAAA;;2FAAxC,wCAAwC,EAAA,UAAA,EAAA,CAAA;kBADpD;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-preview-control-hierarchy-diagram.command-Dd9xdo_y.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/control-hierarchy-diagram/control-hierarchy-diagram-viewer.service.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/control-hierarchy-diagram/commands/preview-control-hierarchy-diagram.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPWidgetsList } from '@acorex-platform/framework-shared/core';\nimport { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get } from 'lodash';\n\nimport { AXMControlHierarchyDiagramService } from './control-hierarchy-diagram.service';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface AXMControlHierarchyDiagramViewerOpenOptions {\n context: Record<string, unknown>;\n title?: string;\n}\n\n//#endregion\n\n//#region ---- Control Hierarchy Diagram Viewer Service ----\n\n/**\n * Opens a read-only control hierarchy diagram preview dialog from form or record context.\n */\n@Injectable({ providedIn: 'root' })\nexport class AXMControlHierarchyDiagramViewerService {\n //#region ---- Services & Dependencies ----\n\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly diagramService = inject(AXMControlHierarchyDiagramService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Public API ----\n\n async open(options: AXMControlHierarchyDiagramViewerOpenOptions): Promise<void> {\n const context = {\n hierarchyDiagramViewType: defaultTo(get(options.context, 'hierarchyDiagramViewType'), 'horizontal'),\n itemIds: defaultTo(get(options.context, 'itemIds'), []),\n id: get(options.context, 'id'),\n title: get(options.context, 'title'),\n hierarchyDiagram: null,\n };\n\n await this.layoutBuilder\n .create()\n .dialog((dialog) => {\n dialog\n .setTitle(this.resolveDialogTitle(options.title))\n .setSize('lg')\n .setCloseButton(true)\n .setContext(context)\n .content((layout) => {\n layout.flex((flex) => {\n flex.setDirection('column');\n flex.formField(\n '@workplacesafety-management:control-measure-types.components.control-hierarchy-diagram.fields.view-type.title',\n (field) => {\n field.path('hierarchyDiagramViewType').selectBox({\n valueField: 'id',\n textField: 'title',\n dataSource: this.diagramService.getViewTypeOptions(),\n });\n },\n );\n flex.formField('', (field) => {\n field\n .path('hierarchyDiagram')\n .setShowLabel(false)\n .mode('view')\n .customWidget(AXPWidgetsList.Editors.ControlHierarchyDiagram, {\n showLabel: false,\n showTitle: false,\n showViewTypeSelector: false,\n viewType: '{{ context.eval(\"hierarchyDiagramViewType\") ?? \"horizontal\" }}',\n triggers: [\n {\n event: \"{{ events.context('hierarchyDiagramViewType') }}\",\n action: '{{ widget.refresh() }}',\n },\n {\n event: \"{{ events.context('itemIds') }}\",\n action: '{{ widget.refresh() }}',\n },\n ],\n });\n });\n });\n });\n })\n .show();\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private resolveDialogTitle(title: string | undefined): string {\n const resolved = resolveEntityRowDisplayText(title, this.translation.getActiveLang() ?? 'en-US');\n return resolved || 'Hierarchy Diagram';\n }\n\n //#endregion\n}\n\n//#endregion\n","//#region ---- Imports ----\n\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\n\nimport { Injectable, inject } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { AXMControlHierarchyDiagramViewerService } from '../control-hierarchy-diagram-viewer.service';\n\n//#endregion\n\n//#region ---- Command Types ----\n\nexport interface AXMPreviewControlHierarchyDiagramCommandInput {\n title?: string;\n itemIds?: unknown;\n hierarchyDiagramViewType?: string;\n id?: string;\n data?: Record<string, unknown>;\n options?: Partial<AXMPreviewControlHierarchyDiagramCommandInput>;\n}\n\n//#endregion\n\n//#region ---- Command ----\n\n@Injectable()\nexport class AXMPreviewControlHierarchyDiagramCommand\n implements AXPCommand<AXMPreviewControlHierarchyDiagramCommandInput, void>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly translationService = inject(AXTranslationService);\n private readonly diagramViewer = inject(AXMControlHierarchyDiagramViewerService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: AXMPreviewControlHierarchyDiagramCommandInput): AXPCommandExecuteResultPromise<void> {\n try {\n const context = this.resolveContext(input);\n const dialogTitle = await this.resolveDialogTitle(input, context);\n\n await this.diagramViewer.open({\n context,\n title: dialogTitle,\n });\n\n return {\n success: true,\n kind: 'object',\n data: undefined,\n metadata: { refresh: false },\n };\n } catch {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.generic.error.description'),\n },\n };\n }\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private resolveContext(input: AXMPreviewControlHierarchyDiagramCommandInput): Record<string, unknown> {\n const ctxData = input.data;\n if (ctxData) {\n return {\n itemIds: defaultTo(get(ctxData, 'itemIds'), []),\n hierarchyDiagramViewType: defaultTo(get(ctxData, 'hierarchyDiagramViewType'), 'horizontal'),\n id: get(ctxData, 'id'),\n title: get(ctxData, 'title'),\n };\n }\n\n const ctxOpts = defaultTo(input.options, {});\n\n return {\n itemIds: defaultTo(get(input, 'itemIds'), defaultTo(get(ctxOpts, 'itemIds'), [])),\n hierarchyDiagramViewType: defaultTo(\n get(input, 'hierarchyDiagramViewType'),\n defaultTo(get(ctxOpts, 'hierarchyDiagramViewType'), 'horizontal'),\n ),\n id: defaultTo(get(input, 'id'), get(ctxOpts, 'id')),\n title: defaultTo(get(input, 'title'), get(ctxOpts, 'title')),\n };\n }\n\n private async resolveDialogTitle(\n input: AXMPreviewControlHierarchyDiagramCommandInput,\n context: Record<string, unknown>,\n ): Promise<string> {\n const previewLabel =\n (await this.translationService.translateAsync('@general:actions.preview.title')) || 'Preview';\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n\n const explicitTitle = defaultTo(input.title, get(input, 'options.title'));\n if (isString(explicitTitle) && explicitTitle.trim().length > 0) {\n return `${previewLabel}: ${resolveMultiLanguageString(explicitTitle, locale).trim()}`;\n }\n\n const contextTitle = get(context, 'title');\n if (contextTitle != null) {\n const recordTitle = resolveEntityRowDisplayText(contextTitle, locale).trim();\n if (recordTitle.length > 0) {\n return `${previewLabel}: ${recordTitle}`;\n }\n }\n\n const diagramTitle =\n (await this.translationService.translateAsync(\n '@workplacesafety-management:control-measure-types.components.control-hierarchy-diagram.title',\n )) || 'Hierarchy Diagram';\n\n return `${previewLabel}: ${diagramTitle}`;\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAoBA;AAEA;AAEA;;AAEG;MAEU,uCAAuC,CAAA;AADpD,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iCAAiC,CAAC;AAC1D,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0E5D,IAAA;;;IApEC,MAAM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I,EAAE,EAAE;QACvF;QAEA,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;AAC1C,QAAA,IAAI,YAAY,IAAI,IAAI,EAAE;YACxB,MAAM,WAAW,GAAG,2BAA2B,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE;AAC5E,YAAA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AAC1B,gBAAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,WAAW,EAAE;YAC1C;QACF;AAEA,QAAA,MAAM,YAAY,GAChB,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAC3C,8FAA8F,CAC/F,KAAK,mBAAmB;AAE3B,QAAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,YAAY,EAAE;IAC3C;8GA7FW,wCAAwC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAxC,wCAAwC,EAAA,CAAA,CAAA;;2FAAxC,wCAAwC,EAAA,UAAA,EAAA,CAAA;kBADpD;;;"}
@@ -0,0 +1,254 @@
1
+ import { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';
2
+ import { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';
3
+ import { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';
4
+ import * as i0 from '@angular/core';
5
+ import { inject, Injectable } from '@angular/core';
6
+ import { get, isString, isEmpty, defaultTo } from 'lodash';
7
+ import { A as AXMSafetyPlanPreviewService } from './acorex-platform-module-workplacesafety-management-client-safety-plan-preview.service-DJP41MuL.mjs';
8
+ import { RootConfig, dedupeSafetyPlanSectionStructure, collectBuiltInRepeatableSectionTypeIds, resolveEntityRefId, normalizeStepTableColumns, isStepTableSectionType, resolveSectionItemEntityName, asSafetyPlanDisplayText } from '@acorex-platform/module-workplacesafety-management-client/contracts';
9
+ import { a as safetyPlanSectionsToBuilderValue, h as hydrateStepTableSectionsWithWorkSteps } from './acorex-platform-module-workplacesafety-management-client-safety-plan-section-builder.types-LaN1NIgc.mjs';
10
+
11
+ //#region ----- Imports -----
12
+ //#endregion
13
+ //#region ----- Constants -----
14
+ const SAFETY_PLAN_SECTION_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanSection.name}`;
15
+ const SAFETY_PLAN_WORK_STEP_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanWorkStep.name}`;
16
+ const SECTION_TYPE_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.sectionType.name}`;
17
+ const WORK_STEP_TYPE_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.workStepType.name}`;
18
+ //#endregion
19
+ //#region ----- Public API -----
20
+ /**
21
+ * Loads a safety plan's section structure for the existing preview modal
22
+ * (same shape the sections page feeds into AXMSafetyPlanPreviewService).
23
+ */
24
+ async function loadSafetyPlanPreviewStructure(entityService, translationService, planId) {
25
+ const repeatableSectionTypeIds = await loadRepeatableSectionTypeIds(entityService);
26
+ const result = await entityService.withEntity(SAFETY_PLAN_SECTION_ENTITY).data().query({
27
+ skip: 0,
28
+ take: 1000,
29
+ filter: {
30
+ logic: 'and',
31
+ filters: [{ field: 'safetyPlanId', operator: { type: 'equal' }, value: planId }],
32
+ },
33
+ });
34
+ const rawLoaded = safetyPlanSectionsToBuilderValue((result.items ?? []));
35
+ const deduped = dedupeSafetyPlanSectionStructure(rawLoaded, { repeatableSectionTypeIds });
36
+ const workStepsResult = await entityService.withEntity(SAFETY_PLAN_WORK_STEP_ENTITY).data().query({
37
+ skip: 0,
38
+ take: 2000,
39
+ filter: {
40
+ logic: 'and',
41
+ filters: [{ field: 'safetyPlanId', operator: { type: 'equal' }, value: planId }],
42
+ },
43
+ });
44
+ const columnsByWorkStepTypeId = await loadWorkStepTypeColumns(entityService, deduped.sections
45
+ .map((section) => section.workStepTypeId)
46
+ .filter((id) => typeof id === 'string' && id.length > 0));
47
+ return hydrateCatalogItemSnapshots(entityService, translationService, hydrateStepTableSectionsWithWorkSteps(deduped, (workStepsResult.items ?? []), columnsByWorkStepTypeId));
48
+ }
49
+ //#endregion
50
+ //#region ----- Helpers -----
51
+ async function loadRepeatableSectionTypeIds(entityService) {
52
+ const builtIn = collectBuiltInRepeatableSectionTypeIds();
53
+ try {
54
+ const result = await entityService.withEntity(SECTION_TYPE_ENTITY).data().query({
55
+ skip: 0,
56
+ take: 1000,
57
+ });
58
+ const fromQuery = (result.items ?? [])
59
+ .filter((row) => row.isRepeatable === true)
60
+ .map((row) => resolveEntityRefId(row.id))
61
+ .filter((id) => !!id);
62
+ return [...new Set([...fromQuery, ...builtIn])];
63
+ }
64
+ catch {
65
+ return builtIn;
66
+ }
67
+ }
68
+ async function loadWorkStepTypeColumns(entityService, workStepTypeIds) {
69
+ const uniqueIds = [...new Set(workStepTypeIds)];
70
+ const columnsById = new Map();
71
+ if (!uniqueIds.length) {
72
+ return columnsById;
73
+ }
74
+ const accessor = entityService.withEntity(WORK_STEP_TYPE_ENTITY);
75
+ await Promise.all(uniqueIds.map(async (id) => {
76
+ try {
77
+ const row = await accessor.data().byKey(id);
78
+ if (!row) {
79
+ return;
80
+ }
81
+ const record = row;
82
+ columnsById.set(id, normalizeStepTableColumns(record.columns));
83
+ }
84
+ catch {
85
+ // Leave missing types without columns; hydrate falls back to row snapshots.
86
+ }
87
+ }));
88
+ return columnsById;
89
+ }
90
+ async function hydrateCatalogItemSnapshots(entityService, translationService, value) {
91
+ const locale = translationService.getActiveLang?.() ?? 'en-US';
92
+ const missingByEntity = new Map();
93
+ for (const section of value.sections) {
94
+ if (isStepTableSectionType(section.sectionTypeId, section.sectionType)) {
95
+ continue;
96
+ }
97
+ const entityName = resolveSectionItemEntityName(section.sectionTypeId, section.sectionType);
98
+ if (!entityName) {
99
+ continue;
100
+ }
101
+ for (const slot of section.items) {
102
+ for (const id of slot.itemIds ?? []) {
103
+ const snapshot = slot.items?.find((entry) => entry.id === id);
104
+ if (asSafetyPlanDisplayText(snapshot?.title) || asSafetyPlanDisplayText(snapshot?.code)) {
105
+ continue;
106
+ }
107
+ const ids = missingByEntity.get(entityName) ?? new Set();
108
+ ids.add(id);
109
+ missingByEntity.set(entityName, ids);
110
+ }
111
+ }
112
+ }
113
+ if (missingByEntity.size === 0) {
114
+ return value;
115
+ }
116
+ const loadedById = new Map();
117
+ await Promise.all([...missingByEntity.entries()].map(async ([entityName, ids]) => {
118
+ const idList = [...ids];
119
+ try {
120
+ const result = await entityService.withEntity(entityName).data().query({
121
+ skip: 0,
122
+ take: Math.max(idList.length, 1),
123
+ filter: idList.length === 1
124
+ ? { field: 'id', operator: { type: 'equal' }, value: idList[0] }
125
+ : { field: 'id', operator: { type: 'in' }, value: idList },
126
+ });
127
+ for (const row of result.items ?? []) {
128
+ const record = row;
129
+ const id = resolveEntityRefId(record['id']);
130
+ if (!id) {
131
+ continue;
132
+ }
133
+ loadedById.set(id, {
134
+ title: resolveEntityRowDisplayText(record['title'], locale) || undefined,
135
+ code: asSafetyPlanDisplayText(record['code']) || undefined,
136
+ });
137
+ }
138
+ }
139
+ catch {
140
+ /* skip entities the session cannot read */
141
+ }
142
+ }));
143
+ if (loadedById.size === 0) {
144
+ return value;
145
+ }
146
+ return {
147
+ sections: value.sections.map((section) => ({
148
+ ...section,
149
+ items: section.items.map((slot) => ({
150
+ ...slot,
151
+ items: (slot.itemIds ?? []).map((id, index) => {
152
+ const existing = slot.items?.find((entry) => entry.id === id) ?? slot.items?.[index];
153
+ const loaded = loadedById.get(id);
154
+ return {
155
+ id,
156
+ title: asSafetyPlanDisplayText(existing?.title) || loaded?.title,
157
+ code: asSafetyPlanDisplayText(existing?.code) || loaded?.code,
158
+ };
159
+ }),
160
+ })),
161
+ })),
162
+ };
163
+ }
164
+ //#endregion
165
+
166
+ //#region ----- Imports -----
167
+ //#endregion
168
+ //#region ----- Command -----
169
+ class AXMPreviewSafetyPlanCommand {
170
+ constructor() {
171
+ //#region ----- Services & Dependencies -----
172
+ this.entityService = inject(AXPEntityService);
173
+ this.translationService = inject(AXTranslationService);
174
+ this.previewService = inject(AXMSafetyPlanPreviewService);
175
+ }
176
+ //#endregion
177
+ //#region ----- Command Implementation -----
178
+ async execute(input = {}) {
179
+ try {
180
+ const planId = this.resolvePlanId(input);
181
+ if (!planId) {
182
+ return {
183
+ success: false,
184
+ message: {
185
+ text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),
186
+ },
187
+ };
188
+ }
189
+ const structure = await loadSafetyPlanPreviewStructure(this.entityService, this.translationService, planId);
190
+ const dialogTitle = await this.resolveDialogTitle(input);
191
+ await this.previewService.open({
192
+ title: dialogTitle,
193
+ structure,
194
+ });
195
+ return {
196
+ success: true,
197
+ kind: 'object',
198
+ data: undefined,
199
+ metadata: { refresh: false },
200
+ };
201
+ }
202
+ catch {
203
+ return {
204
+ success: false,
205
+ message: {
206
+ text: await this.translationService.translateAsync('@general:messages.generic.error.description'),
207
+ },
208
+ };
209
+ }
210
+ }
211
+ //#endregion
212
+ //#region ----- Utility Methods -----
213
+ resolvePlanId(input) {
214
+ const context = input.__context__;
215
+ const candidates = [
216
+ input.id,
217
+ input.options?.id,
218
+ get(input, 'options.id'),
219
+ context?.options?.id,
220
+ context?.data?.id,
221
+ input.data?.['id'],
222
+ ];
223
+ for (const candidate of candidates) {
224
+ if (isString(candidate) && !isEmpty(candidate.trim())) {
225
+ return candidate.trim();
226
+ }
227
+ }
228
+ return undefined;
229
+ }
230
+ async resolveDialogTitle(input) {
231
+ const previewLabel = (await this.translationService.translateAsync('@general:actions.preview.title')) || 'Preview';
232
+ const locale = this.translationService.getActiveLang?.() ?? 'en-US';
233
+ const explicitTitle = defaultTo(input.title, defaultTo(input.options?.title, defaultTo(get(input, 'options.title'), input.__context__?.options?.title)));
234
+ if (isString(explicitTitle) && explicitTitle.trim().length > 0) {
235
+ return `${previewLabel}: ${resolveMultiLanguageString(explicitTitle, locale).trim()}`;
236
+ }
237
+ const contextTitle = defaultTo(input.data?.['title'], input.__context__?.data?.title);
238
+ if (contextTitle != null) {
239
+ const recordTitle = resolveEntityRowDisplayText(contextTitle, locale).trim();
240
+ if (recordTitle.length > 0) {
241
+ return `${previewLabel}: ${recordTitle}`;
242
+ }
243
+ }
244
+ return previewLabel;
245
+ }
246
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPreviewSafetyPlanCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
247
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPreviewSafetyPlanCommand }); }
248
+ }
249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMPreviewSafetyPlanCommand, decorators: [{
250
+ type: Injectable
251
+ }] });
252
+
253
+ export { AXMPreviewSafetyPlanCommand };
254
+ //# sourceMappingURL=acorex-platform-module-workplacesafety-management-client-preview-safety-plan.command-BU95c4xb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-workplacesafety-management-client-preview-safety-plan.command-BU95c4xb.mjs","sources":["../../../../libs/modules/workplacesafety-management/client/src/lib/features/safety-plan/commands/load-safety-plan-preview-structure.ts","../../../../libs/modules/workplacesafety-management/client/src/lib/features/safety-plan/commands/preview-safety-plan.command.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport {\n asSafetyPlanDisplayText,\n collectBuiltInRepeatableSectionTypeIds,\n dedupeSafetyPlanSectionStructure,\n isStepTableSectionType,\n normalizeStepTableColumns,\n resolveEntityRefId,\n resolveSectionItemEntityName,\n RootConfig,\n type AXMSafetyPlanSectionBuilderValue,\n type AXMStepTableColumnDef,\n} from '@acorex-platform/module-workplacesafety-management-client/contracts';\nimport { AXTranslationService } from '@acorex/core/translation';\n\nimport {\n hydrateStepTableSectionsWithWorkSteps,\n safetyPlanSectionsToBuilderValue,\n} from '../../safety-plan-sections-page/safety-plan-section-builder.types';\n\n//#endregion\n\n//#region ----- Constants -----\n\nconst SAFETY_PLAN_SECTION_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanSection.name}`;\nconst SAFETY_PLAN_WORK_STEP_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.safetyPlanWorkStep.name}`;\nconst SECTION_TYPE_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.sectionType.name}`;\nconst WORK_STEP_TYPE_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.workStepType.name}`;\n\n//#endregion\n\n//#region ----- Public API -----\n\n/**\n * Loads a safety plan's section structure for the existing preview modal\n * (same shape the sections page feeds into AXMSafetyPlanPreviewService).\n */\nexport async function loadSafetyPlanPreviewStructure(\n entityService: AXPEntityService,\n translationService: AXTranslationService,\n planId: string,\n): Promise<AXMSafetyPlanSectionBuilderValue> {\n const repeatableSectionTypeIds = await loadRepeatableSectionTypeIds(entityService);\n\n const result = await entityService.withEntity(SAFETY_PLAN_SECTION_ENTITY).data().query({\n skip: 0,\n take: 1000,\n filter: {\n logic: 'and',\n filters: [{ field: 'safetyPlanId', operator: { type: 'equal' }, value: planId }],\n },\n } as never);\n\n const rawLoaded = safetyPlanSectionsToBuilderValue(\n (result.items ?? []) as Parameters<typeof safetyPlanSectionsToBuilderValue>[0],\n );\n const deduped = dedupeSafetyPlanSectionStructure(rawLoaded, { repeatableSectionTypeIds });\n\n const workStepsResult = await entityService.withEntity(SAFETY_PLAN_WORK_STEP_ENTITY).data().query({\n skip: 0,\n take: 2000,\n filter: {\n logic: 'and',\n filters: [{ field: 'safetyPlanId', operator: { type: 'equal' }, value: planId }],\n },\n } as never);\n\n const columnsByWorkStepTypeId = await loadWorkStepTypeColumns(\n entityService,\n deduped.sections\n .map((section) => section.workStepTypeId)\n .filter((id): id is string => typeof id === 'string' && id.length > 0),\n );\n\n return hydrateCatalogItemSnapshots(\n entityService,\n translationService,\n hydrateStepTableSectionsWithWorkSteps(\n deduped,\n (workStepsResult.items ?? []) as Parameters<typeof hydrateStepTableSectionsWithWorkSteps>[1],\n columnsByWorkStepTypeId,\n ),\n );\n}\n\n//#endregion\n\n//#region ----- Helpers -----\n\nasync function loadRepeatableSectionTypeIds(entityService: AXPEntityService): Promise<string[]> {\n const builtIn = collectBuiltInRepeatableSectionTypeIds();\n try {\n const result = await entityService.withEntity(SECTION_TYPE_ENTITY).data().query({\n skip: 0,\n take: 1000,\n } as never);\n const fromQuery = (result.items ?? [])\n .filter((row) => (row as { isRepeatable?: unknown }).isRepeatable === true)\n .map((row) => resolveEntityRefId((row as { id?: unknown }).id))\n .filter((id): id is string => !!id);\n return [...new Set([...fromQuery, ...builtIn])];\n } catch {\n return builtIn;\n }\n}\n\nasync function loadWorkStepTypeColumns(\n entityService: AXPEntityService,\n workStepTypeIds: readonly string[],\n): Promise<Map<string, AXMStepTableColumnDef[]>> {\n const uniqueIds = [...new Set(workStepTypeIds)];\n const columnsById = new Map<string, AXMStepTableColumnDef[]>();\n if (!uniqueIds.length) {\n return columnsById;\n }\n\n const accessor = entityService.withEntity(WORK_STEP_TYPE_ENTITY);\n await Promise.all(\n uniqueIds.map(async (id) => {\n try {\n const row = await accessor.data().byKey(id);\n if (!row) {\n return;\n }\n const record = row as { columns?: AXMStepTableColumnDef[] };\n columnsById.set(id, normalizeStepTableColumns(record.columns));\n } catch {\n // Leave missing types without columns; hydrate falls back to row snapshots.\n }\n }),\n );\n return columnsById;\n}\n\nasync function hydrateCatalogItemSnapshots(\n entityService: AXPEntityService,\n translationService: AXTranslationService,\n value: AXMSafetyPlanSectionBuilderValue,\n): Promise<AXMSafetyPlanSectionBuilderValue> {\n const locale = translationService.getActiveLang?.() ?? 'en-US';\n const missingByEntity = new Map<string, Set<string>>();\n\n for (const section of value.sections) {\n if (isStepTableSectionType(section.sectionTypeId, section.sectionType)) {\n continue;\n }\n const entityName = resolveSectionItemEntityName(section.sectionTypeId, section.sectionType);\n if (!entityName) {\n continue;\n }\n for (const slot of section.items) {\n for (const id of slot.itemIds ?? []) {\n const snapshot = slot.items?.find((entry) => entry.id === id);\n if (asSafetyPlanDisplayText(snapshot?.title) || asSafetyPlanDisplayText(snapshot?.code)) {\n continue;\n }\n const ids = missingByEntity.get(entityName) ?? new Set<string>();\n ids.add(id);\n missingByEntity.set(entityName, ids);\n }\n }\n }\n\n if (missingByEntity.size === 0) {\n return value;\n }\n\n const loadedById = new Map<string, { title?: string; code?: string }>();\n await Promise.all(\n [...missingByEntity.entries()].map(async ([entityName, ids]) => {\n const idList = [...ids];\n try {\n const result = await entityService.withEntity(entityName).data().query({\n skip: 0,\n take: Math.max(idList.length, 1),\n filter:\n idList.length === 1\n ? { field: 'id', operator: { type: 'equal' }, value: idList[0] }\n : { field: 'id', operator: { type: 'in' }, value: idList },\n } as never);\n for (const row of result.items ?? []) {\n const record = row as unknown as Record<string, unknown>;\n const id = resolveEntityRefId(record['id']);\n if (!id) {\n continue;\n }\n loadedById.set(id, {\n title: resolveEntityRowDisplayText(record['title'], locale) || undefined,\n code: asSafetyPlanDisplayText(record['code']) || undefined,\n });\n }\n } catch {\n /* skip entities the session cannot read */\n }\n }),\n );\n\n if (loadedById.size === 0) {\n return value;\n }\n\n return {\n sections: value.sections.map((section) => ({\n ...section,\n items: section.items.map((slot) => ({\n ...slot,\n items: (slot.itemIds ?? []).map((id, index) => {\n const existing = slot.items?.find((entry) => entry.id === id) ?? slot.items?.[index];\n const loaded = loadedById.get(id);\n return {\n id,\n title: asSafetyPlanDisplayText(existing?.title) || loaded?.title,\n code: asSafetyPlanDisplayText(existing?.code) || loaded?.code,\n };\n }),\n })),\n })),\n };\n}\n\n//#endregion\n","//#region ----- Imports -----\n\nimport { resolveEntityRowDisplayText } from '@acorex-platform/framework-client/common';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';\nimport { Injectable, inject } from '@angular/core';\nimport { defaultTo, get, isEmpty, isString } from 'lodash';\n\nimport { AXMSafetyPlanPreviewService } from '../../safety-plan-preview/safety-plan-preview.service';\nimport { loadSafetyPlanPreviewStructure } from './load-safety-plan-preview-structure';\n\n//#endregion\n\n//#region ----- Types -----\n\nexport interface AXMPreviewSafetyPlanCommandInput {\n id?: string;\n title?: string;\n data?: Record<string, unknown>;\n options?: Partial<AXMPreviewSafetyPlanCommandInput>;\n __context__?: {\n entity?: string;\n data?: { id?: string; title?: unknown };\n options?: { id?: string; title?: unknown };\n };\n}\n\n//#endregion\n\n//#region ----- Command -----\n\n@Injectable()\nexport class AXMPreviewSafetyPlanCommand implements AXPCommand<AXMPreviewSafetyPlanCommandInput, void> {\n //#region ----- Services & Dependencies -----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly translationService = inject(AXTranslationService);\n private readonly previewService = inject(AXMSafetyPlanPreviewService);\n\n //#endregion\n\n //#region ----- Command Implementation -----\n\n async execute(input: AXMPreviewSafetyPlanCommandInput = {}): AXPCommandExecuteResultPromise<void> {\n try {\n const planId = this.resolvePlanId(input);\n if (!planId) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n const structure = await loadSafetyPlanPreviewStructure(\n this.entityService,\n this.translationService,\n planId,\n );\n const dialogTitle = await this.resolveDialogTitle(input);\n\n await this.previewService.open({\n title: dialogTitle,\n structure,\n });\n\n return {\n success: true,\n kind: 'object',\n data: undefined,\n metadata: { refresh: false },\n };\n } catch {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.generic.error.description'),\n },\n };\n }\n }\n\n //#endregion\n\n //#region ----- Utility Methods -----\n\n private resolvePlanId(input: AXMPreviewSafetyPlanCommandInput): string | undefined {\n const context = input.__context__;\n const candidates = [\n input.id,\n input.options?.id,\n get(input, 'options.id'),\n context?.options?.id,\n context?.data?.id,\n input.data?.['id'],\n ];\n\n for (const candidate of candidates) {\n if (isString(candidate) && !isEmpty(candidate.trim())) {\n return candidate.trim();\n }\n }\n\n return undefined;\n }\n\n private async resolveDialogTitle(input: AXMPreviewSafetyPlanCommandInput): Promise<string> {\n const previewLabel =\n (await this.translationService.translateAsync('@general:actions.preview.title')) || 'Preview';\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n\n const explicitTitle = defaultTo(\n input.title,\n defaultTo(input.options?.title, defaultTo(get(input, 'options.title'), input.__context__?.options?.title)),\n );\n if (isString(explicitTitle) && explicitTitle.trim().length > 0) {\n return `${previewLabel}: ${resolveMultiLanguageString(explicitTitle, locale).trim()}`;\n }\n\n const contextTitle = defaultTo(input.data?.['title'], input.__context__?.data?.title);\n if (contextTitle != null) {\n const recordTitle = resolveEntityRowDisplayText(contextTitle, locale).trim();\n if (recordTitle.length > 0) {\n return `${previewLabel}: ${recordTitle}`;\n }\n }\n\n return previewLabel;\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AAuBA;AAEA;AAEA,MAAM,0BAA0B,GAAG,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,EAAE;AAC5G,MAAM,4BAA4B,GAAG,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAI,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE;AAC/G,MAAM,mBAAmB,GAAG,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE;AAC/F,MAAM,qBAAqB,GAAG,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,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W,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAC3G;AACD,QAAA,IAAI,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;AAC9D,YAAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACvF;QAEA,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC;AACrF,QAAA,IAAI,YAAY,IAAI,IAAI,EAAE;YACxB,MAAM,WAAW,GAAG,2BAA2B,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE;AAC5E,YAAA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AAC1B,gBAAA,OAAO,CAAA,EAAG,YAAY,CAAA,EAAA,EAAK,WAAW,EAAE;YAC1C;QACF;AAEA,QAAA,OAAO,YAAY;IACrB;8GAjGW,2BAA2B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAA3B,2BAA2B,EAAA,CAAA,CAAA;;2FAA3B,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBADvC;;;"}
@@ -1 +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-client/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,G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,"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-client/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;IAC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