@acorex-platform/module-document-management-client 0.0.38 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/{acorex-platform-module-document-management-client-acorex-platform-module-document-management-client-DHcNgw3P.mjs → acorex-platform-module-document-management-client-acorex-platform-module-document-management-client-DhDRtALE.mjs} +477 -163
- package/fesm2022/acorex-platform-module-document-management-client-acorex-platform-module-document-management-client-DhDRtALE.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-attachment-view-skeleton.component-lm3X8cQr.mjs → acorex-platform-module-document-management-client-attachment-view-skeleton.component-Dvvp7Dje.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-attachment-view-skeleton.component-lm3X8cQr.mjs.map → acorex-platform-module-document-management-client-attachment-view-skeleton.component-Dvvp7Dje.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-document-management-client-attachment-widget.component-nGSM4SLU.mjs → acorex-platform-module-document-management-client-attachment-widget.component-DVm7a1d2.mjs} +5 -4
- package/fesm2022/acorex-platform-module-document-management-client-attachment-widget.component-DVm7a1d2.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-shortcut.mjs +20 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-shortcut.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-type.mjs +65 -10
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-type.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-version.mjs +270 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document-version.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document.mjs +61 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-document.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-folder.mjs +21 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entities-folder.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-document-management-client-contracts-entity-catalog-acorex-platform-module-document-management-client-contracts-entity-catalog-Bl6_lO9-.mjs → acorex-platform-module-document-management-client-contracts-entity-catalog-acorex-platform-module-document-management-client-contracts-entity-catalog-BxwUMlCE.mjs} +12 -5
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-acorex-platform-module-document-management-client-contracts-entity-catalog-BxwUMlCE.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-contracts-entity-catalog-document-shortcut.entity-BpGBX1CD.mjs → acorex-platform-module-document-management-client-contracts-entity-catalog-document-shortcut.entity-D-hEBLFT.mjs} +16 -2
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-shortcut.entity-D-hEBLFT.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-contracts-entity-catalog-document-type.entity-D0-wHSOd.mjs → acorex-platform-module-document-management-client-contracts-entity-catalog-document-type.entity-CBMUwrc-.mjs} +61 -12
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-type.entity-CBMUwrc-.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-version.entity-hATC_iAQ.mjs +200 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-version.entity-hATC_iAQ.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-contracts-entity-catalog-document.entity-BB3250Gc.mjs → acorex-platform-module-document-management-client-contracts-entity-catalog-document.entity-DOvhTOtO.mjs} +57 -3
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document.entity-DOvhTOtO.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-contracts-entity-catalog-folder.entity-BWplP1j6.mjs → acorex-platform-module-document-management-client-contracts-entity-catalog-folder.entity-cNSFyJoY.mjs} +17 -2
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-folder.entity-cNSFyJoY.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog.mjs +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts.mjs +91 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-distribute-document.command-Bw6xDrJ4.mjs +445 -0
- package/fesm2022/acorex-platform-module-document-management-client-distribute-document.command-Bw6xDrJ4.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-distribute-document.command.util-Bnw0rh94.mjs +78 -0
- package/fesm2022/acorex-platform-module-document-management-client-distribute-document.command.util-Bnw0rh94.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-drive-choose.component-ByxmDInD.mjs → acorex-platform-module-document-management-client-drive-choose.component-BHiNuDvr.mjs} +17 -6
- package/fesm2022/acorex-platform-module-document-management-client-drive-choose.component-BHiNuDvr.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-large-icons-view-skeleton.component-B64PFFtO.mjs → acorex-platform-module-document-management-client-large-icons-view-skeleton.component-DmYeUizg.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-large-icons-view-skeleton.component-B64PFFtO.mjs.map → acorex-platform-module-document-management-client-large-icons-view-skeleton.component-DmYeUizg.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-large-icons-view.component-Dx95E_1P.mjs +31 -0
- package/fesm2022/acorex-platform-module-document-management-client-large-icons-view.component-Dx95E_1P.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-large-tiles-view.component-VNDRhDNx.mjs +36 -0
- package/fesm2022/acorex-platform-module-document-management-client-large-tiles-view.component-VNDRhDNx.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-list-view-skeleton.component-K22Zof-0.mjs → acorex-platform-module-document-management-client-list-view-skeleton.component-C9rbuY5b.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-list-view-skeleton.component-K22Zof-0.mjs.map → acorex-platform-module-document-management-client-list-view-skeleton.component-C9rbuY5b.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-list-view.component-yHeNWSJC.mjs +31 -0
- package/fesm2022/acorex-platform-module-document-management-client-list-view.component-yHeNWSJC.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-local-entities.mjs +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-local-entities.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-document-management-client-open-document.command-Deqs3cEg.mjs → acorex-platform-module-document-management-client-open-document.command-By0k8BgV.mjs} +27 -14
- package/fesm2022/acorex-platform-module-document-management-client-open-document.command-By0k8BgV.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-document-management-client-sign-distributed-document.command-DpQ-Un7q.mjs +124 -0
- package/fesm2022/acorex-platform-module-document-management-client-sign-distributed-document.command-DpQ-Un7q.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-small-icons-view-skeleton.component-BFuFFUax.mjs → acorex-platform-module-document-management-client-small-icons-view-skeleton.component-d0LTdcBY.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-small-icons-view-skeleton.component-BFuFFUax.mjs.map → acorex-platform-module-document-management-client-small-icons-view-skeleton.component-d0LTdcBY.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-small-icons-view.component-CoEYTcd9.mjs +31 -0
- package/fesm2022/acorex-platform-module-document-management-client-small-icons-view.component-CoEYTcd9.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-small-tiles-view-skeleton.component-6EgbuXTv.mjs → acorex-platform-module-document-management-client-small-tiles-view-skeleton.component-rZAAx-ns.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-small-tiles-view-skeleton.component-6EgbuXTv.mjs.map → acorex-platform-module-document-management-client-small-tiles-view-skeleton.component-rZAAx-ns.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-document-management-client-small-tiles-view.component-C4wnLgWR.mjs +36 -0
- package/fesm2022/acorex-platform-module-document-management-client-small-tiles-view.component-C4wnLgWR.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-document-management-client-upload-document.command-D6J57Ha5.mjs → acorex-platform-module-document-management-client-upload-document.command-JDYYMckB.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-document-management-client-upload-document.command-D6J57Ha5.mjs.map → acorex-platform-module-document-management-client-upload-document.command-JDYYMckB.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-document-management-client.mjs +1 -1
- package/package.json +6 -2
- package/types/acorex-platform-module-document-management-client-contracts-entities-document-version.d.ts +8 -0
- package/types/acorex-platform-module-document-management-client-contracts.d.ts +85 -4
- package/types/acorex-platform-module-document-management-client.d.ts +98 -7
- package/fesm2022/acorex-platform-module-document-management-client-acorex-platform-module-document-management-client-DHcNgw3P.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-attachment-widget.component-nGSM4SLU.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-acorex-platform-module-document-management-client-contracts-entity-catalog-Bl6_lO9-.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-shortcut.entity-BpGBX1CD.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document-type.entity-D0-wHSOd.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-document.entity-BB3250Gc.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-contracts-entity-catalog-folder.entity-BWplP1j6.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-drive-choose.component-ByxmDInD.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-large-icons-view.component-CBk1WOVb.mjs +0 -30
- package/fesm2022/acorex-platform-module-document-management-client-large-icons-view.component-CBk1WOVb.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-large-tiles-view.component-m-UkV_QT.mjs +0 -35
- package/fesm2022/acorex-platform-module-document-management-client-large-tiles-view.component-m-UkV_QT.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-list-view.component-CVF0Lkii.mjs +0 -30
- package/fesm2022/acorex-platform-module-document-management-client-list-view.component-CVF0Lkii.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-open-document.command-Deqs3cEg.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-small-icons-view.component-5XaGmpoN.mjs +0 -30
- package/fesm2022/acorex-platform-module-document-management-client-small-icons-view.component-5XaGmpoN.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-document-management-client-small-tiles-view.component-07tFnkqV.mjs +0 -35
- package/fesm2022/acorex-platform-module-document-management-client-small-tiles-view.component-07tFnkqV.mjs.map +0 -1
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { AXLoadingDialogService } from '@acorex/components/loading-dialog';
|
|
2
|
+
import { AXToastService } from '@acorex/components/toast';
|
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
|
4
|
+
import { AXPSessionService } from '@acorex-platform/framework-client/auth';
|
|
5
|
+
import { AXPLayoutBuilderService, resolveLayoutBuilderDialogResult } from '@acorex-platform/framework-client/layout/builder';
|
|
6
|
+
import { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';
|
|
7
|
+
import { AXPWorkflowManager } from '@acorex-platform/framework-client/workflow';
|
|
8
|
+
import { buildAXPRecordWorkflowInfo } from '@acorex-platform/framework-shared/entity';
|
|
9
|
+
import { RootConfig, AXPContentDocumentsPermissionKeys } from '@acorex-platform/module-document-management-client/contracts';
|
|
10
|
+
import * as i0 from '@angular/core';
|
|
11
|
+
import { inject, Injectable } from '@angular/core';
|
|
12
|
+
import { d as AXMDocumentManagerService } from './acorex-platform-module-document-management-client-acorex-platform-module-document-management-client-DhDRtALE.mjs';
|
|
13
|
+
import { a as asTrimmedId, i as isTruthyFlag, b as asDisplayName, m as mapWithConcurrency, c as asUserIds, r as resolveCreatedEntityId } from './acorex-platform-module-document-management-client-distribute-document.command.util-Bnw0rh94.mjs';
|
|
14
|
+
|
|
15
|
+
//#region ----- Imports -----
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ----- Constants -----
|
|
18
|
+
const TASK_MODULE = 'TaskManagement';
|
|
19
|
+
const TASK_ENTITY = 'Task';
|
|
20
|
+
const TASK_ENTITY_NAME = `${TASK_MODULE}.${TASK_ENTITY}`;
|
|
21
|
+
const TASK_TYPE_ENTITY = 'TaskType';
|
|
22
|
+
const TASK_STATUS_ENTITY = 'TaskStatus';
|
|
23
|
+
const TASK_ASSIGNMENT_ENTITY = 'TaskAssignment';
|
|
24
|
+
const DOCUMENT_DISTRIBUTION_WORKFLOW_NAME = 'document-distribution';
|
|
25
|
+
const MOCK_DOCUMENT_DISTRIBUTION_TASK_TYPE_ID = 'pm-mock-task-type-document-distribution';
|
|
26
|
+
const DOCUMENT_VERSION_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.documentVersion.name}`;
|
|
27
|
+
const I18N = '@document-management:distribute';
|
|
28
|
+
const ASSIGNEE_CREATE_CONCURRENCY = 3;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ----- Helpers -----
|
|
31
|
+
function resolveDocumentId(input = {}) {
|
|
32
|
+
const data = input.data;
|
|
33
|
+
const fromData = data && typeof data === 'object'
|
|
34
|
+
? asTrimmedId(data.documentId) ?? asTrimmedId(data.id)
|
|
35
|
+
: undefined;
|
|
36
|
+
return asTrimmedId(input.options?.documentId) ?? fromData ?? asTrimmedId(input.documentId);
|
|
37
|
+
}
|
|
38
|
+
function asItems(value) {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
if (value && typeof value === 'object' && Array.isArray(value.items)) {
|
|
43
|
+
return value.items;
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
function statusRef(row) {
|
|
48
|
+
const id = asTrimmedId(row?.id);
|
|
49
|
+
if (!id) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return { id, title: row?.title, color: row?.color, icon: row?.icon };
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ----- Distribute document command -----
|
|
56
|
+
class AXMDistributeDocumentCommand {
|
|
57
|
+
constructor() {
|
|
58
|
+
//#region ----- Services & Dependencies -----
|
|
59
|
+
this.layoutBuilder = inject(AXPLayoutBuilderService);
|
|
60
|
+
this.entityService = inject(AXPEntityService);
|
|
61
|
+
this.sessionService = inject(AXPSessionService);
|
|
62
|
+
this.toastService = inject(AXToastService);
|
|
63
|
+
this.translationService = inject(AXTranslationService);
|
|
64
|
+
this.workflowManager = inject(AXPWorkflowManager);
|
|
65
|
+
this.driveService = inject(AXMDocumentManagerService);
|
|
66
|
+
this.loadingDialog = inject(AXLoadingDialogService);
|
|
67
|
+
this.documentData = this.entityService
|
|
68
|
+
.withEntity(RootConfig.module.name, RootConfig.entities.document.name)
|
|
69
|
+
.data();
|
|
70
|
+
this.taskTypeData = this.entityService.withEntity(TASK_MODULE, TASK_TYPE_ENTITY).data();
|
|
71
|
+
this.taskStatusData = this.entityService
|
|
72
|
+
.withEntity(TASK_MODULE, TASK_STATUS_ENTITY)
|
|
73
|
+
.data();
|
|
74
|
+
this.taskData = this.entityService.withEntity(TASK_MODULE, TASK_ENTITY).data();
|
|
75
|
+
this.assignmentData = this.entityService.withEntity(TASK_MODULE, TASK_ASSIGNMENT_ENTITY).data();
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ----- Command Implementation -----
|
|
79
|
+
async execute(input = {}) {
|
|
80
|
+
if (!this.sessionService.authorize(AXPContentDocumentsPermissionKeys.DistributeDocuments)) {
|
|
81
|
+
await this.toastError('errors.forbidden');
|
|
82
|
+
return { success: false, message: { text: `${I18N}.errors.forbidden` } };
|
|
83
|
+
}
|
|
84
|
+
const documentId = resolveDocumentId(input);
|
|
85
|
+
if (!documentId) {
|
|
86
|
+
await this.toastError('errors.document-required');
|
|
87
|
+
return { success: false, message: { text: `${I18N}.errors.document-required` } };
|
|
88
|
+
}
|
|
89
|
+
const document = await this.documentData.byKey(documentId);
|
|
90
|
+
if (!document?.id) {
|
|
91
|
+
await this.toastError('errors.document-required');
|
|
92
|
+
return { success: false, message: { text: `${I18N}.errors.document-required` } };
|
|
93
|
+
}
|
|
94
|
+
if (!isTruthyFlag(document.distributionEnabled) && !isTruthyFlag(document.documentType?.enableDistributionCapability)) {
|
|
95
|
+
await this.toastError('errors.not-enabled');
|
|
96
|
+
return { success: false, message: { text: `${I18N}.errors.not-enabled` } };
|
|
97
|
+
}
|
|
98
|
+
const versionId = asTrimmedId(document.versionId);
|
|
99
|
+
if (!versionId) {
|
|
100
|
+
await this.toastError('errors.version-required');
|
|
101
|
+
return { success: false, message: { text: `${I18N}.errors.version-required` } };
|
|
102
|
+
}
|
|
103
|
+
const setupPromise = this.loadDistributionSetup();
|
|
104
|
+
const form = await this.openDialog(document);
|
|
105
|
+
if (!form) {
|
|
106
|
+
return { success: true, kind: 'object', data: { cancelled: true } };
|
|
107
|
+
}
|
|
108
|
+
const loading = await this.showDistributeLoading(form.assigneeIds.length);
|
|
109
|
+
try {
|
|
110
|
+
const setup = await setupPromise;
|
|
111
|
+
if (!setup?.taskType?.id) {
|
|
112
|
+
await this.toastError('errors.task-type-missing');
|
|
113
|
+
return { success: false, message: { text: `${I18N}.errors.task-type-missing` } };
|
|
114
|
+
}
|
|
115
|
+
if (!setup.openStatus?.id) {
|
|
116
|
+
await this.toastError('errors.status-missing');
|
|
117
|
+
return { success: false, message: { text: `${I18N}.errors.status-missing` } };
|
|
118
|
+
}
|
|
119
|
+
const firstAssigneeId = form.assigneeIds[0];
|
|
120
|
+
const documentDisplayName = asDisplayName(document.name) ?? asDisplayName(document.title);
|
|
121
|
+
const subjectRef = {
|
|
122
|
+
type: DOCUMENT_VERSION_ENTITY,
|
|
123
|
+
id: versionId,
|
|
124
|
+
title: documentDisplayName,
|
|
125
|
+
};
|
|
126
|
+
const assignedBy = this.sessionService.user?.id;
|
|
127
|
+
const total = form.assigneeIds.length;
|
|
128
|
+
let completed = 0;
|
|
129
|
+
const created = await mapWithConcurrency(form.assigneeIds, ASSIGNEE_CREATE_CONCURRENCY, async (userId) => {
|
|
130
|
+
const row = await this.createAndStartForAssignee({
|
|
131
|
+
userId,
|
|
132
|
+
assignedBy: assignedBy ?? firstAssigneeId,
|
|
133
|
+
form,
|
|
134
|
+
taskType: setup.taskType,
|
|
135
|
+
openStatus: setup.openStatus,
|
|
136
|
+
signOffStatus: setup.signOffStatus,
|
|
137
|
+
completedStatus: setup.completedStatus,
|
|
138
|
+
subjectRef,
|
|
139
|
+
document,
|
|
140
|
+
versionId,
|
|
141
|
+
documentDisplayName,
|
|
142
|
+
workflowId: setup.workflowId,
|
|
143
|
+
});
|
|
144
|
+
completed += 1;
|
|
145
|
+
await this.updateDistributeLoadingProgress(loading, completed, total);
|
|
146
|
+
return row;
|
|
147
|
+
});
|
|
148
|
+
const createdTaskIds = created.map((row) => row.taskId);
|
|
149
|
+
const createdInstanceIds = created
|
|
150
|
+
.map((row) => row.instanceId)
|
|
151
|
+
.filter((id) => typeof id === 'string' && id.length > 0);
|
|
152
|
+
if (created.some((row) => row.pinFailed)) {
|
|
153
|
+
await this.toastWarning('warnings.pin-failed');
|
|
154
|
+
}
|
|
155
|
+
const [title, content] = await Promise.all([
|
|
156
|
+
this.translationService.translateAsync(`${I18N}.success.title`),
|
|
157
|
+
this.translationService.translateAsync(`${I18N}.success.description`),
|
|
158
|
+
]);
|
|
159
|
+
this.toastService.show({ color: 'success', title, content, timeOut: 3000 });
|
|
160
|
+
return { success: true, kind: 'object', data: { taskIds: createdTaskIds, instanceIds: createdInstanceIds } };
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
const message = error instanceof Error ? error.message : undefined;
|
|
164
|
+
await this.toastError('errors.failed', message);
|
|
165
|
+
return { success: false, message: { text: message ?? `${I18N}.errors.failed` } };
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
loading.close();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ----- Dialog -----
|
|
173
|
+
async openDialog(document) {
|
|
174
|
+
const defaultTitle = asDisplayName(document.name) ?? asDisplayName(document.title) ?? '';
|
|
175
|
+
const dueDate = new Date();
|
|
176
|
+
dueDate.setHours(0, 0, 0, 0);
|
|
177
|
+
const result = await this.layoutBuilder
|
|
178
|
+
.create()
|
|
179
|
+
.dialog((dialog) => {
|
|
180
|
+
dialog
|
|
181
|
+
.setTitle(`${I18N}.dialog.title`)
|
|
182
|
+
.setSize('md')
|
|
183
|
+
.setCloseButton(true)
|
|
184
|
+
.setContext({
|
|
185
|
+
title: defaultTitle,
|
|
186
|
+
description: '',
|
|
187
|
+
dueDate,
|
|
188
|
+
assigneeIds: [],
|
|
189
|
+
})
|
|
190
|
+
.content((flex) => {
|
|
191
|
+
flex
|
|
192
|
+
.setDirection('column')
|
|
193
|
+
.setGap('12px')
|
|
194
|
+
.formField(`${I18N}.fields.title`, (field) => {
|
|
195
|
+
field.path('title');
|
|
196
|
+
field.textBox({ validations: [{ rule: 'required' }] });
|
|
197
|
+
})
|
|
198
|
+
.formField(`${I18N}.fields.description`, (field) => {
|
|
199
|
+
field.path('description');
|
|
200
|
+
field.textBox({});
|
|
201
|
+
})
|
|
202
|
+
.formField(`${I18N}.fields.due-date`, (field) => {
|
|
203
|
+
field.path('dueDate');
|
|
204
|
+
field.dateTimeBox({ type: 'date', validations: [{ rule: 'required' }] });
|
|
205
|
+
})
|
|
206
|
+
.formField(`${I18N}.fields.assignees`, (field) => {
|
|
207
|
+
field.path('assigneeIds');
|
|
208
|
+
field.lookupBox({
|
|
209
|
+
entity: 'SecurityManagement.User',
|
|
210
|
+
multiple: true,
|
|
211
|
+
look: 'lookup',
|
|
212
|
+
validations: [{ rule: 'required' }],
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
})
|
|
216
|
+
.setActions((actions) => {
|
|
217
|
+
actions.cancel('@general:actions.cancel.title');
|
|
218
|
+
actions.submit(`${I18N}.dialog.submit`);
|
|
219
|
+
})
|
|
220
|
+
.onAction(async (dialogRef) => {
|
|
221
|
+
if (dialogRef.action() === 'cancel') {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const ctx = dialogRef.context();
|
|
225
|
+
const title = (ctx.title ?? '').trim();
|
|
226
|
+
const assigneeIds = asUserIds(ctx.assigneeIds);
|
|
227
|
+
if (!title) {
|
|
228
|
+
throw new Error(`${I18N}.errors.title-required`);
|
|
229
|
+
}
|
|
230
|
+
if (!ctx.dueDate) {
|
|
231
|
+
throw new Error(`${I18N}.errors.due-date-required`);
|
|
232
|
+
}
|
|
233
|
+
if (assigneeIds.length === 0) {
|
|
234
|
+
throw new Error(`${I18N}.errors.assignees-required`);
|
|
235
|
+
}
|
|
236
|
+
dialogRef.setLoading(true);
|
|
237
|
+
return {
|
|
238
|
+
title,
|
|
239
|
+
description: (ctx.description ?? '').trim() || undefined,
|
|
240
|
+
dueDate: ctx.dueDate,
|
|
241
|
+
assigneeIds,
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
})
|
|
245
|
+
.show();
|
|
246
|
+
return resolveLayoutBuilderDialogResult(result);
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region ----- Create per assignee -----
|
|
250
|
+
async createAndStartForAssignee(params) {
|
|
251
|
+
const createdTask = await this.taskData.create({
|
|
252
|
+
title: params.form.title,
|
|
253
|
+
description: params.form.description,
|
|
254
|
+
taskTypeId: params.taskType.id,
|
|
255
|
+
taskType: { id: params.taskType.id, title: params.taskType.title },
|
|
256
|
+
statusId: params.openStatus.id,
|
|
257
|
+
status: statusRef(params.openStatus),
|
|
258
|
+
priority: 'medium',
|
|
259
|
+
progress: 0,
|
|
260
|
+
order: 0,
|
|
261
|
+
startDate: params.form.dueDate,
|
|
262
|
+
dueDate: params.form.dueDate,
|
|
263
|
+
assigneeId: params.userId,
|
|
264
|
+
assignee: { id: params.userId },
|
|
265
|
+
subjectRef: params.subjectRef,
|
|
266
|
+
isArchived: false,
|
|
267
|
+
});
|
|
268
|
+
const taskId = resolveCreatedEntityId(createdTask);
|
|
269
|
+
let pinFailed = false;
|
|
270
|
+
const assignmentPromise = this.assignmentData.create({
|
|
271
|
+
taskId,
|
|
272
|
+
assignmentRef: {
|
|
273
|
+
sourceKey: 'employee-user',
|
|
274
|
+
refId: params.userId,
|
|
275
|
+
displayName: params.userId,
|
|
276
|
+
},
|
|
277
|
+
role: 'reviewer',
|
|
278
|
+
assignedBy: params.assignedBy,
|
|
279
|
+
assignedAt: new Date(),
|
|
280
|
+
isActive: true,
|
|
281
|
+
});
|
|
282
|
+
const pinPromise = this.pinDocumentOnTask(taskId, params.document, params.documentDisplayName).catch((error) => {
|
|
283
|
+
console.warn('[AXMDistributeDocumentCommand] pin document shortcut failed', error);
|
|
284
|
+
pinFailed = true;
|
|
285
|
+
});
|
|
286
|
+
const [, , instanceId] = await Promise.all([
|
|
287
|
+
assignmentPromise,
|
|
288
|
+
pinPromise,
|
|
289
|
+
this.startWorkflowForAssignee(taskId, params),
|
|
290
|
+
]);
|
|
291
|
+
return { taskId, instanceId, pinFailed };
|
|
292
|
+
}
|
|
293
|
+
async startWorkflowForAssignee(taskId, params) {
|
|
294
|
+
const startResult = await this.workflowManager.start(params.workflowId, {
|
|
295
|
+
taskId,
|
|
296
|
+
taskTitle: params.form.title,
|
|
297
|
+
documentId: params.document.id,
|
|
298
|
+
documentVersionId: params.versionId,
|
|
299
|
+
signerUserId: params.userId,
|
|
300
|
+
signerUserIds: [params.userId],
|
|
301
|
+
initiatorUserId: params.assignedBy,
|
|
302
|
+
openStatusId: params.openStatus.id,
|
|
303
|
+
openStatus: statusRef(params.openStatus),
|
|
304
|
+
signOffStatusId: params.signOffStatus?.id ?? params.openStatus.id,
|
|
305
|
+
signOffStatus: statusRef(params.signOffStatus) ?? statusRef(params.openStatus),
|
|
306
|
+
completedStatusId: params.completedStatus?.id ?? params.openStatus.id,
|
|
307
|
+
completedStatus: statusRef(params.completedStatus) ?? statusRef(params.openStatus),
|
|
308
|
+
correlationId: taskId,
|
|
309
|
+
refId: taskId,
|
|
310
|
+
refType: TASK_ENTITY_NAME,
|
|
311
|
+
dueDate: params.form.dueDate,
|
|
312
|
+
});
|
|
313
|
+
if (!startResult.success) {
|
|
314
|
+
throw new Error(startResult.error ?? 'workflow-failed');
|
|
315
|
+
}
|
|
316
|
+
if (startResult.instanceId) {
|
|
317
|
+
try {
|
|
318
|
+
await this.taskData.update(taskId, {
|
|
319
|
+
workflowInfo: buildAXPRecordWorkflowInfo({
|
|
320
|
+
instanceId: startResult.instanceId,
|
|
321
|
+
definitionId: params.workflowId,
|
|
322
|
+
correlationId: taskId,
|
|
323
|
+
}),
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
console.warn('[AXMDistributeDocumentCommand] stamp workflowInfo failed', error);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return startResult.instanceId;
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region ----- Pin document -----
|
|
334
|
+
async pinDocumentOnTask(taskId, document, nameOverride) {
|
|
335
|
+
const folder = await this.driveService.getRootByEntityRef(`${TASK_MODULE}.${TASK_ENTITY}`, taskId);
|
|
336
|
+
const folderId = folder?.result?.id;
|
|
337
|
+
if (!folderId) {
|
|
338
|
+
throw new Error('Task document folder was not provisioned');
|
|
339
|
+
}
|
|
340
|
+
await this.driveService.createShortcut(document.id, 'file', folderId, {
|
|
341
|
+
nameOverride: nameOverride ?? asDisplayName(document.name) ?? asDisplayName(document.title) ?? 'Document',
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region ----- Data Loading -----
|
|
346
|
+
async loadDistributionSetup() {
|
|
347
|
+
const taskType = await this.loadDistributionTaskType();
|
|
348
|
+
if (!taskType?.id) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
const statuses = await this.loadStatuses(taskType.id);
|
|
352
|
+
const openStatus = statuses.find((row) => row.isDefault) ?? statuses[0];
|
|
353
|
+
const signOffStatus = statuses.find((row) => row.name === 'sign-off') ?? openStatus;
|
|
354
|
+
const completedStatus = statuses.find((row) => row.isFinal) ?? signOffStatus;
|
|
355
|
+
return {
|
|
356
|
+
taskType,
|
|
357
|
+
openStatus,
|
|
358
|
+
signOffStatus,
|
|
359
|
+
completedStatus,
|
|
360
|
+
workflowId: taskType.workflowConfig?.workflowName?.trim() || DOCUMENT_DISTRIBUTION_WORKFLOW_NAME,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
async loadDistributionTaskType() {
|
|
364
|
+
try {
|
|
365
|
+
const byId = await this.taskTypeData.byKey(MOCK_DOCUMENT_DISTRIBUTION_TASK_TYPE_ID);
|
|
366
|
+
if (byId?.id) {
|
|
367
|
+
return byId;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
// hashed tenant copies use different ids
|
|
372
|
+
}
|
|
373
|
+
const result = await this.taskTypeData.query({ skip: 0, take: 200 });
|
|
374
|
+
return (asItems(result).find((row) => row.workflowConfig?.workflowName?.trim() === DOCUMENT_DISTRIBUTION_WORKFLOW_NAME) ?? null);
|
|
375
|
+
}
|
|
376
|
+
async loadStatuses(taskTypeId) {
|
|
377
|
+
const result = await this.taskStatusData.query({
|
|
378
|
+
skip: 0,
|
|
379
|
+
take: 50,
|
|
380
|
+
filter: { field: 'taskTypeId', operator: { type: 'equal' }, value: taskTypeId },
|
|
381
|
+
});
|
|
382
|
+
const rows = asItems(result);
|
|
383
|
+
return rows.some((row) => row.taskTypeId === taskTypeId)
|
|
384
|
+
? rows.filter((row) => row.taskTypeId === taskTypeId)
|
|
385
|
+
: rows;
|
|
386
|
+
}
|
|
387
|
+
async showDistributeLoading(assigneeCount) {
|
|
388
|
+
const [title, text] = await Promise.all([
|
|
389
|
+
this.translationService.translateAsync(`${I18N}.loading.title`),
|
|
390
|
+
this.translationService.translateAsync(`${I18N}.loading.description`, {
|
|
391
|
+
params: { count: assigneeCount },
|
|
392
|
+
}),
|
|
393
|
+
]);
|
|
394
|
+
return this.loadingDialog.show({
|
|
395
|
+
title,
|
|
396
|
+
mode: 'indeterminate',
|
|
397
|
+
progressColor: 'primary',
|
|
398
|
+
text,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
async updateDistributeLoadingProgress(loading, current, total) {
|
|
402
|
+
if (!loading.setProgressText) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const text = await this.translationService.translateAsync(`${I18N}.loading.progress`, {
|
|
406
|
+
params: { current, total },
|
|
407
|
+
});
|
|
408
|
+
loading.setProgressText(text);
|
|
409
|
+
}
|
|
410
|
+
async toastError(key, detail) {
|
|
411
|
+
const [title, fallback] = await Promise.all([
|
|
412
|
+
this.translationService.translateAsync(`${I18N}.errors.title`),
|
|
413
|
+
this.translationService.translateAsync(`${I18N}.${key}`),
|
|
414
|
+
]);
|
|
415
|
+
this.toastService.show({
|
|
416
|
+
color: 'danger',
|
|
417
|
+
title,
|
|
418
|
+
content: detail?.trim() || fallback,
|
|
419
|
+
closeButton: true,
|
|
420
|
+
timeOut: 5000,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
async toastWarning(key) {
|
|
424
|
+
const [title, content] = await Promise.all([
|
|
425
|
+
this.translationService.translateAsync(`${I18N}.warnings.title`),
|
|
426
|
+
this.translationService.translateAsync(`${I18N}.${key}`),
|
|
427
|
+
]);
|
|
428
|
+
this.toastService.show({
|
|
429
|
+
color: 'warning',
|
|
430
|
+
title,
|
|
431
|
+
content,
|
|
432
|
+
closeButton: true,
|
|
433
|
+
timeOut: 5000,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMDistributeDocumentCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
437
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMDistributeDocumentCommand, providedIn: 'root' }); }
|
|
438
|
+
}
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMDistributeDocumentCommand, decorators: [{
|
|
440
|
+
type: Injectable,
|
|
441
|
+
args: [{ providedIn: 'root' }]
|
|
442
|
+
}] });
|
|
443
|
+
|
|
444
|
+
export { AXMDistributeDocumentCommand };
|
|
445
|
+
//# sourceMappingURL=acorex-platform-module-document-management-client-distribute-document.command-Bw6xDrJ4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-document-management-client-distribute-document.command-Bw6xDrJ4.mjs","sources":["../../../../libs/modules/document-management/client/src/lib/features/commands/distribute-document.command.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { AXLoadingDialogService } from '@acorex/components/loading-dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport {\n AXPLayoutBuilderService,\n resolveLayoutBuilderDialogResult,\n} from '@acorex-platform/framework-client/layout/builder';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\nimport { AXPWorkflowManager } from '@acorex-platform/framework-client/workflow';\nimport type { AXPEntityReference } from '@acorex-platform/framework-shared/core';\nimport { buildAXPRecordWorkflowInfo } from '@acorex-platform/framework-shared/entity';\nimport { AXPCommand, type AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport {\n AXPContentDocumentsPermissionKeys,\n RootConfig,\n type AXMDocumentDto,\n} from '@acorex-platform/module-document-management-client/contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXMDocumentManagerService } from '../shared/document-manager.service';\nimport type { AXMDocumentExplorerNode } from '../shared/document-manager.types';\nimport {\n asDisplayName,\n asTrimmedId,\n asUserIds,\n isTruthyFlag,\n mapWithConcurrency,\n resolveCreatedEntityId,\n} from './distribute-document.command.util';\n\n//#endregion\n\n//#region ----- Types -----\n\nexport interface AXMDistributeDocumentCommandInput {\n documentId?: string;\n data?: AXMDocumentExplorerNode | { documentId?: string; id?: string };\n options?: { documentId?: string };\n}\n\ninterface DistributeDialogResult {\n title: string;\n description?: string;\n dueDate: Date | string;\n assigneeIds: string[];\n}\n\ninterface TaskTypeRow {\n id: string;\n title?: string;\n workflowConfig?: {\n workflowDefinitionId?: string;\n workflowName?: string;\n } | null;\n}\n\ninterface TaskStatusRow {\n id: string;\n name?: string;\n title?: string;\n color?: string;\n icon?: string;\n isDefault?: boolean;\n isFinal?: boolean;\n taskTypeId?: string;\n}\n\ninterface DistributionSetup {\n taskType: TaskTypeRow;\n openStatus: TaskStatusRow;\n signOffStatus: TaskStatusRow | undefined;\n completedStatus: TaskStatusRow | undefined;\n workflowId: string;\n}\n\ninterface LoadingDialogRef {\n close: () => void;\n setProgressText?: (text: string) => void;\n}\n\n//#endregion\n\n//#region ----- Constants -----\n\nconst TASK_MODULE = 'TaskManagement';\nconst TASK_ENTITY = 'Task';\nconst TASK_ENTITY_NAME = `${TASK_MODULE}.${TASK_ENTITY}`;\nconst TASK_TYPE_ENTITY = 'TaskType';\nconst TASK_STATUS_ENTITY = 'TaskStatus';\nconst TASK_ASSIGNMENT_ENTITY = 'TaskAssignment';\nconst DOCUMENT_DISTRIBUTION_WORKFLOW_NAME = 'document-distribution';\nconst MOCK_DOCUMENT_DISTRIBUTION_TASK_TYPE_ID = 'pm-mock-task-type-document-distribution';\nconst DOCUMENT_VERSION_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.documentVersion.name}`;\nconst I18N = '@document-management:distribute';\nconst ASSIGNEE_CREATE_CONCURRENCY = 3;\n\n//#endregion\n\n//#region ----- Helpers -----\n\nfunction resolveDocumentId(input: AXMDistributeDocumentCommandInput = {}): string | undefined {\n const data = input.data;\n const fromData =\n data && typeof data === 'object'\n ? asTrimmedId((data as { documentId?: unknown }).documentId) ?? asTrimmedId((data as { id?: unknown }).id)\n : undefined;\n return asTrimmedId(input.options?.documentId) ?? fromData ?? asTrimmedId(input.documentId);\n}\n\nfunction asItems<T>(value: unknown): T[] {\n if (Array.isArray(value)) {\n return value as T[];\n }\n if (value && typeof value === 'object' && Array.isArray((value as { items?: unknown }).items)) {\n return (value as { items: T[] }).items;\n }\n return [];\n}\n\nfunction statusRef(row: TaskStatusRow | undefined): { id: string; title?: string; color?: string; icon?: string } | undefined {\n const id = asTrimmedId(row?.id);\n if (!id) {\n return undefined;\n }\n return { id, title: row?.title, color: row?.color, icon: row?.icon };\n}\n\n//#endregion\n\n//#region ----- Distribute document command -----\n\n@Injectable({ providedIn: 'root' })\nexport class AXMDistributeDocumentCommand implements AXPCommand<AXMDistributeDocumentCommandInput> {\n //#region ----- Services & Dependencies -----\n\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly entityService = inject(AXPEntityService);\n private readonly sessionService = inject(AXPSessionService);\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n private readonly workflowManager = inject(AXPWorkflowManager);\n private readonly driveService = inject(AXMDocumentManagerService);\n private readonly loadingDialog = inject(AXLoadingDialogService);\n\n private readonly documentData = this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.document.name)\n .data<string, AXMDocumentDto>();\n private readonly taskTypeData = this.entityService.withEntity(TASK_MODULE, TASK_TYPE_ENTITY).data<string, TaskTypeRow>();\n private readonly taskStatusData = this.entityService\n .withEntity(TASK_MODULE, TASK_STATUS_ENTITY)\n .data<string, TaskStatusRow>();\n private readonly taskData = this.entityService.withEntity(TASK_MODULE, TASK_ENTITY).data<string>();\n private readonly assignmentData = this.entityService.withEntity(TASK_MODULE, TASK_ASSIGNMENT_ENTITY).data<string>();\n\n //#endregion\n\n //#region ----- Command Implementation -----\n\n async execute(input: AXMDistributeDocumentCommandInput = {}): AXPCommandExecuteResultPromise {\n if (!this.sessionService.authorize(AXPContentDocumentsPermissionKeys.DistributeDocuments)) {\n await this.toastError('errors.forbidden');\n return { success: false, message: { text: `${I18N}.errors.forbidden` } };\n }\n\n const documentId = resolveDocumentId(input);\n if (!documentId) {\n await this.toastError('errors.document-required');\n return { success: false, message: { text: `${I18N}.errors.document-required` } };\n }\n\n const document = await this.documentData.byKey(documentId);\n if (!document?.id) {\n await this.toastError('errors.document-required');\n return { success: false, message: { text: `${I18N}.errors.document-required` } };\n }\n\n if (!isTruthyFlag(document.distributionEnabled) && !isTruthyFlag(document.documentType?.enableDistributionCapability)) {\n await this.toastError('errors.not-enabled');\n return { success: false, message: { text: `${I18N}.errors.not-enabled` } };\n }\n\n const versionId = asTrimmedId(document.versionId);\n if (!versionId) {\n await this.toastError('errors.version-required');\n return { success: false, message: { text: `${I18N}.errors.version-required` } };\n }\n\n const setupPromise = this.loadDistributionSetup();\n const form = await this.openDialog(document);\n if (!form) {\n return { success: true, kind: 'object', data: { cancelled: true } };\n }\n\n const loading = await this.showDistributeLoading(form.assigneeIds.length);\n try {\n const setup = await setupPromise;\n if (!setup?.taskType?.id) {\n await this.toastError('errors.task-type-missing');\n return { success: false, message: { text: `${I18N}.errors.task-type-missing` } };\n }\n if (!setup.openStatus?.id) {\n await this.toastError('errors.status-missing');\n return { success: false, message: { text: `${I18N}.errors.status-missing` } };\n }\n\n const firstAssigneeId = form.assigneeIds[0];\n const documentDisplayName = asDisplayName(document.name) ?? asDisplayName(document.title);\n const subjectRef: AXPEntityReference = {\n type: DOCUMENT_VERSION_ENTITY,\n id: versionId,\n title: documentDisplayName,\n };\n const assignedBy = this.sessionService.user?.id;\n const total = form.assigneeIds.length;\n let completed = 0;\n\n const created = await mapWithConcurrency(form.assigneeIds, ASSIGNEE_CREATE_CONCURRENCY, async (userId) => {\n const row = await this.createAndStartForAssignee({\n userId,\n assignedBy: assignedBy ?? firstAssigneeId,\n form,\n taskType: setup.taskType,\n openStatus: setup.openStatus,\n signOffStatus: setup.signOffStatus,\n completedStatus: setup.completedStatus,\n subjectRef,\n document,\n versionId,\n documentDisplayName,\n workflowId: setup.workflowId,\n });\n completed += 1;\n await this.updateDistributeLoadingProgress(loading, completed, total);\n return row;\n });\n\n const createdTaskIds = created.map((row) => row.taskId);\n const createdInstanceIds = created\n .map((row) => row.instanceId)\n .filter((id): id is string => typeof id === 'string' && id.length > 0);\n\n if (created.some((row) => row.pinFailed)) {\n await this.toastWarning('warnings.pin-failed');\n }\n\n const [title, content] = await Promise.all([\n this.translationService.translateAsync(`${I18N}.success.title`),\n this.translationService.translateAsync(`${I18N}.success.description`),\n ]);\n this.toastService.show({ color: 'success', title, content, timeOut: 3000 });\n return { success: true, kind: 'object', data: { taskIds: createdTaskIds, instanceIds: createdInstanceIds } };\n } catch (error) {\n const message = error instanceof Error ? error.message : undefined;\n await this.toastError('errors.failed', message);\n return { success: false, message: { text: message ?? `${I18N}.errors.failed` } };\n } finally {\n loading.close();\n }\n }\n\n //#endregion\n\n //#region ----- Dialog -----\n\n private async openDialog(document: AXMDocumentDto): Promise<DistributeDialogResult | null> {\n const defaultTitle = asDisplayName(document.name) ?? asDisplayName(document.title) ?? '';\n const dueDate = new Date();\n dueDate.setHours(0, 0, 0, 0);\n const result = await this.layoutBuilder\n .create()\n .dialog<DistributeDialogResult | null>((dialog) => {\n dialog\n .setTitle(`${I18N}.dialog.title`)\n .setSize('md')\n .setCloseButton(true)\n .setContext({\n title: defaultTitle,\n description: '',\n dueDate,\n assigneeIds: [],\n })\n .content((flex) => {\n flex\n .setDirection('column')\n .setGap('12px')\n .formField(`${I18N}.fields.title`, (field) => {\n field.path('title');\n field.textBox({ validations: [{ rule: 'required' }] });\n })\n .formField(`${I18N}.fields.description`, (field) => {\n field.path('description');\n field.textBox({});\n })\n .formField(`${I18N}.fields.due-date`, (field) => {\n field.path('dueDate');\n field.dateTimeBox({ type: 'date', validations: [{ rule: 'required' }] });\n })\n .formField(`${I18N}.fields.assignees`, (field) => {\n field.path('assigneeIds');\n field.lookupBox({\n entity: 'SecurityManagement.User',\n multiple: true,\n look: 'lookup',\n validations: [{ rule: 'required' }],\n });\n });\n })\n .setActions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n actions.submit(`${I18N}.dialog.submit`);\n })\n .onAction(async (dialogRef) => {\n if (dialogRef.action() === 'cancel') {\n return null;\n }\n const ctx = dialogRef.context() as {\n title?: string;\n description?: string;\n dueDate?: Date | string | null;\n assigneeIds?: unknown;\n };\n const title = (ctx.title ?? '').trim();\n const assigneeIds = asUserIds(ctx.assigneeIds);\n if (!title) {\n throw new Error(`${I18N}.errors.title-required`);\n }\n if (!ctx.dueDate) {\n throw new Error(`${I18N}.errors.due-date-required`);\n }\n if (assigneeIds.length === 0) {\n throw new Error(`${I18N}.errors.assignees-required`);\n }\n dialogRef.setLoading(true);\n return {\n title,\n description: (ctx.description ?? '').trim() || undefined,\n dueDate: ctx.dueDate,\n assigneeIds,\n };\n });\n })\n .show();\n\n return resolveLayoutBuilderDialogResult<DistributeDialogResult>(result);\n }\n\n //#endregion\n\n //#region ----- Create per assignee -----\n\n private async createAndStartForAssignee(params: {\n userId: string;\n assignedBy: string;\n form: DistributeDialogResult;\n taskType: TaskTypeRow;\n openStatus: TaskStatusRow;\n signOffStatus: TaskStatusRow | undefined;\n completedStatus: TaskStatusRow | undefined;\n subjectRef: AXPEntityReference;\n document: AXMDocumentDto;\n versionId: string;\n documentDisplayName: string | undefined;\n workflowId: string;\n }): Promise<{ taskId: string; instanceId?: string; pinFailed: boolean }> {\n const createdTask = await this.taskData.create({\n title: params.form.title,\n description: params.form.description,\n taskTypeId: params.taskType.id,\n taskType: { id: params.taskType.id, title: params.taskType.title },\n statusId: params.openStatus.id,\n status: statusRef(params.openStatus),\n priority: 'medium',\n progress: 0,\n order: 0,\n startDate: params.form.dueDate,\n dueDate: params.form.dueDate,\n assigneeId: params.userId,\n assignee: { id: params.userId },\n subjectRef: params.subjectRef,\n isArchived: false,\n } as never);\n const taskId = resolveCreatedEntityId(createdTask);\n\n let pinFailed = false;\n const assignmentPromise = this.assignmentData.create({\n taskId,\n assignmentRef: {\n sourceKey: 'employee-user',\n refId: params.userId,\n displayName: params.userId,\n },\n role: 'reviewer',\n assignedBy: params.assignedBy,\n assignedAt: new Date(),\n isActive: true,\n } as never);\n\n const pinPromise = this.pinDocumentOnTask(taskId, params.document, params.documentDisplayName).catch((error) => {\n console.warn('[AXMDistributeDocumentCommand] pin document shortcut failed', error);\n pinFailed = true;\n });\n\n const [, , instanceId] = await Promise.all([\n assignmentPromise,\n pinPromise,\n this.startWorkflowForAssignee(taskId, params),\n ]);\n return { taskId, instanceId, pinFailed };\n }\n\n private async startWorkflowForAssignee(\n taskId: string,\n params: {\n userId: string;\n assignedBy: string;\n form: DistributeDialogResult;\n openStatus: TaskStatusRow;\n signOffStatus: TaskStatusRow | undefined;\n completedStatus: TaskStatusRow | undefined;\n document: AXMDocumentDto;\n versionId: string;\n workflowId: string;\n },\n ): Promise<string | undefined> {\n const startResult = await this.workflowManager.start(params.workflowId, {\n taskId,\n taskTitle: params.form.title,\n documentId: params.document.id,\n documentVersionId: params.versionId,\n signerUserId: params.userId,\n signerUserIds: [params.userId],\n initiatorUserId: params.assignedBy,\n openStatusId: params.openStatus.id,\n openStatus: statusRef(params.openStatus),\n signOffStatusId: params.signOffStatus?.id ?? params.openStatus.id,\n signOffStatus: statusRef(params.signOffStatus) ?? statusRef(params.openStatus),\n completedStatusId: params.completedStatus?.id ?? params.openStatus.id,\n completedStatus: statusRef(params.completedStatus) ?? statusRef(params.openStatus),\n correlationId: taskId,\n refId: taskId,\n refType: TASK_ENTITY_NAME,\n dueDate: params.form.dueDate,\n });\n\n if (!startResult.success) {\n throw new Error(startResult.error ?? 'workflow-failed');\n }\n\n if (startResult.instanceId) {\n try {\n await this.taskData.update(taskId, {\n workflowInfo: buildAXPRecordWorkflowInfo({\n instanceId: startResult.instanceId,\n definitionId: params.workflowId,\n correlationId: taskId,\n }),\n } as never);\n } catch (error) {\n console.warn('[AXMDistributeDocumentCommand] stamp workflowInfo failed', error);\n }\n }\n\n return startResult.instanceId;\n }\n\n //#endregion\n\n //#region ----- Pin document -----\n\n private async pinDocumentOnTask(\n taskId: string,\n document: AXMDocumentDto,\n nameOverride?: string,\n ): Promise<void> {\n const folder = await this.driveService.getRootByEntityRef(`${TASK_MODULE}.${TASK_ENTITY}`, taskId);\n const folderId = folder?.result?.id;\n if (!folderId) {\n throw new Error('Task document folder was not provisioned');\n }\n await this.driveService.createShortcut(document.id, 'file', folderId, {\n nameOverride: nameOverride ?? asDisplayName(document.name) ?? asDisplayName(document.title) ?? 'Document',\n });\n }\n\n //#endregion\n\n //#region ----- Data Loading -----\n\n private async loadDistributionSetup(): Promise<DistributionSetup | null> {\n const taskType = await this.loadDistributionTaskType();\n if (!taskType?.id) {\n return null;\n }\n const statuses = await this.loadStatuses(taskType.id);\n const openStatus = statuses.find((row) => row.isDefault) ?? statuses[0];\n const signOffStatus = statuses.find((row) => row.name === 'sign-off') ?? openStatus;\n const completedStatus = statuses.find((row) => row.isFinal) ?? signOffStatus;\n return {\n taskType,\n openStatus,\n signOffStatus,\n completedStatus,\n workflowId: taskType.workflowConfig?.workflowName?.trim() || DOCUMENT_DISTRIBUTION_WORKFLOW_NAME,\n };\n }\n\n private async loadDistributionTaskType(): Promise<TaskTypeRow | null> {\n try {\n const byId = await this.taskTypeData.byKey(MOCK_DOCUMENT_DISTRIBUTION_TASK_TYPE_ID);\n if (byId?.id) {\n return byId;\n }\n } catch {\n // hashed tenant copies use different ids\n }\n\n const result = await this.taskTypeData.query({ skip: 0, take: 200 });\n return (\n asItems<TaskTypeRow>(result).find(\n (row) => row.workflowConfig?.workflowName?.trim() === DOCUMENT_DISTRIBUTION_WORKFLOW_NAME,\n ) ?? null\n );\n }\n\n private async loadStatuses(taskTypeId: string): Promise<TaskStatusRow[]> {\n const result = await this.taskStatusData.query({\n skip: 0,\n take: 50,\n filter: { field: 'taskTypeId', operator: { type: 'equal' }, value: taskTypeId },\n });\n const rows = asItems<TaskStatusRow>(result);\n return rows.some((row) => row.taskTypeId === taskTypeId)\n ? rows.filter((row) => row.taskTypeId === taskTypeId)\n : rows;\n }\n\n private async showDistributeLoading(assigneeCount: number): Promise<LoadingDialogRef> {\n const [title, text] = await Promise.all([\n this.translationService.translateAsync(`${I18N}.loading.title`),\n this.translationService.translateAsync(`${I18N}.loading.description`, {\n params: { count: assigneeCount },\n }),\n ]);\n return this.loadingDialog.show({\n title,\n mode: 'indeterminate',\n progressColor: 'primary',\n text,\n }) as LoadingDialogRef;\n }\n\n private async updateDistributeLoadingProgress(\n loading: LoadingDialogRef,\n current: number,\n total: number,\n ): Promise<void> {\n if (!loading.setProgressText) {\n return;\n }\n const text = await this.translationService.translateAsync(`${I18N}.loading.progress`, {\n params: { current, total },\n });\n loading.setProgressText(text);\n }\n\n private async toastError(key: string, detail?: string): Promise<void> {\n const [title, fallback] = await Promise.all([\n this.translationService.translateAsync(`${I18N}.errors.title`),\n this.translationService.translateAsync(`${I18N}.${key}`),\n ]);\n this.toastService.show({\n color: 'danger',\n title,\n content: detail?.trim() || fallback,\n closeButton: true,\n timeOut: 5000,\n });\n }\n\n private async toastWarning(key: string): Promise<void> {\n const [title, content] = await Promise.all([\n this.translationService.translateAsync(`${I18N}.warnings.title`),\n this.translationService.translateAsync(`${I18N}.${key}`),\n ]);\n this.toastService.show({\n color: 'warning',\n title,\n content,\n closeButton: true,\n timeOut: 5000,\n });\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AAmFA;AAEA;AAEA,MAAM,WAAW,GAAG,gBAAgB;AACpC,MAAM,WAAW,GAAG,MAAM;AAC1B,MAAM,gBA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C;AACF,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;AACrB,YAAA,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,OAAO;AACP,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA,CAAC;IACJ;8GA3cW,4BAA4B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA5B,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,4BAA4B,cADf,MAAM,EAAA,CAAA,CAAA;;2FACnB,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBADxC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { resolveMultiLanguageString, coerceUnknownToMultiLanguageString } from '@acorex-platform/framework-shared/core';
|
|
2
|
+
|
|
3
|
+
//#region ----- Imports -----
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region ----- Helpers -----
|
|
6
|
+
function asTrimmedId(value) {
|
|
7
|
+
if (typeof value === 'string' && value.trim()) {
|
|
8
|
+
return value.trim();
|
|
9
|
+
}
|
|
10
|
+
if (value && typeof value === 'object' && 'id' in value) {
|
|
11
|
+
const id = value.id;
|
|
12
|
+
if (typeof id === 'string' && id.trim()) {
|
|
13
|
+
return id.trim();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
function asUserIds(value) {
|
|
19
|
+
if (value == null || value === '') {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const source = Array.isArray(value)
|
|
23
|
+
? value
|
|
24
|
+
: value && typeof value === 'object' && Array.isArray(value.selectedItems)
|
|
25
|
+
? (value.selectedItems)
|
|
26
|
+
: [value];
|
|
27
|
+
const ids = [];
|
|
28
|
+
for (const row of source) {
|
|
29
|
+
const id = asTrimmedId(row);
|
|
30
|
+
if (id && !ids.includes(id)) {
|
|
31
|
+
ids.push(id);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return ids;
|
|
35
|
+
}
|
|
36
|
+
function resolveCreatedEntityId(created) {
|
|
37
|
+
if (typeof created === 'string' && created.trim()) {
|
|
38
|
+
return created.trim();
|
|
39
|
+
}
|
|
40
|
+
if (created && typeof created === 'object' && 'result' in created) {
|
|
41
|
+
return resolveCreatedEntityId(created.result);
|
|
42
|
+
}
|
|
43
|
+
const id = asTrimmedId(created);
|
|
44
|
+
if (!id) {
|
|
45
|
+
throw new Error('Failed to resolve created entity id');
|
|
46
|
+
}
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
function isTruthyFlag(value) {
|
|
50
|
+
return value === true || value === 'true' || value === 1 || value === '1';
|
|
51
|
+
}
|
|
52
|
+
function asDisplayName(value) {
|
|
53
|
+
const resolved = resolveMultiLanguageString(coerceUnknownToMultiLanguageString(value), 'en-US').trim();
|
|
54
|
+
return resolved || undefined;
|
|
55
|
+
}
|
|
56
|
+
async function mapWithConcurrency(items, limit, mapper) {
|
|
57
|
+
if (items.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const results = new Array(items.length);
|
|
61
|
+
let nextIndex = 0;
|
|
62
|
+
const workerCount = Math.min(Math.max(1, limit), items.length);
|
|
63
|
+
await Promise.all(Array.from({ length: workerCount }, async () => {
|
|
64
|
+
for (;;) {
|
|
65
|
+
const index = nextIndex;
|
|
66
|
+
nextIndex += 1;
|
|
67
|
+
if (index >= items.length) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
results[index] = await mapper(items[index], index);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
|
|
77
|
+
export { asTrimmedId as a, asDisplayName as b, asUserIds as c, isTruthyFlag as i, mapWithConcurrency as m, resolveCreatedEntityId as r };
|
|
78
|
+
//# sourceMappingURL=acorex-platform-module-document-management-client-distribute-document.command.util-Bnw0rh94.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-document-management-client-distribute-document.command.util-Bnw0rh94.mjs","sources":["../../../../libs/modules/document-management/client/src/lib/features/commands/distribute-document.command.util.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { coerceUnknownToMultiLanguageString, resolveMultiLanguageString } from '@acorex-platform/framework-shared/core';\n\n//#endregion\n\n//#region ----- Helpers -----\n\nexport function asTrimmedId(value: unknown): string | undefined {\n if (typeof value === 'string' && value.trim()) {\n return value.trim();\n }\n if (value && typeof value === 'object' && 'id' in value) {\n const id = (value as { id?: unknown }).id;\n if (typeof id === 'string' && id.trim()) {\n return id.trim();\n }\n }\n return undefined;\n}\n\nexport function asUserIds(value: unknown): string[] {\n if (value == null || value === '') {\n return [];\n }\n const source = Array.isArray(value)\n ? value\n : value && typeof value === 'object' && Array.isArray((value as { selectedItems?: unknown }).selectedItems)\n ? ((value as { selectedItems: unknown[] }).selectedItems)\n : [value];\n const ids: string[] = [];\n for (const row of source) {\n const id = asTrimmedId(row);\n if (id && !ids.includes(id)) {\n ids.push(id);\n }\n }\n return ids;\n}\n\nexport function resolveCreatedEntityId(created: unknown): string {\n if (typeof created === 'string' && created.trim()) {\n return created.trim();\n }\n if (created && typeof created === 'object' && 'result' in created) {\n return resolveCreatedEntityId((created as { result: unknown }).result);\n }\n const id = asTrimmedId(created);\n if (!id) {\n throw new Error('Failed to resolve created entity id');\n }\n return id;\n}\n\nexport function isTruthyFlag(value: unknown): boolean {\n return value === true || value === 'true' || value === 1 || value === '1';\n}\n\nexport function asDisplayName(value: unknown): string | undefined {\n const resolved = resolveMultiLanguageString(coerceUnknownToMultiLanguageString(value), 'en-US').trim();\n return resolved || undefined;\n}\n\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n limit: number,\n mapper: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n if (items.length === 0) {\n return [];\n }\n const results: R[] = new Array(items.length);\n let nextIndex = 0;\n const workerCount = Math.min(Math.max(1, limit), items.length);\n await Promise.all(\n Array.from({ length: workerCount }, async () => {\n for (;;) {\n const index = nextIndex;\n nextIndex += 1;\n if (index >= items.length) {\n return;\n }\n results[index] = await mapper(items[index], index);\n }\n }),\n );\n return results;\n}\n\n//#endregion\n"],"names":[],"mappings":";;AAAA;AAIA;AAEA;AAEM,SAAU,WAAW,CAAC,KAAc,EAAA;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;AAC7C,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;IACA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,IAAI,KAAK,EAAE;AACvD,QAAA,MAAM,EAAE,GAAI,KAA0B,CAAC,EAAE;QACzC,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;AACvC,YAAA,OAAO,EAAE,CAAC,IAAI,EAAE;QAClB;IACF;AACA,IAAA,OAAO,SAAS;AAClB;AAEM,SAAU,SAAS,CAAC,KAAc,EAAA;IACtC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE;AACjC,QAAA,OAAO,EAAE;IACX;AACA,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK;AAChC,UAAE;AACF,UAAE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,KAAqC,CAAC,aAAa;AACxG,eAAI,KAAsC,CAAC,aAAa;AACxD,cAAE,CAAC,KAAK,CAAC;IACb,MAAM,GAAG,GAAa,EAAE;AACxB,IAAA,KAAK,MAA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