@acorex-platform/module-maintenance-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 (84) hide show
  1. package/fesm2022/{acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BiQlJxPX.mjs → acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BI7RNP_h.mjs} +13 -13
  2. package/fesm2022/{acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BiQlJxPX.mjs.map → acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BI7RNP_h.mjs.map} +1 -1
  3. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-activity-type-asset-type.mjs.map +1 -1
  4. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-activity-type-resource.mjs.map +1 -1
  5. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-activity-type.mjs.map +1 -1
  6. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-cause.mjs.map +1 -1
  7. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-detection.mjs.map +1 -1
  8. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-effect.mjs.map +1 -1
  9. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-mechanism.mjs.map +1 -1
  10. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-mode-asset-type.mjs.map +1 -1
  11. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-mode-mechanism.mjs.map +1 -1
  12. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-mode-solution.mjs.map +1 -1
  13. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-mode.mjs.map +1 -1
  14. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-register-cause.mjs.map +1 -1
  15. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-register-effect.mjs.map +1 -1
  16. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-register-mechanism.mjs.map +1 -1
  17. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-register.mjs.map +1 -1
  18. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-severity.mjs.map +1 -1
  19. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-failure-type.mjs.map +1 -1
  20. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-plan.mjs.map +1 -1
  21. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-template-activity-type.mjs.map +1 -1
  22. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-template-failure-mode.mjs.map +1 -1
  23. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-template-resource.mjs.map +1 -1
  24. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-template.mjs.map +1 -1
  25. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-maintenance-type.mjs.map +1 -1
  26. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-work-order.mjs.map +1 -1
  27. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-work-package.mjs.map +1 -1
  28. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entities-work-report.mjs.map +1 -1
  29. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-acorex-platform-module-maintenance-management-client-contracts-entity-catalog-DJkKh0Qa.mjs.map +1 -1
  30. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-activity-type-asset-type.entity--Kz4Kqqe.mjs.map +1 -1
  31. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-activity-type-resource.entity-C2OP2EN0.mjs.map +1 -1
  32. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-activity-type.entity-D9UUDRIS.mjs.map +1 -1
  33. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-cause.entity-glUcXwS9.mjs.map +1 -1
  34. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-detection.entity-CTp1voFW.mjs.map +1 -1
  35. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-effect.entity-ClD09en8.mjs.map +1 -1
  36. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-mechanism.entity-BcU0-nFS.mjs.map +1 -1
  37. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-mode-asset-type.entity-N37srLVb.mjs.map +1 -1
  38. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-mode-mechanism.entity-BkkvXk03.mjs.map +1 -1
  39. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-mode-solution.entity-HlVVBMTA.mjs.map +1 -1
  40. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-mode.entity-BGJP73yC.mjs.map +1 -1
  41. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-register-cause.entity-CLM9YuYF.mjs.map +1 -1
  42. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-register-effect.entity-DpLYMLsi.mjs.map +1 -1
  43. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-register-mechanism.entity-DqU2wP0I.mjs.map +1 -1
  44. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-register.entity-BPZwEGE9.mjs.map +1 -1
  45. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-severity.entity-DaMUJOID.mjs.map +1 -1
  46. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-failure-type.entity-DkhVvBOh.mjs.map +1 -1
  47. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-plan.entity-WCiP2h8H.mjs.map +1 -1
  48. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-template-activity-type.entity-FWn7bmMX.mjs.map +1 -1
  49. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-template-failure-mode.entity-DC5GTHYM.mjs.map +1 -1
  50. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-template-resource.entity-O6y3Q3U6.mjs.map +1 -1
  51. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-template.entity-DFDajM9U.mjs.map +1 -1
  52. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-maintenance-type.entity-CGSHreth.mjs.map +1 -1
  53. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-work-order.entity-GaQSPAmn.mjs.map +1 -1
  54. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-work-package.entity-CJE8Txjo.mjs.map +1 -1
  55. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts-entity-catalog-work-report.entity-BrActlGh.mjs.map +1 -1
  56. package/fesm2022/acorex-platform-module-maintenance-management-client-contracts.mjs.map +1 -1
  57. package/fesm2022/{acorex-platform-module-maintenance-management-client-create-or-get-work-report-draft.activity-xxvOfIxf.mjs → acorex-platform-module-maintenance-management-client-create-or-get-work-report-draft.activity-By_yjJjy.mjs} +2 -2
  58. package/fesm2022/{acorex-platform-module-maintenance-management-client-create-or-get-work-report-draft.activity-xxvOfIxf.mjs.map → acorex-platform-module-maintenance-management-client-create-or-get-work-report-draft.activity-By_yjJjy.mjs.map} +1 -1
  59. package/fesm2022/acorex-platform-module-maintenance-management-client-failure-register-status.provider-CLBaQy_e.mjs.map +1 -1
  60. package/fesm2022/acorex-platform-module-maintenance-management-client-fill-work-report-completion.command-Capowl1e.mjs.map +1 -1
  61. package/fesm2022/acorex-platform-module-maintenance-management-client-local-entities.mjs.map +1 -1
  62. package/fesm2022/acorex-platform-module-maintenance-management-client-open-work-report-from-work-order.command-B0O4fWPt.mjs.map +1 -1
  63. package/fesm2022/{acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CxRfaf0G.mjs → acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CcH5qKzv.mjs} +2 -2
  64. package/fesm2022/{acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CxRfaf0G.mjs.map → acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CcH5qKzv.mjs.map} +1 -1
  65. package/fesm2022/acorex-platform-module-maintenance-management-client-resolve-person-user-id.activity-nwXAJHkd.mjs.map +1 -1
  66. package/fesm2022/acorex-platform-module-maintenance-management-client-resolve-work-order.activity-q5WM7Sv5.mjs.map +1 -1
  67. package/fesm2022/{acorex-platform-module-maintenance-management-client-start-work-order-flow.command-B06a962Y.mjs → acorex-platform-module-maintenance-management-client-start-work-order-flow.command-CVlDdtxW.mjs} +2 -2
  68. package/fesm2022/{acorex-platform-module-maintenance-management-client-start-work-order-flow.command-B06a962Y.mjs.map → acorex-platform-module-maintenance-management-client-start-work-order-flow.command-CVlDdtxW.mjs.map} +1 -1
  69. package/fesm2022/acorex-platform-module-maintenance-management-client-update-work-order-completed.activity-Di4R6LQl.mjs.map +1 -1
  70. package/fesm2022/{acorex-platform-module-maintenance-management-client-update-work-order-in-progress.activity-CzkCCl1L.mjs → acorex-platform-module-maintenance-management-client-update-work-order-in-progress.activity-CZwXs7XY.mjs} +2 -2
  71. package/fesm2022/{acorex-platform-module-maintenance-management-client-update-work-order-in-progress.activity-CzkCCl1L.mjs.map → acorex-platform-module-maintenance-management-client-update-work-order-in-progress.activity-CZwXs7XY.mjs.map} +1 -1
  72. package/fesm2022/acorex-platform-module-maintenance-management-client-update-work-report-on-completion.activity-_B0SUFtQ.mjs.map +1 -1
  73. package/fesm2022/acorex-platform-module-maintenance-management-client-validate-work-order-completion.activity-RA2zaQHH.mjs.map +1 -1
  74. package/fesm2022/acorex-platform-module-maintenance-management-client-work-order-list-command-Bh_6PS5w.mjs.map +1 -1
  75. package/fesm2022/acorex-platform-module-maintenance-management-client-work-order-status.provider-DvBk5kAW.mjs.map +1 -1
  76. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-order-work-report-column.component-Bf1WZWIS.mjs → acorex-platform-module-maintenance-management-client-work-order-work-report-column.component-BikBvmHi.mjs} +2 -2
  77. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-order-work-report-column.component-Bf1WZWIS.mjs.map → acorex-platform-module-maintenance-management-client-work-order-work-report-column.component-BikBvmHi.mjs.map} +1 -1
  78. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-order-workflow-column.component-Dth3Z9fW.mjs → acorex-platform-module-maintenance-management-client-work-order-workflow-column.component-yzj-D7MB.mjs} +3 -3
  79. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-order-workflow-column.component-Dth3Z9fW.mjs.map → acorex-platform-module-maintenance-management-client-work-order-workflow-column.component-yzj-D7MB.mjs.map} +1 -1
  80. package/fesm2022/acorex-platform-module-maintenance-management-client-work-report-assessment.util-Da1HVAit.mjs.map +1 -1
  81. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-report-checklist-results-view.component-BSFW0Yt-.mjs → acorex-platform-module-maintenance-management-client-work-report-checklist-results-view.component-BgIQr5Hr.mjs} +2 -2
  82. package/fesm2022/{acorex-platform-module-maintenance-management-client-work-report-checklist-results-view.component-BSFW0Yt-.mjs.map → acorex-platform-module-maintenance-management-client-work-report-checklist-results-view.component-BgIQr5Hr.mjs.map} +1 -1
  83. package/fesm2022/acorex-platform-module-maintenance-management-client.mjs +1 -1
  84. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-failure-register-status.provider-CLBaQy_e.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/failure-register-status.provider.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXStyleColorType } from '@acorex/cdk/common';\nimport { AXPStatusProvider, AXPStatusTransition } from '@acorex-platform/framework-shared/core';\n\nimport { AXMFailureRegisterStatus } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Status provider ----\n\nexport class AXMMaintenanceManagementFailureRegisterStatusProvider extends AXPStatusProvider {\n readonly key = 'maintenance-management.status.failure-register';\n\n readonly statuses = [\n {\n name: AXMFailureRegisterStatus.Reported,\n title: '@maintenance-management:failure-registers.states.reported',\n icon: 'fa-light fa-file-circle-plus',\n color: 'secondary' as AXStyleColorType,\n order: 1,\n isInitial: true,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.UnderReview,\n title: '@maintenance-management:failure-registers.states.under-review',\n icon: 'fa-light fa-magnifying-glass',\n color: 'warning' as AXStyleColorType,\n order: 2,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.states.work-order-required',\n icon: 'fa-light fa-clipboard-list',\n color: 'accent1' as AXStyleColorType,\n order: 3,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.WorkOrderCreated,\n title: '@maintenance-management:failure-registers.states.work-order-created',\n icon: 'fa-light fa-file-lines',\n color: 'info' as AXStyleColorType,\n order: 4,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.InProgress,\n title: '@maintenance-management:failure-registers.states.in-progress',\n icon: 'fa-light fa-screwdriver-wrench',\n color: 'primary' as AXStyleColorType,\n order: 5,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Resolved,\n title: '@maintenance-management:failure-registers.states.resolved',\n icon: 'fa-light fa-circle-check',\n color: 'success' as AXStyleColorType,\n order: 6,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.FollowUpRequired,\n title: '@maintenance-management:failure-registers.states.follow-up-required',\n icon: 'fa-light fa-arrow-rotate-right',\n color: 'warning' as AXStyleColorType,\n order: 7,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Rejected,\n title: '@maintenance-management:failure-registers.states.rejected',\n icon: 'fa-light fa-ban',\n color: 'danger' as AXStyleColorType,\n order: 8,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Duplicate,\n title: '@maintenance-management:failure-registers.states.duplicate',\n icon: 'fa-light fa-clone',\n color: 'neutral' as AXStyleColorType,\n order: 9,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.states.closed',\n icon: 'fa-light fa-folder-closed',\n color: 'neutral' as AXStyleColorType,\n order: 10,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n ];\n\n readonly transitions: AXPStatusTransition[] = [\n {\n from: AXMFailureRegisterStatus.Reported,\n to: AXMFailureRegisterStatus.UnderReview,\n title: '@maintenance-management:failure-registers.status.transitions.submit-for-review',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.status.transitions.require-work-order',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.Rejected,\n title: '@maintenance-management:failure-registers.status.transitions.reject',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.Duplicate,\n title: '@maintenance-management:failure-registers.status.transitions.mark-duplicate',\n },\n {\n from: AXMFailureRegisterStatus.WorkOrderRequired,\n to: AXMFailureRegisterStatus.WorkOrderCreated,\n title: '@maintenance-management:failure-registers.status.transitions.create-work-order',\n },\n {\n from: AXMFailureRegisterStatus.WorkOrderCreated,\n to: AXMFailureRegisterStatus.InProgress,\n title: '@maintenance-management:failure-registers.status.transitions.start-work-order',\n },\n {\n from: AXMFailureRegisterStatus.InProgress,\n to: AXMFailureRegisterStatus.Resolved,\n title: '@maintenance-management:failure-registers.status.transitions.resolve',\n },\n {\n from: AXMFailureRegisterStatus.InProgress,\n to: AXMFailureRegisterStatus.FollowUpRequired,\n title: '@maintenance-management:failure-registers.status.transitions.require-follow-up',\n },\n {\n from: AXMFailureRegisterStatus.FollowUpRequired,\n to: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.status.transitions.create-follow-up-work-order',\n },\n {\n from: AXMFailureRegisterStatus.Resolved,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n {\n from: AXMFailureRegisterStatus.Rejected,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n {\n from: AXMFailureRegisterStatus.Duplicate,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n ];\n\n readonly defaultStatus = AXMFailureRegisterStatus.Reported;\n}\n\n//#endregion\n"],"names":[],"mappings":";;;AAAA;AAOA;AAEA;AAEM,MAAO,qDAAsD,SAAQ,iBAAiB,CAAA;AAA5F,IAAA,WAAA,GAAA;;QACW,IAAA,CAAA,GAAG,GAAG,gDAAgD;AAEtD,QAAA,IAAA,CAAA,QAAQ,GAAG;AAClB,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,QAAQ;AACvC,gBAAA,KAAK,EAAE,2DAA2D;AAClE,gBAAA,IAAI,EAAE,8BAA8B;AACpC,gBAAA,KAAK,EAAE,WAA+B;AACtC,gBAAA,KAAK,EAAE,CAAC;AACR,gBAAA,SAAS,EAAE,IAAI;AACf,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,YAAY,EAAE,KAAK;AACpB,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,WAAW;AAC1C,gBAAA,KAAK,EAAE,+DAA+D;AACtE,gBAAA,IAAI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AAwB,CAAC,iBAAiB;AAC9C,gBAAA,KAAK,EAAE,0FAA0F;AAClG,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,QAAQ;gBACvC,EAAE,EAAE,wBAAwB,CAAC,MAAM;AACnC,gBAAA,KAAK,EAAE,oEAAoE;AAC5E,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,QAAQ;gBACvC,EAAE,EAAE,wBAAwB,CAAC,MAAM;AACnC,gBAAA,KAAK,EAAE,oEAAoE;AAC5E,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,SAAS;gBACxC,EAAE,EAAE,wBAAwB,CAAC,MAAM;AACnC,gBAAA,KAAK,EAAE,oEAAoE;AAC5E,aAAA;SACF;AAEQ,QAAA,IAAA,CAAA,aAAa,GAAG,wBAAwB,CAAC,QAAQ;IAC5D;AAAC;AAED;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-failure-register-status.provider-CLBaQy_e.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/failure-register-status.provider.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXStyleColorType } from '@acorex/cdk/common';\nimport { AXPStatusProvider, AXPStatusTransition } from '@acorex-platform/framework-shared/core';\n\nimport { AXMFailureRegisterStatus } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Status provider ----\n\nexport class AXMMaintenanceManagementFailureRegisterStatusProvider extends AXPStatusProvider {\n readonly key = 'maintenance-management.status.failure-register';\n\n readonly statuses = [\n {\n name: AXMFailureRegisterStatus.Reported,\n title: '@maintenance-management:failure-registers.states.reported',\n icon: 'fa-light fa-file-circle-plus',\n color: 'secondary' as AXStyleColorType,\n order: 1,\n isInitial: true,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.UnderReview,\n title: '@maintenance-management:failure-registers.states.under-review',\n icon: 'fa-light fa-magnifying-glass',\n color: 'warning' as AXStyleColorType,\n order: 2,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.states.work-order-required',\n icon: 'fa-light fa-clipboard-list',\n color: 'accent1' as AXStyleColorType,\n order: 3,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.WorkOrderCreated,\n title: '@maintenance-management:failure-registers.states.work-order-created',\n icon: 'fa-light fa-file-lines',\n color: 'info' as AXStyleColorType,\n order: 4,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.InProgress,\n title: '@maintenance-management:failure-registers.states.in-progress',\n icon: 'fa-light fa-screwdriver-wrench',\n color: 'primary' as AXStyleColorType,\n order: 5,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Resolved,\n title: '@maintenance-management:failure-registers.states.resolved',\n icon: 'fa-light fa-circle-check',\n color: 'success' as AXStyleColorType,\n order: 6,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.FollowUpRequired,\n title: '@maintenance-management:failure-registers.states.follow-up-required',\n icon: 'fa-light fa-arrow-rotate-right',\n color: 'warning' as AXStyleColorType,\n order: 7,\n isInitial: false,\n isFinal: false,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Rejected,\n title: '@maintenance-management:failure-registers.states.rejected',\n icon: 'fa-light fa-ban',\n color: 'danger' as AXStyleColorType,\n order: 8,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Duplicate,\n title: '@maintenance-management:failure-registers.states.duplicate',\n icon: 'fa-light fa-clone',\n color: 'neutral' as AXStyleColorType,\n order: 9,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n {\n name: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.states.closed',\n icon: 'fa-light fa-folder-closed',\n color: 'neutral' as AXStyleColorType,\n order: 10,\n isInitial: false,\n isFinal: true,\n generateView: false,\n },\n ];\n\n readonly transitions: AXPStatusTransition[] = [\n {\n from: AXMFailureRegisterStatus.Reported,\n to: AXMFailureRegisterStatus.UnderReview,\n title: '@maintenance-management:failure-registers.status.transitions.submit-for-review',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.status.transitions.require-work-order',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.Rejected,\n title: '@maintenance-management:failure-registers.status.transitions.reject',\n },\n {\n from: AXMFailureRegisterStatus.UnderReview,\n to: AXMFailureRegisterStatus.Duplicate,\n title: '@maintenance-management:failure-registers.status.transitions.mark-duplicate',\n },\n {\n from: AXMFailureRegisterStatus.WorkOrderRequired,\n to: AXMFailureRegisterStatus.WorkOrderCreated,\n title: '@maintenance-management:failure-registers.status.transitions.create-work-order',\n },\n {\n from: AXMFailureRegisterStatus.WorkOrderCreated,\n to: AXMFailureRegisterStatus.InProgress,\n title: '@maintenance-management:failure-registers.status.transitions.start-work-order',\n },\n {\n from: AXMFailureRegisterStatus.InProgress,\n to: AXMFailureRegisterStatus.Resolved,\n title: '@maintenance-management:failure-registers.status.transitions.resolve',\n },\n {\n from: AXMFailureRegisterStatus.InProgress,\n to: AXMFailureRegisterStatus.FollowUpRequired,\n title: '@maintenance-management:failure-registers.status.transitions.require-follow-up',\n },\n {\n from: AXMFailureRegisterStatus.FollowUpRequired,\n to: AXMFailureRegisterStatus.WorkOrderRequired,\n title: '@maintenance-management:failure-registers.status.transitions.create-follow-up-work-order',\n },\n {\n from: AXMFailureRegisterStatus.Resolved,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n {\n from: AXMFailureRegisterStatus.Rejected,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n {\n from: AXMFailureRegisterStatus.Duplicate,\n to: AXMFailureRegisterStatus.Closed,\n title: '@maintenance-management:failure-registers.status.transitions.close',\n },\n ];\n\n readonly defaultStatus = AXMFailureRegisterStatus.Reported;\n}\n\n//#endregion\n"],"names":[],"mappings":";;;AAAA;AAOA;AAEA;AAEM,MAAO,qDAAsD,SAAQ,iBAAiB,CAAA;AAA5F,IAAA,WAAA,GAAA;;QACW,IAAA,CAAA,GAAG,GAAG,gDAAgD;AAEtD,QAAA,IAAA,CAAA,QAAQ,GAAG;AAClB,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,QAAQ;AACvC,gBAAA,KAAK,EAAE,2DAA2D;AAClE,gBAAA,IAAI,EAAE,8BAA8B;AACpC,gBAAA,KAAK,EAAE,WAA+B;AACtC,gBAAA,KAAK,EAAE,CAAC;AACR,gBAAA,SAAS,EAAE,IAAI;AACf,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,YAAY,EAAE,KAAK;AACpB,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,WAAW;AAC1C,gBAAA,KAAK,EAAE,+DAA+D;AACtE,gBAAA,IAAI,EAAE,8BAA8B;AACpC,gBAAA,KAAK,EAAE,SAA6B;AACpC,gBAAA,KAAK,EAAE,CAAC;AACR,gBAAA,SAAS,EAAE,KAAK;AAChB,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,YAAY,EAAE,KAAK;AACpB,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,CAAC,iBAAiB;AAChD,gBAAA,KAAK,EAAE,sEAAsE;AAC7E,gBAAA,IAAI,EAAE,4BAA4B;AAClC,gBAAA,KAAK,EAAE,SAA6B;AACpC,gBAAA,KAAK,EAAE,CAAC;AACR,gBAAA,SAAS,EAAE,KAAK;AAChB,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,YAAY,EAAE,KAAK;AACpB,aAAA;AACD,YAAA;gBACE,IAAI,EAAE,wBAAwB,C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AAa,GAAG,wBAAwB,CAAC,QAAQ;IAC5D;AAAC;AAED;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-fill-work-report-completion.command-Capowl1e.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-report/commands/fill-work-report-completion.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityFormBuilderService, AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString, merge } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { isWorkReportEditable } from '../work-report-assessment.util';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface FillWorkReportCompletionInput {\n workReportId: string;\n workOrderId?: string;\n /** When false, returns form data for workflow persistence (default). When true, saves immediately. */\n persistOnSubmit?: boolean;\n}\n\nexport interface FillWorkReportCompletionOutput {\n result?: Record<string, unknown>;\n}\n\nexport type FillWorkReportCompletionOutcome = 'Submitted' | 'Cancelled';\n\n//#endregion\n\n/**\n * Opens the work report completion form during workflow execution.\n * Persists only through workflow follow-up activities (update-work-report-on-completion).\n */\n@Injectable({ providedIn: 'root' })\nexport class FillWorkReportCompletionCommand\n implements AXPCommand<FillWorkReportCompletionInput, FillWorkReportCompletionOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityForm = inject(AXPEntityFormBuilderService);\n private readonly entityService = inject(AXPEntityService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Constants ----\n\n private readonly editableFields = [\n 'result',\n 'summary',\n 'actionTaken',\n 'recommendation',\n 'laborHours',\n 'downtimeMinutes',\n 'endedAt',\n 'needFollowUp',\n ] as const;\n\n private readonly systemFields = [\n 'workOrderId',\n 'reportedAt',\n 'performedById',\n 'startedAt',\n 'finalizedAt',\n ] as const;\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: FillWorkReportCompletionInput,\n ): AXPCommandExecuteResultPromise<FillWorkReportCompletionOutput> {\n const workReportId = this.resolveText(input?.workReportId);\n if (!workReportId) {\n return {\n success: false,\n message: { text: 'workReportId is required' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const workReport = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(workReportId)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n\n if (!workReport?.id) {\n return {\n success: false,\n message: { text: 'Work report not found' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const workOrderId = this.resolveText(input.workOrderId) || this.resolveText(workReport.workOrderId);\n const workOrder = workOrderId\n ? ((await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null)\n : null;\n\n if (workOrderId && this.resolveText(workReport.workOrderId) !== workOrderId) {\n return {\n success: false,\n message: { text: 'Work report does not belong to the work order' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const editable = isWorkReportEditable(workReport, workOrder);\n const persistOnSubmit = input.persistOnSubmit === true;\n const entitySource = `${RootConfig.module.name}.${RootConfig.entities.workReport.name}`;\n const title = await this.translation.translateAsync(\n '@maintenance-management:work-reports.commands.fill-completion.title',\n );\n\n let chain = this.entityForm\n .entity(entitySource)\n .update(workReportId)\n .title(title)\n .include(...this.systemFields, ...this.editableFields, 'assessments')\n .readonlyProperties(...this.systemFields, 'assessments');\n\n if (!editable) {\n chain = chain.readonlyProperties(...this.editableFields).mode('view');\n }\n\n chain.actions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n if (editable) {\n actions.submit('@general:actions.submit.title');\n }\n });\n\n const result = await chain\n .onAction<AXPRuntimeCommandResult<FillWorkReportCompletionOutput>>(async (dialogRef) => {\n const action = dialogRef.action();\n\n if (action === 'cancel') {\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n if (action !== 'submit') {\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const context = merge({}, dialogRef.context());\n\n if (persistOnSubmit) {\n dialogRef.setLoading(true);\n try {\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .update(workReportId, this.pickEditableFields(context) as never);\n } finally {\n dialogRef.setLoading(false);\n }\n\n return { success: true, kind: 'object',\n data: { result: context },\n metadata: { outcome: 'Submitted' },\n };\n }\n\n return { success: true, kind: 'object',\n data: { result: context },\n metadata: { outcome: 'Submitted' },\n };\n })\n .show();\n\n return this.normalizeDialogShowResult(result);\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private pickEditableFields(context: Record<string, unknown>): Record<string, unknown> {\n const picked: Record<string, unknown> = {};\n for (const field of this.editableFields) {\n if (field in context) {\n picked[field] = context[field];\n }\n }\n return picked;\n }\n\n private normalizeDialogShowResult(\n result: unknown,\n ): AXPRuntimeCommandResult<FillWorkReportCompletionOutput> {\n if (\n result &&\n typeof result === 'object' &&\n 'metadata' in result &&\n (result as AXPRuntimeCommandResult<FillWorkReportCompletionOutput>).metadata?.['outcome']\n ) {\n return result as AXPRuntimeCommandResult<FillWorkReportCompletionOutput>;\n }\n\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AA+BA;AAEA;;;AAGG;MAEU,+BAA+B,C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WAAW,EAAE;SACnC;IACH;AAEQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GA1LW,+BAA+B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA/B,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,+BAA+B,cADlB,MAAM,EAAA,CAAA,CAAA;;2FACnB,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAD3C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-fill-work-report-completion.command-Capowl1e.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-report/commands/fill-work-report-completion.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityFormBuilderService, AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString, merge } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { isWorkReportEditable } from '../work-report-assessment.util';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface FillWorkReportCompletionInput {\n workReportId: string;\n workOrderId?: string;\n /** When false, returns form data for workflow persistence (default). When true, saves immediately. */\n persistOnSubmit?: boolean;\n}\n\nexport interface FillWorkReportCompletionOutput {\n result?: Record<string, unknown>;\n}\n\nexport type FillWorkReportCompletionOutcome = 'Submitted' | 'Cancelled';\n\n//#endregion\n\n/**\n * Opens the work report completion form during workflow execution.\n * Persists only through workflow follow-up activities (update-work-report-on-completion).\n */\n@Injectable({ providedIn: 'root' })\nexport class FillWorkReportCompletionCommand\n implements AXPCommand<FillWorkReportCompletionInput, FillWorkReportCompletionOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityForm = inject(AXPEntityFormBuilderService);\n private readonly entityService = inject(AXPEntityService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Constants ----\n\n private readonly editableFields = [\n 'result',\n 'summary',\n 'actionTaken',\n 'recommendation',\n 'laborHours',\n 'downtimeMinutes',\n 'endedAt',\n 'needFollowUp',\n ] as const;\n\n private readonly systemFields = [\n 'workOrderId',\n 'reportedAt',\n 'performedById',\n 'startedAt',\n 'finalizedAt',\n ] as const;\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: FillWorkReportCompletionInput,\n ): AXPCommandExecuteResultPromise<FillWorkReportCompletionOutput> {\n const workReportId = this.resolveText(input?.workReportId);\n if (!workReportId) {\n return {\n success: false,\n message: { text: 'workReportId is required' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const workReport = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(workReportId)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n\n if (!workReport?.id) {\n return {\n success: false,\n message: { text: 'Work report not found' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const workOrderId = this.resolveText(input.workOrderId) || this.resolveText(workReport.workOrderId);\n const workOrder = workOrderId\n ? ((await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null)\n : null;\n\n if (workOrderId && this.resolveText(workReport.workOrderId) !== workOrderId) {\n return {\n success: false,\n message: { text: 'Work report does not belong to the work order' },\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const editable = isWorkReportEditable(workReport, workOrder);\n const persistOnSubmit = input.persistOnSubmit === true;\n const entitySource = `${RootConfig.module.name}.${RootConfig.entities.workReport.name}`;\n const title = await this.translation.translateAsync(\n '@maintenance-management:work-reports.commands.fill-completion.title',\n );\n\n let chain = this.entityForm\n .entity(entitySource)\n .update(workReportId)\n .title(title)\n .include(...this.systemFields, ...this.editableFields, 'assessments')\n .readonlyProperties(...this.systemFields, 'assessments');\n\n if (!editable) {\n chain = chain.readonlyProperties(...this.editableFields).mode('view');\n }\n\n chain.actions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n if (editable) {\n actions.submit('@general:actions.submit.title');\n }\n });\n\n const result = await chain\n .onAction<AXPRuntimeCommandResult<FillWorkReportCompletionOutput>>(async (dialogRef) => {\n const action = dialogRef.action();\n\n if (action === 'cancel') {\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n if (action !== 'submit') {\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n const context = merge({}, dialogRef.context());\n\n if (persistOnSubmit) {\n dialogRef.setLoading(true);\n try {\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .update(workReportId, this.pickEditableFields(context) as never);\n } finally {\n dialogRef.setLoading(false);\n }\n\n return { success: true, kind: 'object',\n data: { result: context },\n metadata: { outcome: 'Submitted' },\n };\n }\n\n return { success: true, kind: 'object',\n data: { result: context },\n metadata: { outcome: 'Submitted' },\n };\n })\n .show();\n\n return this.normalizeDialogShowResult(result);\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private pickEditableFields(context: Record<string, unknown>): Record<string, unknown> {\n const picked: Record<string, unknown> = {};\n for (const field of this.editableFields) {\n if (field in context) {\n picked[field] = context[field];\n }\n }\n return picked;\n }\n\n private normalizeDialogShowResult(\n result: unknown,\n ): AXPRuntimeCommandResult<FillWorkReportCompletionOutput> {\n if (\n result &&\n typeof result === 'object' &&\n 'metadata' in result &&\n (result as AXPRuntimeCommandResult<FillWorkReportCompletionOutput>).metadata?.['outcome']\n ) {\n return result as AXPRuntimeCommandResult<FillWorkReportCompletionOutput>;\n }\n\n return { success: true, kind: 'object',\n data: {},\n metadata: { outcome: 'Cancelled' },\n };\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AA+BA;AAEA;;;AAGG;MAEU,+BAA+B,CAAA;AAD5C,IAAA,WAAA,GAAA;;AAMmB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,2BAA2B,CAAC;AAChD,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC;;;AAM1C,QAAA,IAAA,CAAA,cAAc,GAAG;YAChC,QAAQ;YACR,SAAS;YACT,aAAa;YACb,gBAAgB;YAChB,YAAY;YACZ,iBAAiB;YACjB,SAAS;YACT,cAAc;SACN;AAEO,QAAA,IAAA,CAAA,YAAY,GAAG;YAC9B,aAAa;YACb,YAAY;YACZ,eAAe;YACf,WAAW;YACX,aAAa;SACL;AA+JX,IAAA;;;IAzJC,MAAM,OAAO,CACX,KAAoC,EAAA;QAEpC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC;QAC1D,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,0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AK,IAAI,IAAI,CAAC,cAAc,EAAE;AACvC,YAAA,IAAI,KAAK,IAAI,OAAO,EAAE;gBACpB,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;YAChC;QACF;AACA,QAAA,OAAO,MAAM;IACf;AAEQ,IAAA,yBAAyB,CAC/B,MAAe,EAAA;AAEf,QAAA,IACE,MAAM;YACN,OAAO,MAAM,KAAK,QAAQ;AAC1B,YAAA,UAAU,IAAI,MAAM;AACnB,YAAA,MAAkE,CAAC,QAAQ,GAAG,SAAS,CAAC,EACzF;AACA,YAAA,OAAO,MAAiE;QAC1E;AAEA,QAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ;AACpC,YAAA,IAAI,EAAE,EAAE;AACR,YAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;SACnC;IACH;AAEQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GA1LW,+BAA+B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA/B,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,+BAA+B,cADlB,MAAM,EAAA,CAAA,CAAA;;2FACnB,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAD3C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-local-entities.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/provide-local-entities.ts","../../../../libs/modules/maintenance-management/client/src/lib/acorex-platform-module-maintenance-management-client-local-entities.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { provideLocalEntityCatalog } from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ----- Provide local entities -----\n\n/**\n * Registers maintenance-management layouts on the client from packaged factories.\n * Each `import()` targets a secondary entry so unused entities stay out of the\n * bundle. Do not add this to the demo app; demo continues to load layouts via\n * `Domain:GetEntityLayout`.\n */\nexport function provideMaintenanceManagementLocalEntities() {\n return provideLocalEntityCatalog({\n moduleName: RootConfig.module.name,\n loaders: {\n [RootConfig.entities.activityType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type').then((m) => m.factoryActivityType()),\n [RootConfig.entities.activityTypeAssetType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type-asset-type').then((m) => m.factoryActivityTypeAssetType()),\n [RootConfig.entities.activityTypeResource.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type-resource').then((m) => m.factoryActivityTypeResource()),\n [RootConfig.entities.failureCause.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-cause').then((m) => m.factoryFailureCause()),\n [RootConfig.entities.failureDetection.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-detection').then((m) => m.factoryFailureDetection()),\n [RootConfig.entities.failureEffect.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-effect').then((m) => m.factoryFailureEffect()),\n [RootConfig.entities.failureMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mechanism').then((m) => m.factoryFailureMechanism()),\n [RootConfig.entities.failureMode.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode').then((m) => m.factoryFailureMode()),\n [RootConfig.entities.failureModeAssetType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-asset-type').then((m) => m.factoryFailureModeAssetType()),\n [RootConfig.entities.failureModeMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-mechanism').then((m) => m.factoryFailureModeMechanism()),\n [RootConfig.entities.failureModeSolution.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-solution').then((m) => m.factoryFailureModeSolution()),\n [RootConfig.entities.failureRegister.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register').then((m) => m.factoryFailureRegister()),\n [RootConfig.entities.failureRegisterCause.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-cause').then((m) => m.factoryFailureRegisterCause()),\n [RootConfig.entities.failureRegisterEffect.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-effect').then((m) => m.factoryFailureRegisterEffect()),\n [RootConfig.entities.failureRegisterMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-mechanism').then((m) => m.factoryFailureRegisterMechanism()),\n [RootConfig.entities.failureSeverity.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-severity').then((m) => m.factoryFailureSeverity()),\n [RootConfig.entities.failureType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-type').then((m) => m.factoryFailureType()),\n [RootConfig.entities.maintenancePlan.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-plan').then((m) => m.maintenancePlanEntityFactory()),\n [RootConfig.entities.maintenanceTemplate.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template').then((m) => m.factoryMaintenanceTemplate()),\n [RootConfig.entities.maintenanceTemplateActivityType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-activity-type').then((m) => m.factoryMaintenanceTemplateActivityType()),\n [RootConfig.entities.maintenanceTemplateFailureMode.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-failure-mode').then((m) => m.maintenanceTemplateFailureModeEntityFactory()),\n [RootConfig.entities.maintenanceTemplateResource.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-resource').then((m) => m.maintenanceTemplateResourceEntityFactory()),\n [RootConfig.entities.maintenanceType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-type').then((m) => m.factoryMaintenanceType()),\n [RootConfig.entities.workOrder.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-order').then((m) => m.workOrderEntityFactory()),\n [RootConfig.entities.workPackage.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-package').then((m) => m.workPackageEntityFactory()),\n [RootConfig.entities.workReport.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-report').then((m) => m.workReportEntityFactory()),\n },\n });\n}\n\nexport { maintenanceManagementLocalEntityCatalog } from '@acorex-platform/module-maintenance-management-client/contracts/entity-catalog';\n\n//#endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './provide-local-entities';\n"],"names":[],"mappings":";;;;AAAA;AAKA;AAEA;AAEA;;;;;AAKG;SACa,yCAAyC,GAAA;AACvD,IAAA,OAAO,yBAAyB,CAAC;AAC/B,QAAA,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI;AAClC,QAAA,OAAO,EAAE;AACP,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,GAAG,MACvC,OAAO,wFAAwF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvI,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,GAAG,MAChD,OAAO,mGAAmG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,4BAA4B,EAAE,CAAC;AAC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,GAAG,MACtC,OAAO,uFAAuF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,wBAAwB,EAAE,CAAC;AAC3I,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,GAAG,MACrC,OAAO,sFAAsF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC1I,SAAA;AACF,KAAA,CAAC;AACJ;AAIA;;AC7EA;;AAEG;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-local-entities.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/provide-local-entities.ts","../../../../libs/modules/maintenance-management/client/src/lib/acorex-platform-module-maintenance-management-client-local-entities.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { provideLocalEntityCatalog } from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ----- Provide local entities -----\n\n/**\n * Registers maintenance-management layouts on the client from packaged factories.\n * Each `import()` targets a secondary entry so unused entities stay out of the\n * bundle. Do not add this to the demo app; demo continues to load layouts via\n * `Domain:GetEntityLayout`.\n */\nexport function provideMaintenanceManagementLocalEntities() {\n return provideLocalEntityCatalog({\n moduleName: RootConfig.module.name,\n loaders: {\n [RootConfig.entities.activityType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type').then((m) => m.factoryActivityType()),\n [RootConfig.entities.activityTypeAssetType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type-asset-type').then((m) => m.factoryActivityTypeAssetType()),\n [RootConfig.entities.activityTypeResource.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/activity-type-resource').then((m) => m.factoryActivityTypeResource()),\n [RootConfig.entities.failureCause.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-cause').then((m) => m.factoryFailureCause()),\n [RootConfig.entities.failureDetection.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-detection').then((m) => m.factoryFailureDetection()),\n [RootConfig.entities.failureEffect.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-effect').then((m) => m.factoryFailureEffect()),\n [RootConfig.entities.failureMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mechanism').then((m) => m.factoryFailureMechanism()),\n [RootConfig.entities.failureMode.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode').then((m) => m.factoryFailureMode()),\n [RootConfig.entities.failureModeAssetType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-asset-type').then((m) => m.factoryFailureModeAssetType()),\n [RootConfig.entities.failureModeMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-mechanism').then((m) => m.factoryFailureModeMechanism()),\n [RootConfig.entities.failureModeSolution.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-mode-solution').then((m) => m.factoryFailureModeSolution()),\n [RootConfig.entities.failureRegister.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register').then((m) => m.factoryFailureRegister()),\n [RootConfig.entities.failureRegisterCause.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-cause').then((m) => m.factoryFailureRegisterCause()),\n [RootConfig.entities.failureRegisterEffect.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-effect').then((m) => m.factoryFailureRegisterEffect()),\n [RootConfig.entities.failureRegisterMechanism.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-register-mechanism').then((m) => m.factoryFailureRegisterMechanism()),\n [RootConfig.entities.failureSeverity.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-severity').then((m) => m.factoryFailureSeverity()),\n [RootConfig.entities.failureType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/failure-type').then((m) => m.factoryFailureType()),\n [RootConfig.entities.maintenancePlan.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-plan').then((m) => m.maintenancePlanEntityFactory()),\n [RootConfig.entities.maintenanceTemplate.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template').then((m) => m.factoryMaintenanceTemplate()),\n [RootConfig.entities.maintenanceTemplateActivityType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-activity-type').then((m) => m.factoryMaintenanceTemplateActivityType()),\n [RootConfig.entities.maintenanceTemplateFailureMode.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-failure-mode').then((m) => m.maintenanceTemplateFailureModeEntityFactory()),\n [RootConfig.entities.maintenanceTemplateResource.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-template-resource').then((m) => m.maintenanceTemplateResourceEntityFactory()),\n [RootConfig.entities.maintenanceType.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/maintenance-type').then((m) => m.factoryMaintenanceType()),\n [RootConfig.entities.workOrder.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-order').then((m) => m.workOrderEntityFactory()),\n [RootConfig.entities.workPackage.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-package').then((m) => m.workPackageEntityFactory()),\n [RootConfig.entities.workReport.name]: () =>\n import('@acorex-platform/module-maintenance-management-client/contracts/entities/work-report').then((m) => m.workReportEntityFactory()),\n },\n });\n}\n\nexport { maintenanceManagementLocalEntityCatalog } from '@acorex-platform/module-maintenance-management-client/contracts/entity-catalog';\n\n//#endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './provide-local-entities';\n"],"names":[],"mappings":";;;;AAAA;AAKA;AAEA;AAEA;;;;;AAKG;SACa,yCAAyC,GAAA;AACvD,IAAA,OA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KAAK,CAAC,CAAC,wCAAwC,EAAE,CAAC;AAC5K,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,GAAG,MAC1C,OAAO,2FAA2F,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,sBAAsB,EAAE,CAAC;AAC7I,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,MACpC,OAAO,qFAAqF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,sBAAsB,EAAE,CAAC;AACvI,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,MACtC,OAAO,uFAAuF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,wBAAwB,EAAE,CAAC;AAC3I,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,GAAG,MACrC,OAAO,sFAAsF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC1I,SAAA;AACF,KAAA,CAAC;AACJ;AAIA;;AC7EA;;AAEG;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-open-work-report-from-work-order.command-B0O4fWPt.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-report/commands/open-work-report-from-work-order.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXPCommandService } from '@acorex-platform/framework-client/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { isWorkReportEditable } from '../work-report-assessment.util';\nimport { FillWorkReportCompletionCommand } from './fill-work-report-completion.command';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface OpenWorkReportFromWorkOrderInput {\n workOrderId: string;\n}\n\n//#endregion\n\n/**\n * Opens an existing work report for a work order from grid/detail.\n * Does not create work reports; shows a friendly message when none exists.\n */\n@Injectable({ providedIn: 'root' })\nexport class OpenWorkReportFromWorkOrderCommand implements AXPCommand<OpenWorkReportFromWorkOrderInput, void> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly commandService = inject(AXPCommandService);\n private readonly fillCompletion = inject(FillWorkReportCompletionCommand);\n private readonly toastService = inject(AXToastService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: OpenWorkReportFromWorkOrderInput): AXPCommandExecuteResultPromise<void> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return { success: false, message: { text: 'workOrderId is required' } };\n }\n\n const workReport = await this.findWorkReportByWorkOrderId(workOrderId);\n if (!workReport?.id) {\n const content = await this.translation.translateAsync(\n '@maintenance-management:work-reports.messages.not-created-yet',\n );\n this.toastService.show({\n color: 'warning',\n title: await this.translation.translateAsync('@general:messages.generic.warning.title'),\n content,\n closeButton: true,\n });\n return { success: true, kind: 'object', data: undefined };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (isWorkReportEditable(workReport, workOrder)) {\n await this.fillCompletion.execute({\n workReportId: workReport.id,\n workOrderId,\n persistOnSubmit: true,\n });\n return { success: true, kind: 'object', data: undefined };\n }\n\n await this.commandService.execute('Entity:View', {\n entity: RootConfig.entities.workReport.source,\n entityInfo: {\n name: RootConfig.entities.workReport.name,\n module: RootConfig.module.name,\n title: RootConfig.entities.workReport.title,\n parentKey: 'workOrderId',\n source: RootConfig.entities.workReport.source,\n },\n data: workReport.id,\n options: {\n excludeProperties: ['workOrderId'],\n },\n \n });\n\n return { success: true, kind: 'object', data: undefined };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async findWorkReportByWorkOrderId(\n workOrderId: string,\n ): Promise<AXMMaintenanceManagementWorkReportEntityModel | null> {\n const page = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'workOrderId', operator: { type: 'equal' }, value: workOrderId }],\n },\n } as never);\n\n const report = defaultTo(get(page, 'items[0]'), null) as AXMMaintenanceManagementWorkReportEntityModel | null;\n return report?.id ? report : null;\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AAyBA;AAEA;;;AAGG;MAEU,kCAAkC,CAAA;AAD/C,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,+BAA+B,CAAC;AACxD,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0F5D,IAAA;;;IApFC,MAAM,OAAO,CAAC,KAAuC,EAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,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,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,IAAI,CAAyD;QAC7G,OAAO,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,IAAI;IACnC;AAEQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GA9FW,kCAAkC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAlC,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,kCAAkC,cADrB,MAAM,EAAA,CAAA,CAAA;;2FACnB,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAD9C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-open-work-report-from-work-order.command-B0O4fWPt.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-report/commands/open-work-report-from-work-order.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXPCommandService } from '@acorex-platform/framework-client/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { isWorkReportEditable } from '../work-report-assessment.util';\nimport { FillWorkReportCompletionCommand } from './fill-work-report-completion.command';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface OpenWorkReportFromWorkOrderInput {\n workOrderId: string;\n}\n\n//#endregion\n\n/**\n * Opens an existing work report for a work order from grid/detail.\n * Does not create work reports; shows a friendly message when none exists.\n */\n@Injectable({ providedIn: 'root' })\nexport class OpenWorkReportFromWorkOrderCommand implements AXPCommand<OpenWorkReportFromWorkOrderInput, void> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly commandService = inject(AXPCommandService);\n private readonly fillCompletion = inject(FillWorkReportCompletionCommand);\n private readonly toastService = inject(AXToastService);\n private readonly translation = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: OpenWorkReportFromWorkOrderInput): AXPCommandExecuteResultPromise<void> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return { success: false, message: { text: 'workOrderId is required' } };\n }\n\n const workReport = await this.findWorkReportByWorkOrderId(workOrderId);\n if (!workReport?.id) {\n const content = await this.translation.translateAsync(\n '@maintenance-management:work-reports.messages.not-created-yet',\n );\n this.toastService.show({\n color: 'warning',\n title: await this.translation.translateAsync('@general:messages.generic.warning.title'),\n content,\n closeButton: true,\n });\n return { success: true, kind: 'object', data: undefined };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (isWorkReportEditable(workReport, workOrder)) {\n await this.fillCompletion.execute({\n workReportId: workReport.id,\n workOrderId,\n persistOnSubmit: true,\n });\n return { success: true, kind: 'object', data: undefined };\n }\n\n await this.commandService.execute('Entity:View', {\n entity: RootConfig.entities.workReport.source,\n entityInfo: {\n name: RootConfig.entities.workReport.name,\n module: RootConfig.module.name,\n title: RootConfig.entities.workReport.title,\n parentKey: 'workOrderId',\n source: RootConfig.entities.workReport.source,\n },\n data: workReport.id,\n options: {\n excludeProperties: ['workOrderId'],\n },\n \n });\n\n return { success: true, kind: 'object', data: undefined };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async findWorkReportByWorkOrderId(\n workOrderId: string,\n ): Promise<AXMMaintenanceManagementWorkReportEntityModel | null> {\n const page = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'workOrderId', operator: { type: 'equal' }, value: workOrderId }],\n },\n } as never);\n\n const report = defaultTo(get(page, 'items[0]'), null) as AXMMaintenanceManagementWorkReportEntityModel | null;\n return report?.id ? report : null;\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AAyBA;AAEA;;;AAGG;MAEU,kCAAkC,CAAA;AAD/C,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,+BAA+B,CAAC;AACxD,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0F5D,IAAA;;;IApFC,MAAM,OAAO,CAAC,KAAuC,EAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE;AAChB,YAAA,OAAO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AAO,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,IAAI;IACnC;AAEQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GA9FW,kCAAkC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAlC,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,kCAAkC,cADrB,MAAM,EAAA,CAAA,CAAA;;2FACnB,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAD9C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -4,7 +4,7 @@ import * as i0 from '@angular/core';
4
4
  import { inject, Injectable } from '@angular/core';
5
5
  import { defaultTo, get, isString } from 'lodash';
6
6
  import { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';
7
- import { A as AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE } from './acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BiQlJxPX.mjs';
7
+ import { A as AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE } from './acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BI7RNP_h.mjs';
8
8
  import { i as isWorkReportFinalized, s as sortWorkReportAssessments, u as upsertWorkReportAssessment } from './acorex-platform-module-maintenance-management-client-work-report-assessment.util-Da1HVAit.mjs';
9
9
 
10
10
  //#region ---- Imports ----
@@ -149,4 +149,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
149
149
  }] });
150
150
 
151
151
  export { RecordWorkReportAssessmentActivity };
152
- //# sourceMappingURL=acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CxRfaf0G.mjs.map
152
+ //# sourceMappingURL=acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CcH5qKzv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CxRfaf0G.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/record-work-report-assessment.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPDebugService } from '@acorex-platform/framework-client/core';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE } from '../work-order-workflow.debug';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport {\n isWorkReportFinalized,\n sortWorkReportAssessments,\n upsertWorkReportAssessment,\n} from '../../../work-report/work-report-assessment.util';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface RecordWorkReportAssessmentInput {\n workOrderId: string;\n workReportId?: string | null;\n performedById?: string | null;\n assessmentCaseId: string;\n completedById?: string | null;\n}\n\nexport interface RecordWorkReportAssessmentOutput {\n workReportId: string;\n workOrderId: string;\n}\n\n//#endregion\n\n/**\n * Persists a lightweight checklist assessment reference on WorkReport after a checklist is submitted.\n * Questionnaire answers remain in AssessmentCase / AssessmentSession storage.\n */\n@Injectable({ providedIn: 'root' })\nexport class RecordWorkReportAssessmentActivity\n implements AXPCommand<RecordWorkReportAssessmentInput, RecordWorkReportAssessmentOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly debug = inject(AXPDebugService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: RecordWorkReportAssessmentInput,\n ): AXPCommandExecuteResultPromise<RecordWorkReportAssessmentOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n const assessmentCaseId = this.resolveText(input?.assessmentCaseId);\n\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n if (!assessmentCaseId) {\n return { success: true, kind: 'object',\n data: { workReportId: this.resolveText(input.workReportId), workOrderId },\n metadata: { outcome: 'Done' },\n };\n }\n\n const workReport = await this.resolveWorkReport(workOrderId, input);\n if (!workReport?.id) {\n return {\n success: false,\n message: { text: 'Work report could not be resolved for the work order' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n if (isWorkReportFinalized(workReport)) {\n return {\n success: false,\n message: { text: 'Work report is finalized and cannot be updated' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const assessmentCase = await this.loadAssessmentCase(assessmentCaseId);\n const completedById = this.resolveText(input.completedById);\n const assessments = sortWorkReportAssessments(\n upsertWorkReportAssessment(workReport.assessments, {\n assessmentCaseId,\n assessmentCaseTitle: assessmentCase?.title as never,\n completedAt: new Date().toISOString(),\n completedById: completedById || null,\n }),\n );\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .update(workReport.id, { assessments } as never);\n\n this.debug.trace(\n AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE,\n 'work-report-assessment',\n 'Recorded checklist reference on work report',\n { workOrderId, workReportId: workReport.id, assessmentCaseId, assessmentCount: assessments.length },\n );\n\n return { success: true, kind: 'object',\n data: { workReportId: workReport.id, workOrderId },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async resolveWorkReport(\n workOrderId: string,\n input: RecordWorkReportAssessmentInput,\n ): Promise<AXMMaintenanceManagementWorkReportEntityModel | null> {\n const workReportId = this.resolveText(input.workReportId);\n if (workReportId) {\n const byId = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(workReportId)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n\n if (byId?.id && this.resolveText(byId.workOrderId) === workOrderId) {\n return byId;\n }\n }\n\n const page = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'workOrderId', operator: { type: 'equal' }, value: workOrderId }],\n },\n } as never);\n\n const existing = defaultTo(get(page, 'items[0]'), null) as AXMMaintenanceManagementWorkReportEntityModel | null;\n if (existing?.id) {\n return existing;\n }\n\n const performedById = this.resolveText(input.performedById);\n if (!performedById) {\n return null;\n }\n\n const now = new Date().toISOString();\n const createdId = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .create({\n workOrderId,\n reportedAt: now,\n performedById,\n startedAt: now,\n finalizedAt: null,\n assessments: [],\n } as never);\n\n const id = this.resolveText(createdId);\n if (!id) {\n return null;\n }\n\n return (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(id)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n }\n\n private async loadAssessmentCase(assessmentCaseId: string): Promise<{ title?: unknown } | null> {\n try {\n return (await this.entityService\n .withEntity('AssessmentManagement', 'AssessmentCase')\n .data()\n .byKey(assessmentCaseId)) as { title?: unknown } | null;\n } catch {\n return null;\n }\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAmCA;AAEA;;;AAGG;MAEU,kCAAkC,CAAA;AAD/C,IAAA,WAAA,GAAA;;AAMmB,QAAA,IAAA,CAAA,a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BAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kCAAkC,cADrB,MAAM,EAAA,CAAA,CAAA;;2FACnB,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAD9C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-record-work-report-assessment.activity-CcH5qKzv.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/record-work-report-assessment.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPDebugService } from '@acorex-platform/framework-client/core';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport { AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE } from '../work-order-workflow.debug';\nimport type { AXMMaintenanceManagementWorkReportEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport {\n isWorkReportFinalized,\n sortWorkReportAssessments,\n upsertWorkReportAssessment,\n} from '../../../work-report/work-report-assessment.util';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface RecordWorkReportAssessmentInput {\n workOrderId: string;\n workReportId?: string | null;\n performedById?: string | null;\n assessmentCaseId: string;\n completedById?: string | null;\n}\n\nexport interface RecordWorkReportAssessmentOutput {\n workReportId: string;\n workOrderId: string;\n}\n\n//#endregion\n\n/**\n * Persists a lightweight checklist assessment reference on WorkReport after a checklist is submitted.\n * Questionnaire answers remain in AssessmentCase / AssessmentSession storage.\n */\n@Injectable({ providedIn: 'root' })\nexport class RecordWorkReportAssessmentActivity\n implements AXPCommand<RecordWorkReportAssessmentInput, RecordWorkReportAssessmentOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly debug = inject(AXPDebugService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: RecordWorkReportAssessmentInput,\n ): AXPCommandExecuteResultPromise<RecordWorkReportAssessmentOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n const assessmentCaseId = this.resolveText(input?.assessmentCaseId);\n\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n if (!assessmentCaseId) {\n return { success: true, kind: 'object',\n data: { workReportId: this.resolveText(input.workReportId), workOrderId },\n metadata: { outcome: 'Done' },\n };\n }\n\n const workReport = await this.resolveWorkReport(workOrderId, input);\n if (!workReport?.id) {\n return {\n success: false,\n message: { text: 'Work report could not be resolved for the work order' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n if (isWorkReportFinalized(workReport)) {\n return {\n success: false,\n message: { text: 'Work report is finalized and cannot be updated' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const assessmentCase = await this.loadAssessmentCase(assessmentCaseId);\n const completedById = this.resolveText(input.completedById);\n const assessments = sortWorkReportAssessments(\n upsertWorkReportAssessment(workReport.assessments, {\n assessmentCaseId,\n assessmentCaseTitle: assessmentCase?.title as never,\n completedAt: new Date().toISOString(),\n completedById: completedById || null,\n }),\n );\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .update(workReport.id, { assessments } as never);\n\n this.debug.trace(\n AXM_WORK_ORDER_WORKFLOW_DEBUG_NAMESPACE,\n 'work-report-assessment',\n 'Recorded checklist reference on work report',\n { workOrderId, workReportId: workReport.id, assessmentCaseId, assessmentCount: assessments.length },\n );\n\n return { success: true, kind: 'object',\n data: { workReportId: workReport.id, workOrderId },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async resolveWorkReport(\n workOrderId: string,\n input: RecordWorkReportAssessmentInput,\n ): Promise<AXMMaintenanceManagementWorkReportEntityModel | null> {\n const workReportId = this.resolveText(input.workReportId);\n if (workReportId) {\n const byId = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(workReportId)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n\n if (byId?.id && this.resolveText(byId.workOrderId) === workOrderId) {\n return byId;\n }\n }\n\n const page = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'workOrderId', operator: { type: 'equal' }, value: workOrderId }],\n },\n } as never);\n\n const existing = defaultTo(get(page, 'items[0]'), null) as AXMMaintenanceManagementWorkReportEntityModel | null;\n if (existing?.id) {\n return existing;\n }\n\n const performedById = this.resolveText(input.performedById);\n if (!performedById) {\n return null;\n }\n\n const now = new Date().toISOString();\n const createdId = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .create({\n workOrderId,\n reportedAt: now,\n performedById,\n startedAt: now,\n finalizedAt: null,\n assessments: [],\n } as never);\n\n const id = this.resolveText(createdId);\n if (!id) {\n return null;\n }\n\n return (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workReport.name)\n .data()\n .byKey(id)) as AXMMaintenanceManagementWorkReportEntityModel | null;\n }\n\n private async loadAssessmentCase(assessmentCaseId: string): Promise<{ title?: unknown } | null> {\n try {\n return (await this.entityService\n .withEntity('AssessmentManagement', 'AssessmentCase')\n .data()\n .byKey(assessmentCaseId)) as { title?: unknown } | null;\n } catch {\n return null;\n }\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAmCA;AAEA;;;AAGG;MAEU,kCAAkC,CAA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AAlC,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,kCAAkC,cADrB,MAAM,EAAA,CAAA,CAAA;;2FACnB,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAD9C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-resolve-person-user-id.activity-nwXAJHkd.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/resolve-person-user-id.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { isString } from 'lodash';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface ResolvePersonUserIdInput {\n personId?: string;\n}\n\nexport interface ResolvePersonUserIdOutput {\n userId: string | null;\n personId: string | null;\n}\n\n//#endregion\n\n/**\n * Resolves a PersonCore.Person id to the platform user id used by task-board assignment.\n */\n@Injectable({ providedIn: 'root' })\nexport class ResolvePersonUserIdActivity implements AXPCommand<ResolvePersonUserIdInput, ResolvePersonUserIdOutput> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: ResolvePersonUserIdInput): AXPCommandExecuteResultPromise<ResolvePersonUserIdOutput> {\n const personId = this.resolveText(input?.personId);\n if (!personId) {\n return {\n success: false,\n message: { details: { userId: null, personId: null }, text: 'personId is required' },\n \n metadata: { outcome: 'Failed' },\n };\n }\n\n const person = (await this.entityService.withEntity('PersonCore', 'Person').data().byKey(personId)) as\n | { id?: string; userId?: string | null }\n | null;\n\n const userId = this.resolveText(person?.userId);\n if (!userId) {\n return {\n success: false,\n message: { details: { userId: null, personId }, text: 'Assigned person has no linked platform user.' },\n \n metadata: { outcome: 'Failed' },\n };\n }\n\n return { success: true, kind: 'object',\n data: { userId, personId },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;AAqBA;AAEA;;AAEG;MAEU,2BAA2B,CAAA;AADxC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiD1D,IAAA;;;IA3CC,MAAM,OAAO,CAAC,KAA+B,EAAA;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;AAEpF,gBAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;aAChC;QACH;QAEA,MAAM,MAAM,IAAI,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAE1F;QAER,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,8CAA8C,EAAE;AAEtG,gBAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;aAChC;QACH;AAEA,QAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ;AACpC,YAAA,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;AAC1B,YAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;SAC9B;IACH;;;AAMQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GAjDW,2BAA2B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA3B,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,2BAA2B,cADd,MAAM,EAAA,CAAA,CAAA;;2FACnB,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBADvC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-resolve-person-user-id.activity-nwXAJHkd.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/resolve-person-user-id.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { isString } from 'lodash';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface ResolvePersonUserIdInput {\n personId?: string;\n}\n\nexport interface ResolvePersonUserIdOutput {\n userId: string | null;\n personId: string | null;\n}\n\n//#endregion\n\n/**\n * Resolves a PersonCore.Person id to the platform user id used by task-board assignment.\n */\n@Injectable({ providedIn: 'root' })\nexport class ResolvePersonUserIdActivity implements AXPCommand<ResolvePersonUserIdInput, ResolvePersonUserIdOutput> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: ResolvePersonUserIdInput): AXPCommandExecuteResultPromise<ResolvePersonUserIdOutput> {\n const personId = this.resolveText(input?.personId);\n if (!personId) {\n return {\n success: false,\n message: { details: { userId: null, personId: null }, text: 'personId is required' },\n \n metadata: { outcome: 'Failed' },\n };\n }\n\n const person = (await this.entityService.withEntity('PersonCore', 'Person').data().byKey(personId)) as\n | { id?: string; userId?: string | null }\n | null;\n\n const userId = this.resolveText(person?.userId);\n if (!userId) {\n return {\n success: false,\n message: { details: { userId: null, personId }, text: 'Assigned person has no linked platform user.' },\n \n metadata: { outcome: 'Failed' },\n };\n }\n\n return { success: true, kind: 'object',\n data: { userId, personId },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;AAqBA;AAEA;;AAEG;MAEU,2BAA2B,CAAA;AADxC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiD1D,IAAA;;;IA3CC,MAAM,OAAO,CAAC,KAA+B,EAAA;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE;YAC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AA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,2BAA2B,cADd,MAAM,EAAA,CAAA,CAAA;;2FACnB,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBADvC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-resolve-work-order.activity-q5WM7Sv5.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/resolve-work-order.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface ResolveWorkOrderInput {\n workOrderId?: string;\n assignedToId?: string;\n}\n\nexport interface ResolveWorkOrderOutput {\n workOrderId: string;\n workOrderNo: string;\n assetId: string;\n assetDisplayName: string;\n assignedToId: string;\n assignedToDisplayName: string;\n maintenanceTypeId: string;\n maintenanceTypeName: string;\n maintenancePlanId: string | null;\n failureRegisterId: string | null;\n sourceType: string | null;\n dueDate: string | null;\n statusId: string | null;\n}\n\n//#endregion\n\n/**\n * Loads the existing work order and validates that an assignee is present before execution starts.\n */\n@Injectable({ providedIn: 'root' })\nexport class ResolveWorkOrderActivity implements AXPCommand<ResolveWorkOrderInput, ResolveWorkOrderOutput> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: ResolveWorkOrderInput): AXPCommandExecuteResultPromise<ResolveWorkOrderOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (!workOrder?.id) {\n return {\n success: false,\n message: { text: 'Work order not found' },\n metadata: { outcome: 'NotFound' },\n };\n }\n\n const assignedToId = this.resolveText(input?.assignedToId) || this.resolveText(workOrder.assignedToId);\n if (!assignedToId) {\n return {\n success: false,\n message: { text: 'Assigned user is required before starting work order execution.' },\n metadata: { outcome: 'Blocked' },\n };\n }\n\n return { success: true, kind: 'object',\n data: {\n workOrderId: workOrder.id,\n workOrderNo: workOrder.workOrderNo,\n assetId: this.resolveText(workOrder.assetId),\n assetDisplayName: this.resolveDisplayName(workOrder.asset?.title, workOrder.assetId),\n assignedToId,\n assignedToDisplayName: this.resolveDisplayName(workOrder.assignedTo?.fullName, assignedToId),\n maintenanceTypeId: this.resolveText(workOrder.maintenanceTypeId),\n maintenanceTypeName: this.resolveDisplayName(workOrder.maintenanceType?.title, workOrder.maintenanceTypeId),\n maintenancePlanId: workOrder.maintenancePlanId?.trim() || null,\n failureRegisterId: workOrder.failureRegisterId?.trim() || null,\n sourceType: workOrder.sourceType?.trim() || null,\n dueDate: workOrder.scheduledEnd ?? workOrder.scheduledStart ?? null,\n statusId: workOrder.statusId ?? null,\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n private resolveDisplayName(value: unknown, fallback: string): string {\n if (isString(value) && value.trim()) {\n return value.trim();\n }\n if (value && typeof value === 'object') {\n const record = value as Record<string, string>;\n return record['en-US'] ?? record['fa-IR'] ?? Object.values(record)[0] ?? fallback;\n }\n return fallback;\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;AAoCA;AAEA;;AAEG;MAEU,wBAAwB,CAAA;AADrC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiF1D,IAAA;;;IA3EC,MAAM,OAAO,CAAC,KAA4B,EAAA;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;AAC5C,gBAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;aAChC;QACH;AAEA,QAAA,MAAM,SAAS,IAAI,MAAM,IAAI,CAAC;AAC3B,aAAA,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI;AACrE,aAAA,IAAI;AACJ,aAAA,KAAK,CAAC,WAAW,CAAC,CAAwD;AAE7E,QAAA,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE;YAClB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;AACzC,gBAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;aAClC;QACH;AAEA,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;QACtG,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE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,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;IAEQ,kBAAkB,CAAC,KAAc,EAAE,QAAgB,EAAA;QACzD,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;AACnC,YAAA,OAAO,KAAK,CAAC,IAAI,EAAE;QACrB;AACA,QAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACtC,MAAM,MAAM,GAAG,KAA+B;YAC9C,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ;QACnF;AACA,QAAA,OAAO,QAAQ;IACjB;8GAjFW,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAxB,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,wBAAwB,cADX,MAAM,EAAA,CAAA,CAAA;;2FACnB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-resolve-work-order.activity-q5WM7Sv5.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/resolve-work-order.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface ResolveWorkOrderInput {\n workOrderId?: string;\n assignedToId?: string;\n}\n\nexport interface ResolveWorkOrderOutput {\n workOrderId: string;\n workOrderNo: string;\n assetId: string;\n assetDisplayName: string;\n assignedToId: string;\n assignedToDisplayName: string;\n maintenanceTypeId: string;\n maintenanceTypeName: string;\n maintenancePlanId: string | null;\n failureRegisterId: string | null;\n sourceType: string | null;\n dueDate: string | null;\n statusId: string | null;\n}\n\n//#endregion\n\n/**\n * Loads the existing work order and validates that an assignee is present before execution starts.\n */\n@Injectable({ providedIn: 'root' })\nexport class ResolveWorkOrderActivity implements AXPCommand<ResolveWorkOrderInput, ResolveWorkOrderOutput> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: ResolveWorkOrderInput): AXPCommandExecuteResultPromise<ResolveWorkOrderOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (!workOrder?.id) {\n return {\n success: false,\n message: { text: 'Work order not found' },\n metadata: { outcome: 'NotFound' },\n };\n }\n\n const assignedToId = this.resolveText(input?.assignedToId) || this.resolveText(workOrder.assignedToId);\n if (!assignedToId) {\n return {\n success: false,\n message: { text: 'Assigned user is required before starting work order execution.' },\n metadata: { outcome: 'Blocked' },\n };\n }\n\n return { success: true, kind: 'object',\n data: {\n workOrderId: workOrder.id,\n workOrderNo: workOrder.workOrderNo,\n assetId: this.resolveText(workOrder.assetId),\n assetDisplayName: this.resolveDisplayName(workOrder.asset?.title, workOrder.assetId),\n assignedToId,\n assignedToDisplayName: this.resolveDisplayName(workOrder.assignedTo?.fullName, assignedToId),\n maintenanceTypeId: this.resolveText(workOrder.maintenanceTypeId),\n maintenanceTypeName: this.resolveDisplayName(workOrder.maintenanceType?.title, workOrder.maintenanceTypeId),\n maintenancePlanId: workOrder.maintenancePlanId?.trim() || null,\n failureRegisterId: workOrder.failureRegisterId?.trim() || null,\n sourceType: workOrder.sourceType?.trim() || null,\n dueDate: workOrder.scheduledEnd ?? workOrder.scheduledStart ?? null,\n statusId: workOrder.statusId ?? null,\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n private resolveDisplayName(value: unknown, fallback: string): string {\n if (isString(value) && value.trim()) {\n return value.trim();\n }\n if (value && typeof value === 'object') {\n const record = value as Record<string, string>;\n return record['en-US'] ?? record['fa-IR'] ?? Object.values(record)[0] ?? fallback;\n }\n return fallback;\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;AAoCA;AAEA;;AAEG;MAEU,wBAAwB,CAAA;AADrC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiF1D,IAAA;;;IA3EC,MAAM,OAAO,CAAC,KAA4B,EAAA;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;AAC5C,gBAAA,QAAQ,EAAE,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AAA,OAAO,QAAQ;IACjB;8GAjFW,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAxB,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,wBAAwB,cADX,MAAM,EAAA,CAAA,CAAA;;2FACnB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -8,7 +8,7 @@ import * as i0 from '@angular/core';
8
8
  import { inject, Injectable } from '@angular/core';
9
9
  import { defaultTo, get, isString } from 'lodash';
10
10
  import { AXMWorkOrderStatus, RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';
11
- import { q as queryWorkflowTemplatesForAsset, r as resolveDisplayLabel } from './acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BiQlJxPX.mjs';
11
+ import { q as queryWorkflowTemplatesForAsset, r as resolveDisplayLabel } from './acorex-platform-module-maintenance-management-client-acorex-platform-module-maintenance-management-client-BI7RNP_h.mjs';
12
12
 
13
13
  //#region ---- Imports ----
14
14
  const STARTABLE_STATUSES = new Set([
@@ -399,4 +399,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
399
399
  }] });
400
400
 
401
401
  export { StartWorkOrderFlowCommand };
402
- //# sourceMappingURL=acorex-platform-module-maintenance-management-client-start-work-order-flow.command-B06a962Y.mjs.map
402
+ //# sourceMappingURL=acorex-platform-module-maintenance-management-client-start-work-order-flow.command-CVlDdtxW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-start-work-order-flow.command-B06a962Y.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/commands/start-work-order-flow.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXDialogService } from '@acorex/components/dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport {\n AXPEntityService,\n buildAXPRecordWorkflowInfo,\n getRecordWorkflowInstanceId,\n} from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXPBroadcastEventService } from '@acorex-platform/framework-client/core';\nimport { AXP_WORKFLOW_ENGINE, type AXPWorkflowEngine } from '@acorex-platform/framework-client/workflow';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { AXMWorkOrderStatus, RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport {\n type EntityStorageBackend,\n queryWorkflowTemplatesForAsset,\n resolveDisplayLabel,\n type MaintenanceTemplateLike,\n} from '../../../middlewares/maintenance-generation.utils';\n\n//#endregion\n\n//#region ---- Types ----\n\ninterface StartWorkOrderFlowContext {\n /** When set, applies the maintenance template on the work order before starting the workflow. */\n maintenanceTemplateId?: string;\n data?: Record<string, unknown>;\n options?: { maintenanceTemplateId?: string };\n}\n\nconst STARTABLE_STATUSES = new Set<string>([\n AXMWorkOrderStatus.Planned,\n AXMWorkOrderStatus.Scheduled,\n AXMWorkOrderStatus.Assigned,\n]);\n\n//#endregion\n\n/**\n * Starts the maintenance template workflow for a work order (execution + approval).\n */\n@Injectable({ providedIn: 'root' })\nexport class StartWorkOrderFlowCommand implements AXPCommand<StartWorkOrderFlowContext, void> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly workflowEngine = inject(AXP_WORKFLOW_ENGINE) as AXPWorkflowEngine;\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n private readonly dialogService = inject(AXDialogService);\n private readonly eventService = inject(AXPBroadcastEventService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: StartWorkOrderFlowContext): AXPCommandExecuteResultPromise<void> {\n const row = defaultTo(get(input, 'data'), {}) as Record<string, unknown>;\n const workOrderId = this.resolveText(get(row, 'id'));\n if (!workOrderId) {\n return { success: false, message: { text: 'Work order id is required.' } };\n }\n\n if (getRecordWorkflowInstanceId(row)) {\n return { success: false };\n }\n\n let workOrder = await this.loadWorkOrder(workOrderId, row);\n if (!workOrder) {\n return { success: false, message: { text: 'Work order not found.' } };\n }\n\n const explicitTemplateId = this.resolveText(get(input, 'maintenanceTemplateId'));\n const selectedTemplateId = await this.resolveMaintenanceTemplateId(workOrder, explicitTemplateId || undefined);\n if (!selectedTemplateId) {\n return { success: false };\n }\n\n const flowPrerequisites = await this.validateFlowPrerequisites(workOrder, selectedTemplateId);\n if (!flowPrerequisites) {\n return { success: false };\n }\n\n const { workflowConfig, workflowName, assignedEmployeeId } = flowPrerequisites;\n\n if (selectedTemplateId !== workOrder.maintenanceTemplateId) {\n await this.applyMaintenanceTemplate(workOrderId, selectedTemplateId);\n workOrder = (await this.loadWorkOrder(workOrderId)) ?? workOrder;\n }\n\n const assetIdentifiers = await this.resolveAssetIdentifiers(this.resolveText(workOrder.assetId));\n const workflowInputs = this.buildWorkflowInputs(\n workOrder,\n workflowConfig,\n assignedEmployeeId,\n assetIdentifiers,\n );\n const correlationId = `${RootConfig.entities.workOrder.source}:${workOrderId}:${workflowName}`;\n\n try {\n // Start via engine only — do not use AXPWorkflowManager.start() here; it auto-runs inline\n // frontend steps (e.g. checklist fill). Human tasks must stay on the task board.\n const startResponse = await this.workflowEngine.start({\n workflowId: workflowName,\n input: {\n ...workflowInputs,\n refId: workOrderId,\n refType: RootConfig.entities.workOrder.source,\n correlationId,\n },\n });\n\n const instanceId = startResponse.instanceId;\n if (!instanceId) {\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: 'Unknown error',\n closeButton: true,\n timeOut: 5000,\n });\n return { success: false, message: { text: 'Unknown error' } };\n }\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n workflowInfo: buildAXPRecordWorkflowInfo({\n instanceId,\n definitionId: workflowName,\n correlationId,\n }),\n } as never);\n\n this.eventService.publish('task-board.refresh', { provider: workflowName });\n\n const taskBoardHint = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.workflow-started-use-task-board',\n );\n this.toastService.show({\n color: 'success',\n title: await this.translationService.translateAsync('@general:messages.generic.success.title'),\n content: taskBoardHint,\n closeButton: true,\n timeOut: 6000,\n });\n\n return { success: true, kind: 'object', data: undefined };\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Unknown error';\n console.error('[StartWorkOrderFlowCommand]', error);\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: message,\n closeButton: true,\n timeOut: 5000,\n });\n return { success: false, message: { text: message } };\n }\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async loadWorkOrder(\n workOrderId: string,\n row?: Record<string, unknown>,\n ): Promise<AXMMaintenanceManagementWorkOrderEntityModel | null> {\n if (get(row, 'id') === workOrderId) {\n return row as unknown as AXMMaintenanceManagementWorkOrderEntityModel;\n }\n\n const loaded = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId);\n return (loaded as AXMMaintenanceManagementWorkOrderEntityModel | null) ?? null;\n }\n\n private async applyMaintenanceTemplate(workOrderId: string, templateId: string): Promise<void> {\n const template = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(templateId)) as {\n id?: string;\n title?: unknown;\n maintenanceTypeId?: string;\n metadataIds?: string[];\n workflowConfig?: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null;\n needShutdown?: boolean;\n needPermission?: boolean;\n estimatedMinutes?: number;\n } | null;\n\n if (!template?.id) {\n throw new Error('Maintenance template not found.');\n }\n\n const estimatedHours =\n typeof template.estimatedMinutes === 'number' && template.estimatedMinutes > 0\n ? Math.round((template.estimatedMinutes / 60) * 100) / 100\n : undefined;\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n maintenanceTemplateId: template.id,\n maintenanceTypeId: template.maintenanceTypeId,\n maintenanceTemplate: {\n id: template.id,\n title: template.title,\n metadataIds: template.metadataIds,\n workflowConfig: template.workflowConfig,\n },\n needShutdown: template.needShutdown ?? false,\n needPermission: template.needPermission ?? false,\n ...(estimatedHours !== undefined ? { estimatedHours } : {}),\n } as never);\n }\n\n private async resolveWorkflowConfig(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n ): Promise<AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null> {\n let workflowConfig = workOrder.maintenanceTemplate?.workflowConfig ?? null;\n if (!workflowConfig?.workflowDefinitionId && workOrder.maintenanceTemplateId) {\n const template = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(workOrder.maintenanceTemplateId);\n workflowConfig = get(template, 'workflowConfig') ?? null;\n }\n return workflowConfig;\n }\n\n private isWorkflowEnabled(\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null,\n ): boolean {\n if (!workflowConfig?.workflowDefinitionId?.trim() || !workflowConfig.workflowName?.trim()) {\n return false;\n }\n return workflowConfig.enabled !== false;\n }\n\n /**\n * Validates work-order state before starting a workflow or persisting workflowInfo.\n */\n private async validateFlowPrerequisites(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n selectedTemplateId: string,\n ): Promise<{\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig;\n workflowName: string;\n assignedEmployeeId: string;\n } | null> {\n const statusId = workOrder.statusId ?? '';\n if (!STARTABLE_STATUSES.has(statusId)) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.flow-requires-startable-status',\n );\n await this.showWarning(content);\n return null;\n }\n\n const workflowConfig = await this.resolveWorkflowConfigForTemplate(selectedTemplateId);\n if (!this.isWorkflowEnabled(workflowConfig)) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-configured',\n );\n await this.showWarning(content);\n return null;\n }\n\n const workflowName = workflowConfig!.workflowName.trim();\n const assignedToId = this.resolveText(workOrder.assignedToId);\n if (!assignedToId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.assigned-user-required',\n );\n await this.showWarning(content);\n return null;\n }\n\n const assignedEmployeeId = await this.resolveEmployeeIdByPersonId(assignedToId);\n if (workflowName === 'work-order-approval' && !assignedEmployeeId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.assigned-employee-required',\n );\n await this.showWarning(content);\n return null;\n }\n\n return { workflowConfig: workflowConfig!, workflowName, assignedEmployeeId };\n }\n\n private async resolveWorkflowConfigForTemplate(\n templateId: string,\n ): Promise<AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null> {\n const template = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(templateId);\n return get(template, 'workflowConfig') ?? null;\n }\n\n private async resolveAssetIdentifiers(\n assetId: string,\n ): Promise<{ assetCode: string | null; assetSerialNumber: string | null }> {\n if (!assetId) {\n return { assetCode: null, assetSerialNumber: null };\n }\n\n const asset = (await this.entityService\n .withEntity('AssetManagement', 'Asset')\n .data()\n .byKey(assetId)) as { code?: string; serialNumber?: string } | null;\n\n const assetCode = this.resolveText(asset?.code);\n const assetSerialNumber = this.resolveText(asset?.serialNumber);\n\n return {\n assetCode: assetCode || null,\n assetSerialNumber: assetSerialNumber || null,\n };\n }\n\n private buildWorkflowInputs(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig,\n assignedEmployeeId: string,\n assetIdentifiers: { assetCode: string | null; assetSerialNumber: string | null },\n ): Record<string, unknown> {\n const assetTitle = workOrder.asset?.title;\n const assetDisplayName =\n typeof assetTitle === 'string'\n ? assetTitle\n : resolveMultiLanguageString(assetTitle as never, this.translationService.getActiveLang());\n\n const templateDefaults = defaultTo(workflowConfig.defaultInput, {}) as Record<string, unknown>;\n const maintenanceTypeTitle = workOrder.maintenanceType?.title;\n const maintenanceTypeName =\n typeof maintenanceTypeTitle === 'string'\n ? maintenanceTypeTitle\n : resolveMultiLanguageString(maintenanceTypeTitle as never, this.translationService.getActiveLang());\n\n const assignedToTitle = workOrder.assignedTo?.fullName;\n\n return {\n ...templateDefaults,\n workOrderId: workOrder.id,\n workOrderNo: workOrder.workOrderNo,\n workOrderCode: workOrder.workOrderNo,\n assetId: workOrder.assetId,\n assetCode: assetIdentifiers.assetCode,\n assetSerialNumber: assetIdentifiers.assetSerialNumber,\n assetDisplayName,\n maintenanceTypeId: workOrder.maintenanceTypeId,\n maintenanceTypeName,\n maintenancePlanId: workOrder.maintenancePlanId ?? null,\n failureRegisterId: workOrder.failureRegisterId ?? null,\n assignedToId: workOrder.assignedToId ?? null,\n assignedToDisplayName:\n typeof assignedToTitle === 'string' && assignedToTitle.trim()\n ? assignedToTitle.trim()\n : workOrder.assignedToId ?? null,\n assignedEmployeeId: assignedEmployeeId || null,\n sourceType: workOrder.sourceType ?? null,\n dueDate: workOrder.scheduledEnd ?? workOrder.scheduledStart ?? null,\n };\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n private async showWarning(content: string): Promise<void> {\n this.toastService.show({\n color: 'warning',\n title: await this.translationService.translateAsync('@general:messages.generic.warning.title'),\n content,\n closeButton: true,\n timeOut: 10000,\n timeOutProgress: true,\n });\n }\n\n /**\n * Work-order approval flow expects `HumanCapitalManagement.Employee` id (`performedById` on WorkReport).\n * `WorkOrder.assignedToId` stores `PersonCore.Person` id.\n */\n private async resolveEmployeeIdByPersonId(personId: string): Promise<string> {\n if (!personId) {\n return '';\n }\n\n const page = await this.entityService\n .withEntity('HumanCapitalManagement', 'Employee')\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'personId', operator: { type: 'equal' }, value: personId }],\n },\n } as never);\n\n const employee = defaultTo(get(page, 'items[0]'), null) as { id?: string } | null;\n return this.resolveText(employee?.id);\n }\n\n private async resolveMaintenanceTemplateId(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n explicitTemplateId?: string,\n ): Promise<string> {\n if (explicitTemplateId) {\n return explicitTemplateId;\n }\n\n const currentTemplateId = this.resolveText(workOrder.maintenanceTemplateId);\n if (currentTemplateId) {\n const currentConfig = await this.resolveWorkflowConfig(workOrder);\n if (this.isWorkflowEnabled(currentConfig)) {\n return currentTemplateId;\n }\n }\n\n const assetId = this.resolveText(workOrder.assetId);\n if (!assetId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-templates-for-asset',\n );\n await this.showWarning(content);\n return '';\n }\n\n const backend = this.createStorageBackend();\n const templateEntityName = `${RootConfig.module.name}.${RootConfig.entities.maintenanceTemplate.name}`;\n const templates = await queryWorkflowTemplatesForAsset(backend, templateEntityName, assetId);\n if (templates.length === 0) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-templates-for-asset',\n );\n await this.showWarning(content);\n return '';\n }\n\n if (templates.length === 1) {\n return templates[0].id;\n }\n\n return (await this.pickMaintenanceTemplate(templates)) ?? '';\n }\n\n private async pickMaintenanceTemplate(templates: MaintenanceTemplateLike[]): Promise<string | null> {\n const locale = this.translationService.getActiveLang() as 'en-US' | 'fa-IR';\n const sorted = [...templates].sort((a, b) => {\n const ta = resolveDisplayLabel(a.title, a.code ?? a.id, locale);\n const tb = resolveDisplayLabel(b.title, b.code ?? b.id, locale);\n return ta.localeCompare(tb, locale, { sensitivity: 'base' });\n });\n\n const title = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.actions.start-flow.select-template.title',\n );\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.actions.start-flow.select-template.content',\n );\n const cancelLabel = await this.translationService.translateAsync('@general:actions.cancel.title');\n\n return new Promise((resolve) => {\n let settled = false;\n const finish = (value: string | null) => {\n if (settled) {\n return;\n }\n settled = true;\n resolve(value);\n };\n\n const dialog = this.dialogService.open({\n title,\n content,\n type: 'primary',\n orientation: 'vertical',\n closeButton: true,\n buttons: [\n {\n text: cancelLabel,\n color: 'default',\n autofocus: true,\n onClick: () => {\n dialog.close();\n finish(null);\n },\n },\n ...sorted.map((template) => ({\n text: resolveDisplayLabel(template.title, template.code ?? template.id, locale),\n color: 'primary' as const,\n onClick: () => {\n dialog.close();\n finish(template.id);\n },\n })),\n ],\n });\n });\n }\n\n private createStorageBackend(): EntityStorageBackend {\n return {\n getOne: async (entityName, id) => {\n const [module, entity] = entityName.split('.');\n return this.entityService.withEntity(module, entity).data().byKey(id);\n },\n insertOne: async () => null,\n query: async (entityName, request) => {\n const [module, entity] = entityName.split('.');\n return this.entityService.withEntity(module, entity).data().query(request as never);\n },\n };\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAsCA,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS;AACzC,IAAA,kBAAkB,CAAC,OAAO;AAC1B,IAAA,kBAAkB,CAAC,SAAS;AAC5B,IAAA,kBAAkB,CAAC,QAAQ;AAC5B,CAAA,CAAC;AAEF;AAEA;;AAEG;MAEU,yBAAyB,CAAA;AADtC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,a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MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-start-work-order-flow.command-CVlDdtxW.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/commands/start-work-order-flow.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXDialogService } from '@acorex/components/dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport {\n AXPEntityService,\n buildAXPRecordWorkflowInfo,\n getRecordWorkflowInstanceId,\n} from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { AXPBroadcastEventService } from '@acorex-platform/framework-client/core';\nimport { AXP_WORKFLOW_ENGINE, type AXPWorkflowEngine } from '@acorex-platform/framework-client/workflow';\nimport { inject, Injectable } from '@angular/core';\nimport { defaultTo, get, isString } from 'lodash';\n\nimport { AXMWorkOrderStatus, RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport {\n type EntityStorageBackend,\n queryWorkflowTemplatesForAsset,\n resolveDisplayLabel,\n type MaintenanceTemplateLike,\n} from '../../../middlewares/maintenance-generation.utils';\n\n//#endregion\n\n//#region ---- Types ----\n\ninterface StartWorkOrderFlowContext {\n /** When set, applies the maintenance template on the work order before starting the workflow. */\n maintenanceTemplateId?: string;\n data?: Record<string, unknown>;\n options?: { maintenanceTemplateId?: string };\n}\n\nconst STARTABLE_STATUSES = new Set<string>([\n AXMWorkOrderStatus.Planned,\n AXMWorkOrderStatus.Scheduled,\n AXMWorkOrderStatus.Assigned,\n]);\n\n//#endregion\n\n/**\n * Starts the maintenance template workflow for a work order (execution + approval).\n */\n@Injectable({ providedIn: 'root' })\nexport class StartWorkOrderFlowCommand implements AXPCommand<StartWorkOrderFlowContext, void> {\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n private readonly workflowEngine = inject(AXP_WORKFLOW_ENGINE) as AXPWorkflowEngine;\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n private readonly dialogService = inject(AXDialogService);\n private readonly eventService = inject(AXPBroadcastEventService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(input: StartWorkOrderFlowContext): AXPCommandExecuteResultPromise<void> {\n const row = defaultTo(get(input, 'data'), {}) as Record<string, unknown>;\n const workOrderId = this.resolveText(get(row, 'id'));\n if (!workOrderId) {\n return { success: false, message: { text: 'Work order id is required.' } };\n }\n\n if (getRecordWorkflowInstanceId(row)) {\n return { success: false };\n }\n\n let workOrder = await this.loadWorkOrder(workOrderId, row);\n if (!workOrder) {\n return { success: false, message: { text: 'Work order not found.' } };\n }\n\n const explicitTemplateId = this.resolveText(get(input, 'maintenanceTemplateId'));\n const selectedTemplateId = await this.resolveMaintenanceTemplateId(workOrder, explicitTemplateId || undefined);\n if (!selectedTemplateId) {\n return { success: false };\n }\n\n const flowPrerequisites = await this.validateFlowPrerequisites(workOrder, selectedTemplateId);\n if (!flowPrerequisites) {\n return { success: false };\n }\n\n const { workflowConfig, workflowName, assignedEmployeeId } = flowPrerequisites;\n\n if (selectedTemplateId !== workOrder.maintenanceTemplateId) {\n await this.applyMaintenanceTemplate(workOrderId, selectedTemplateId);\n workOrder = (await this.loadWorkOrder(workOrderId)) ?? workOrder;\n }\n\n const assetIdentifiers = await this.resolveAssetIdentifiers(this.resolveText(workOrder.assetId));\n const workflowInputs = this.buildWorkflowInputs(\n workOrder,\n workflowConfig,\n assignedEmployeeId,\n assetIdentifiers,\n );\n const correlationId = `${RootConfig.entities.workOrder.source}:${workOrderId}:${workflowName}`;\n\n try {\n // Start via engine only — do not use AXPWorkflowManager.start() here; it auto-runs inline\n // frontend steps (e.g. checklist fill). Human tasks must stay on the task board.\n const startResponse = await this.workflowEngine.start({\n workflowId: workflowName,\n input: {\n ...workflowInputs,\n refId: workOrderId,\n refType: RootConfig.entities.workOrder.source,\n correlationId,\n },\n });\n\n const instanceId = startResponse.instanceId;\n if (!instanceId) {\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: 'Unknown error',\n closeButton: true,\n timeOut: 5000,\n });\n return { success: false, message: { text: 'Unknown error' } };\n }\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n workflowInfo: buildAXPRecordWorkflowInfo({\n instanceId,\n definitionId: workflowName,\n correlationId,\n }),\n } as never);\n\n this.eventService.publish('task-board.refresh', { provider: workflowName });\n\n const taskBoardHint = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.workflow-started-use-task-board',\n );\n this.toastService.show({\n color: 'success',\n title: await this.translationService.translateAsync('@general:messages.generic.success.title'),\n content: taskBoardHint,\n closeButton: true,\n timeOut: 6000,\n });\n\n return { success: true, kind: 'object', data: undefined };\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Unknown error';\n console.error('[StartWorkOrderFlowCommand]', error);\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: message,\n closeButton: true,\n timeOut: 5000,\n });\n return { success: false, message: { text: message } };\n }\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private async loadWorkOrder(\n workOrderId: string,\n row?: Record<string, unknown>,\n ): Promise<AXMMaintenanceManagementWorkOrderEntityModel | null> {\n if (get(row, 'id') === workOrderId) {\n return row as unknown as AXMMaintenanceManagementWorkOrderEntityModel;\n }\n\n const loaded = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId);\n return (loaded as AXMMaintenanceManagementWorkOrderEntityModel | null) ?? null;\n }\n\n private async applyMaintenanceTemplate(workOrderId: string, templateId: string): Promise<void> {\n const template = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(templateId)) as {\n id?: string;\n title?: unknown;\n maintenanceTypeId?: string;\n metadataIds?: string[];\n workflowConfig?: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null;\n needShutdown?: boolean;\n needPermission?: boolean;\n estimatedMinutes?: number;\n } | null;\n\n if (!template?.id) {\n throw new Error('Maintenance template not found.');\n }\n\n const estimatedHours =\n typeof template.estimatedMinutes === 'number' && template.estimatedMinutes > 0\n ? Math.round((template.estimatedMinutes / 60) * 100) / 100\n : undefined;\n\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n maintenanceTemplateId: template.id,\n maintenanceTypeId: template.maintenanceTypeId,\n maintenanceTemplate: {\n id: template.id,\n title: template.title,\n metadataIds: template.metadataIds,\n workflowConfig: template.workflowConfig,\n },\n needShutdown: template.needShutdown ?? false,\n needPermission: template.needPermission ?? false,\n ...(estimatedHours !== undefined ? { estimatedHours } : {}),\n } as never);\n }\n\n private async resolveWorkflowConfig(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n ): Promise<AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null> {\n let workflowConfig = workOrder.maintenanceTemplate?.workflowConfig ?? null;\n if (!workflowConfig?.workflowDefinitionId && workOrder.maintenanceTemplateId) {\n const template = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(workOrder.maintenanceTemplateId);\n workflowConfig = get(template, 'workflowConfig') ?? null;\n }\n return workflowConfig;\n }\n\n private isWorkflowEnabled(\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null,\n ): boolean {\n if (!workflowConfig?.workflowDefinitionId?.trim() || !workflowConfig.workflowName?.trim()) {\n return false;\n }\n return workflowConfig.enabled !== false;\n }\n\n /**\n * Validates work-order state before starting a workflow or persisting workflowInfo.\n */\n private async validateFlowPrerequisites(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n selectedTemplateId: string,\n ): Promise<{\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig;\n workflowName: string;\n assignedEmployeeId: string;\n } | null> {\n const statusId = workOrder.statusId ?? '';\n if (!STARTABLE_STATUSES.has(statusId)) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.flow-requires-startable-status',\n );\n await this.showWarning(content);\n return null;\n }\n\n const workflowConfig = await this.resolveWorkflowConfigForTemplate(selectedTemplateId);\n if (!this.isWorkflowEnabled(workflowConfig)) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-configured',\n );\n await this.showWarning(content);\n return null;\n }\n\n const workflowName = workflowConfig!.workflowName.trim();\n const assignedToId = this.resolveText(workOrder.assignedToId);\n if (!assignedToId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.assigned-user-required',\n );\n await this.showWarning(content);\n return null;\n }\n\n const assignedEmployeeId = await this.resolveEmployeeIdByPersonId(assignedToId);\n if (workflowName === 'work-order-approval' && !assignedEmployeeId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.assigned-employee-required',\n );\n await this.showWarning(content);\n return null;\n }\n\n return { workflowConfig: workflowConfig!, workflowName, assignedEmployeeId };\n }\n\n private async resolveWorkflowConfigForTemplate(\n templateId: string,\n ): Promise<AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig | null> {\n const template = await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.maintenanceTemplate.name)\n .data()\n .byKey(templateId);\n return get(template, 'workflowConfig') ?? null;\n }\n\n private async resolveAssetIdentifiers(\n assetId: string,\n ): Promise<{ assetCode: string | null; assetSerialNumber: string | null }> {\n if (!assetId) {\n return { assetCode: null, assetSerialNumber: null };\n }\n\n const asset = (await this.entityService\n .withEntity('AssetManagement', 'Asset')\n .data()\n .byKey(assetId)) as { code?: string; serialNumber?: string } | null;\n\n const assetCode = this.resolveText(asset?.code);\n const assetSerialNumber = this.resolveText(asset?.serialNumber);\n\n return {\n assetCode: assetCode || null,\n assetSerialNumber: assetSerialNumber || null,\n };\n }\n\n private buildWorkflowInputs(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n workflowConfig: AXMMaintenanceManagementMaintenanceTemplateWorkflowConfig,\n assignedEmployeeId: string,\n assetIdentifiers: { assetCode: string | null; assetSerialNumber: string | null },\n ): Record<string, unknown> {\n const assetTitle = workOrder.asset?.title;\n const assetDisplayName =\n typeof assetTitle === 'string'\n ? assetTitle\n : resolveMultiLanguageString(assetTitle as never, this.translationService.getActiveLang());\n\n const templateDefaults = defaultTo(workflowConfig.defaultInput, {}) as Record<string, unknown>;\n const maintenanceTypeTitle = workOrder.maintenanceType?.title;\n const maintenanceTypeName =\n typeof maintenanceTypeTitle === 'string'\n ? maintenanceTypeTitle\n : resolveMultiLanguageString(maintenanceTypeTitle as never, this.translationService.getActiveLang());\n\n const assignedToTitle = workOrder.assignedTo?.fullName;\n\n return {\n ...templateDefaults,\n workOrderId: workOrder.id,\n workOrderNo: workOrder.workOrderNo,\n workOrderCode: workOrder.workOrderNo,\n assetId: workOrder.assetId,\n assetCode: assetIdentifiers.assetCode,\n assetSerialNumber: assetIdentifiers.assetSerialNumber,\n assetDisplayName,\n maintenanceTypeId: workOrder.maintenanceTypeId,\n maintenanceTypeName,\n maintenancePlanId: workOrder.maintenancePlanId ?? null,\n failureRegisterId: workOrder.failureRegisterId ?? null,\n assignedToId: workOrder.assignedToId ?? null,\n assignedToDisplayName:\n typeof assignedToTitle === 'string' && assignedToTitle.trim()\n ? assignedToTitle.trim()\n : workOrder.assignedToId ?? null,\n assignedEmployeeId: assignedEmployeeId || null,\n sourceType: workOrder.sourceType ?? null,\n dueDate: workOrder.scheduledEnd ?? workOrder.scheduledStart ?? null,\n };\n }\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n private async showWarning(content: string): Promise<void> {\n this.toastService.show({\n color: 'warning',\n title: await this.translationService.translateAsync('@general:messages.generic.warning.title'),\n content,\n closeButton: true,\n timeOut: 10000,\n timeOutProgress: true,\n });\n }\n\n /**\n * Work-order approval flow expects `HumanCapitalManagement.Employee` id (`performedById` on WorkReport).\n * `WorkOrder.assignedToId` stores `PersonCore.Person` id.\n */\n private async resolveEmployeeIdByPersonId(personId: string): Promise<string> {\n if (!personId) {\n return '';\n }\n\n const page = await this.entityService\n .withEntity('HumanCapitalManagement', 'Employee')\n .data()\n .query({\n skip: 0,\n take: 1,\n filter: {\n logic: 'and',\n filters: [{ field: 'personId', operator: { type: 'equal' }, value: personId }],\n },\n } as never);\n\n const employee = defaultTo(get(page, 'items[0]'), null) as { id?: string } | null;\n return this.resolveText(employee?.id);\n }\n\n private async resolveMaintenanceTemplateId(\n workOrder: AXMMaintenanceManagementWorkOrderEntityModel,\n explicitTemplateId?: string,\n ): Promise<string> {\n if (explicitTemplateId) {\n return explicitTemplateId;\n }\n\n const currentTemplateId = this.resolveText(workOrder.maintenanceTemplateId);\n if (currentTemplateId) {\n const currentConfig = await this.resolveWorkflowConfig(workOrder);\n if (this.isWorkflowEnabled(currentConfig)) {\n return currentTemplateId;\n }\n }\n\n const assetId = this.resolveText(workOrder.assetId);\n if (!assetId) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-templates-for-asset',\n );\n await this.showWarning(content);\n return '';\n }\n\n const backend = this.createStorageBackend();\n const templateEntityName = `${RootConfig.module.name}.${RootConfig.entities.maintenanceTemplate.name}`;\n const templates = await queryWorkflowTemplatesForAsset(backend, templateEntityName, assetId);\n if (templates.length === 0) {\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.messages.no-workflow-templates-for-asset',\n );\n await this.showWarning(content);\n return '';\n }\n\n if (templates.length === 1) {\n return templates[0].id;\n }\n\n return (await this.pickMaintenanceTemplate(templates)) ?? '';\n }\n\n private async pickMaintenanceTemplate(templates: MaintenanceTemplateLike[]): Promise<string | null> {\n const locale = this.translationService.getActiveLang() as 'en-US' | 'fa-IR';\n const sorted = [...templates].sort((a, b) => {\n const ta = resolveDisplayLabel(a.title, a.code ?? a.id, locale);\n const tb = resolveDisplayLabel(b.title, b.code ?? b.id, locale);\n return ta.localeCompare(tb, locale, { sensitivity: 'base' });\n });\n\n const title = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.actions.start-flow.select-template.title',\n );\n const content = await this.translationService.translateAsync(\n '@maintenance-management:work-orders.actions.start-flow.select-template.content',\n );\n const cancelLabel = await this.translationService.translateAsync('@general:actions.cancel.title');\n\n return new Promise((resolve) => {\n let settled = false;\n const finish = (value: string | null) => {\n if (settled) {\n return;\n }\n settled = true;\n resolve(value);\n };\n\n const dialog = this.dialogService.open({\n title,\n content,\n type: 'primary',\n orientation: 'vertical',\n closeButton: true,\n buttons: [\n {\n text: cancelLabel,\n color: 'default',\n autofocus: true,\n onClick: () => {\n dialog.close();\n finish(null);\n },\n },\n ...sorted.map((template) => ({\n text: resolveDisplayLabel(template.title, template.code ?? template.id, locale),\n color: 'primary' as const,\n onClick: () => {\n dialog.close();\n finish(template.id);\n },\n })),\n ],\n });\n });\n }\n\n private createStorageBackend(): EntityStorageBackend {\n return {\n getOne: async (entityName, id) => {\n const [module, entity] = entityName.split('.');\n return this.entityService.withEntity(module, entity).data().byKey(id);\n },\n insertOne: async () => null,\n query: async (entityName, request) => {\n const [module, entity] = entityName.split('.');\n return this.entityService.withEntity(module, entity).data().query(request as never);\n },\n };\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAsCA,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS;AACzC,IAAA,kBAAkB,CAAC,OAAO;AAC1B,IAAA,kBAAkB,CAAC,SAAS;AAC5B,IAAA,kBAAkB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EAAA,yBAAyB,cADZ,MAAM,EAAA,CAAA,CAAA;;2FACnB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-platform-module-maintenance-management-client-update-work-order-completed.activity-Di4R6LQl.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/update-work-order-completed.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { isString } from 'lodash';\n\nimport { AXMWorkOrderStatus, RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface UpdateWorkOrderCompletedInput {\n workOrderId: string;\n}\n\nexport interface UpdateWorkOrderCompletedOutput {\n workOrderId: string;\n statusId: string;\n completedAt: string;\n}\n\n//#endregion\n\n/**\n * Marks the work order as completed. Approval/sign-off is handled by a separate workflow.\n */\n@Injectable({ providedIn: 'root' })\nexport class UpdateWorkOrderCompletedActivity\n implements AXPCommand<UpdateWorkOrderCompletedInput, UpdateWorkOrderCompletedOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: UpdateWorkOrderCompletedInput,\n ): AXPCommandExecuteResultPromise<UpdateWorkOrderCompletedOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (!workOrder?.id) {\n return {\n success: false,\n message: { text: 'Work order not found' },\n metadata: { outcome: 'NotFound' },\n };\n }\n\n if (workOrder.statusId === AXMWorkOrderStatus.Completed) {\n return { success: true, kind: 'object',\n data: {\n workOrderId,\n statusId: AXMWorkOrderStatus.Completed,\n completedAt: workOrder.completedAt ?? new Date().toISOString(),\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n if (workOrder.statusId !== AXMWorkOrderStatus.InProgress) {\n return {\n success: false,\n message: { text: 'Work order must be in progress before it can be marked completed.' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const completedAt = new Date().toISOString();\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n statusId: AXMWorkOrderStatus.Completed,\n completedAt,\n } as never);\n\n return { success: true, kind: 'object',\n data: {\n workOrderId,\n statusId: AXMWorkOrderStatus.Completed,\n completedAt,\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;AAyBA;AAEA;;AAEG;MAEU,gCAAgC,CAAA;AAD7C,IAAA,WAAA,GAAA;;AAMmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiF1D,IAAA;;;IA3EC,MAAM,OAAO,CACX,KAAoC,EAAA;QAEpC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;AAC5C,gBAAA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UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI;AACrE,aAAA,IAAI;aACJ,MAAM,CAAC,WAAW,EAAE;YACnB,QAAQ,EAAE,kBAAkB,CAAC,SAAS;YACtC,WAAW;AACH,SAAA,CAAC;AAEb,QAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ;AACpC,YAAA,IAAI,EAAE;gBACJ,WAAW;gBACX,QAAQ,EAAE,kBAAkB,CAAC,SAAS;gBACtC,WAAW;AACZ,aAAA;AACD,YAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;SAC9B;IACH;;;AAMQ,IAAA,WAAW,CAAC,KAAc,EAAA;AAChC,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;8GAnFW,gCAAgC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAhC,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,gCAAgC,cADnB,MAAM,EAAA,CAAA,CAAA;;2FACnB,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAD5C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
1
+ {"version":3,"file":"acorex-platform-module-maintenance-management-client-update-work-order-completed.activity-Di4R6LQl.mjs","sources":["../../../../libs/modules/maintenance-management/client/src/lib/features/work-order/workflows/activities/update-work-order-completed.activity.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXPRuntimeCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport { inject, Injectable } from '@angular/core';\nimport { isString } from 'lodash';\n\nimport { AXMWorkOrderStatus, RootConfig } from '@acorex-platform/module-maintenance-management-client/contracts';\nimport type { AXMMaintenanceManagementWorkOrderEntityModel } from '@acorex-platform/module-maintenance-management-client/contracts';\n\n//#endregion\n\n//#region ---- Types ----\n\nexport interface UpdateWorkOrderCompletedInput {\n workOrderId: string;\n}\n\nexport interface UpdateWorkOrderCompletedOutput {\n workOrderId: string;\n statusId: string;\n completedAt: string;\n}\n\n//#endregion\n\n/**\n * Marks the work order as completed. Approval/sign-off is handled by a separate workflow.\n */\n@Injectable({ providedIn: 'root' })\nexport class UpdateWorkOrderCompletedActivity\n implements AXPCommand<UpdateWorkOrderCompletedInput, UpdateWorkOrderCompletedOutput>\n{\n //#region ---- Services & Dependencies ----\n\n private readonly entityService = inject(AXPEntityService);\n\n //#endregion\n\n //#region ---- Command Implementation ----\n\n async execute(\n input: UpdateWorkOrderCompletedInput,\n ): AXPCommandExecuteResultPromise<UpdateWorkOrderCompletedOutput> {\n const workOrderId = this.resolveText(input?.workOrderId);\n if (!workOrderId) {\n return {\n success: false,\n message: { text: 'workOrderId is required' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const workOrder = (await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .byKey(workOrderId)) as AXMMaintenanceManagementWorkOrderEntityModel | null;\n\n if (!workOrder?.id) {\n return {\n success: false,\n message: { text: 'Work order not found' },\n metadata: { outcome: 'NotFound' },\n };\n }\n\n if (workOrder.statusId === AXMWorkOrderStatus.Completed) {\n return { success: true, kind: 'object',\n data: {\n workOrderId,\n statusId: AXMWorkOrderStatus.Completed,\n completedAt: workOrder.completedAt ?? new Date().toISOString(),\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n if (workOrder.statusId !== AXMWorkOrderStatus.InProgress) {\n return {\n success: false,\n message: { text: 'Work order must be in progress before it can be marked completed.' },\n metadata: { outcome: 'Failed' },\n };\n }\n\n const completedAt = new Date().toISOString();\n await this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.workOrder.name)\n .data()\n .update(workOrderId, {\n statusId: AXMWorkOrderStatus.Completed,\n completedAt,\n } as never);\n\n return { success: true, kind: 'object',\n data: {\n workOrderId,\n statusId: AXMWorkOrderStatus.Completed,\n completedAt,\n },\n metadata: { outcome: 'Done' },\n };\n }\n\n //#endregion\n\n //#region ---- Helpers ----\n\n private resolveText(value: unknown): string {\n if (!isString(value)) {\n return '';\n }\n return value.trim();\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;AAyBA;AAEA;;AAEG;MAEU,gCAAgC,CAAA;AAD7C,IAAA,WAAA,GAAA;;AAMmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAiF1D,IAAA;;;IA3EC,MAAM,OAAO,CACX,KAAoC,EAAA;QAEpC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;AAC5C,gBAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;aAChC;QACH;AAEA,QAAA,MAAM,SAAS,IAAI,MAAM,IAAI,CAAC;AAC3B,aAAA,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI;AACrE,aAAA,IAAI;AACJ,aAAA,KAAK,CAAC,WAAW,CAAC,CAAwD;AAE7E,QAAA,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE;YAClB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,EAAE,IAAI,EAAE,sBAAsB,EA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