@things-factory/worklist 6.0.138 → 6.0.140

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/worklist",
3
- "version": "6.0.138",
3
+ "version": "6.0.140",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -33,10 +33,10 @@
33
33
  "@things-factory/auth-base": "^6.0.133",
34
34
  "@things-factory/board-service": "^6.0.133",
35
35
  "@things-factory/context-ui": "^6.0.133",
36
- "@things-factory/organization": "^6.0.138",
36
+ "@things-factory/organization": "^6.0.139",
37
37
  "@things-factory/scheduler-client": "^6.0.133",
38
38
  "@things-factory/shell": "^6.0.133",
39
39
  "moment-timezone": "^0.5.40"
40
40
  },
41
- "gitHead": "ca6c771a4c9f84e36f002665377ec919c0e11465"
41
+ "gitHead": "b7e0dde9f11e2fa1f7ab276221d936d77cdbb770"
42
42
  }
@@ -68,24 +68,6 @@ export async function draft(
68
68
  activityInstance.dueAt = new Date(Date.now() + activity.standardTime * 1000)
69
69
  }
70
70
 
71
- // if (activityInstance.assignees) {
72
- // activityInstance.assignees = activityInstance.assignees.map(assignee => {
73
- // return {
74
- // type: assignee.type,
75
- // value: assignee.value
76
- // }
77
- // })
78
- // }
79
-
80
- // if (activityInstance.approvalLine) {
81
- // activityInstance.approvalLine = activityInstance.approvalLine.map(approval => {
82
- // return {
83
- // type: approval.type,
84
- // value: approval.value
85
- // }
86
- // })
87
- // }
88
-
89
71
  const activitySearchKeys = fillActivitySearchKeys(activity?.searchKeys, input)
90
72
 
91
73
  return await tx.getRepository(ActivityInstance).save({
@@ -3,10 +3,77 @@ import { In } from 'typeorm'
3
3
 
4
4
  import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
5
5
  import { Application, CallbackBase, registerSchedule, unregisterSchedule } from '@things-factory/scheduler-client'
6
+ import { ApprovalLineItem, OrgMemberTargetType } from '@things-factory/organization'
6
7
 
7
- import { Activity } from './activity'
8
+ import { Activity, AssigneeItem } from './activity'
8
9
  import { ActivityPatch, NewActivity } from './activity-type'
9
10
 
11
+ function getApprovalLineValue(patch: NewActivity | ActivityPatch): ApprovalLineItem[] {
12
+ const { approvalLine } = patch
13
+
14
+ if (!('approvalLine' in patch)) {
15
+ /* approvalLine이 언급되지 않았다면, 업데이트하지 않는다. */
16
+ return
17
+ }
18
+
19
+ if (!approvalLine || !(approvalLine instanceof Array)) {
20
+ /* approvalLine의 값이 없거나 배열이 아니라면, 클리어시킨다. */
21
+ return null
22
+ }
23
+
24
+ return approvalLine
25
+ .map(m => {
26
+ return {
27
+ type: m.type,
28
+ approver: m.approver
29
+ } as ApprovalLineItem
30
+ })
31
+ .filter(m => m.type)
32
+ .filter(m => {
33
+ switch (m.type) {
34
+ case OrgMemberTargetType.Employee:
35
+ case OrgMemberTargetType.Department:
36
+ case OrgMemberTargetType.Role:
37
+ return !!m.approver?.id
38
+ default:
39
+ return true
40
+ }
41
+ })
42
+ }
43
+
44
+ function getAssigneesValue(patch: NewActivity | ActivityPatch): AssigneeItem[] {
45
+ const { assignees } = patch
46
+
47
+ if (!('assignees' in patch)) {
48
+ /* assignees이 언급되지 않았다면, 업데이트하지 않는다. */
49
+ return
50
+ }
51
+
52
+ if (!assignees || !(assignees instanceof Array)) {
53
+ /* assignees의 값이 없거나 배열이 아니라면, 클리어시킨다. */
54
+ return null
55
+ }
56
+
57
+ return assignees
58
+ .map(m => {
59
+ return {
60
+ type: m.type,
61
+ assignee: m.assignee
62
+ } as ApprovalLineItem
63
+ })
64
+ .filter(m => m.type)
65
+ .filter(m => {
66
+ switch (m.type) {
67
+ case OrgMemberTargetType.Employee:
68
+ case OrgMemberTargetType.Department:
69
+ case OrgMemberTargetType.Role:
70
+ return !!m.assignee?.id
71
+ default:
72
+ return true
73
+ }
74
+ })
75
+ }
76
+
10
77
  @Resolver(Activity)
11
78
  export class ActivityMutation {
12
79
  @Directive('@transaction')
@@ -17,6 +84,8 @@ export class ActivityMutation {
17
84
 
18
85
  const result = await tx.getRepository(Activity).save({
19
86
  ...activity,
87
+ assignees: getAssigneesValue(activity),
88
+ approvalLine: getApprovalLineValue(activity),
20
89
  domain,
21
90
  creator: user,
22
91
  updater: user
@@ -59,6 +128,8 @@ export class ActivityMutation {
59
128
  const result = await repository.save({
60
129
  ...activity,
61
130
  ...patch,
131
+ assignees: getAssigneesValue(activity),
132
+ approvalLine: getApprovalLineValue(activity),
62
133
  updater: user
63
134
  })
64
135
 
@@ -100,6 +171,8 @@ export class ActivityMutation {
100
171
 
101
172
  const result = await activityRepo.save({
102
173
  ...newRecord,
174
+ assignees: getAssigneesValue(newRecord),
175
+ approvalLine: getApprovalLineValue(newRecord),
103
176
  domain,
104
177
  creator: user,
105
178
  updater: user
@@ -135,6 +208,8 @@ export class ActivityMutation {
135
208
  const result = await activityRepo.save({
136
209
  ...activity,
137
210
  ...updateRecord,
211
+ assignees: getAssigneesValue(updateRecord),
212
+ approvalLine: getApprovalLineValue(updateRecord),
138
213
  updater: user
139
214
  })
140
215
 
@@ -168,7 +168,7 @@ export class ActivityQuery {
168
168
  default:
169
169
  }
170
170
 
171
- assignee && assigneeItemList.push({ type, value: id, assignee })
171
+ id ? assigneeItemList.push({ type, assignee }) : assigneeItemList.push({ type })
172
172
  }
173
173
 
174
174
  return assigneeItemList