@things-factory/worklist 6.0.8 → 6.0.12
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/client/pages/activity-approval/activity-approval-importer.ts +97 -0
- package/client/pages/activity-approval/activity-approval-list-page.ts +348 -0
- package/client/pages/activity-approval/activity-approval-page.ts +418 -0
- package/client/pages/activity-thread/activity-thread-page.ts +5 -5
- package/client/pages/todo/approval-waiting-list-page.ts +376 -0
- package/client/route.ts +12 -0
- package/dist-client/pages/activity-approval/activity-approval-importer.d.ts +22 -0
- package/dist-client/pages/activity-approval/activity-approval-importer.js +100 -0
- package/dist-client/pages/activity-approval/activity-approval-importer.js.map +1 -0
- package/dist-client/pages/activity-approval/activity-approval-list-page.d.ts +62 -0
- package/dist-client/pages/activity-approval/activity-approval-list-page.js +326 -0
- package/dist-client/pages/activity-approval/activity-approval-list-page.js.map +1 -0
- package/dist-client/pages/activity-approval/activity-approval-page.d.ts +55 -0
- package/dist-client/pages/activity-approval/activity-approval-page.js +365 -0
- package/dist-client/pages/activity-approval/activity-approval-page.js.map +1 -0
- package/dist-client/pages/activity-thread/activity-thread-page.d.ts +1 -1
- package/dist-client/pages/activity-thread/activity-thread-page.js +4 -4
- package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
- package/dist-client/pages/todo/approval-waiting-list-page.d.ts +45 -0
- package/dist-client/pages/todo/approval-waiting-list-page.js +371 -0
- package/dist-client/pages/todo/approval-waiting-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +9 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/activity-approval/abort.js +20 -0
- package/dist-server/controllers/activity-approval/abort.js.map +1 -0
- package/dist-server/controllers/activity-approval/approve.js +50 -0
- package/dist-server/controllers/activity-approval/approve.js.map +1 -0
- package/dist-server/controllers/activity-approval/delegate.js +20 -0
- package/dist-server/controllers/activity-approval/delegate.js.map +1 -0
- package/dist-server/controllers/activity-approval/escalate.js +20 -0
- package/dist-server/controllers/activity-approval/escalate.js.map +1 -0
- package/dist-server/controllers/activity-approval/reject.js +21 -0
- package/dist-server/controllers/activity-approval/reject.js.map +1 -0
- package/dist-server/controllers/activity-instance/abort.js +2 -3
- package/dist-server/controllers/activity-instance/abort.js.map +1 -1
- package/dist-server/controllers/activity-instance/delegate.js +2 -3
- package/dist-server/controllers/activity-instance/delegate.js.map +1 -1
- package/dist-server/controllers/activity-instance/draft.js +1 -2
- package/dist-server/controllers/activity-instance/draft.js.map +1 -1
- package/dist-server/controllers/activity-instance/end.js +2 -3
- package/dist-server/controllers/activity-instance/end.js.map +1 -1
- package/dist-server/controllers/activity-instance/pick.js +2 -3
- package/dist-server/controllers/activity-instance/pick.js.map +1 -1
- package/dist-server/controllers/activity-instance/terminate.js +2 -3
- package/dist-server/controllers/activity-instance/terminate.js.map +1 -1
- package/dist-server/controllers/activity-thread/abort.js +2 -3
- package/dist-server/controllers/activity-thread/abort.js.map +1 -1
- package/dist-server/controllers/activity-thread/delegate.js +2 -3
- package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
- package/dist-server/controllers/activity-thread/end.js +2 -3
- package/dist-server/controllers/activity-thread/end.js.map +1 -1
- package/dist-server/controllers/activity-thread/index.js +1 -0
- package/dist-server/controllers/activity-thread/index.js.map +1 -1
- package/dist-server/controllers/activity-thread/submit.js +46 -0
- package/dist-server/controllers/activity-thread/submit.js.map +1 -0
- package/dist-server/controllers/activity-thread/terminate.js +2 -3
- package/dist-server/controllers/activity-thread/terminate.js.map +1 -1
- package/dist-server/controllers/common.js +24 -1
- package/dist-server/controllers/common.js.map +1 -1
- package/dist-server/service/activity/activity-query.js +1 -1
- package/dist-server/service/activity/activity-query.js.map +1 -1
- package/dist-server/service/activity-approval/activity-approval-mutation.js +79 -0
- package/dist-server/service/activity-approval/activity-approval-mutation.js.map +1 -0
- package/dist-server/service/activity-approval/activity-approval-query.js +128 -0
- package/dist-server/service/activity-approval/activity-approval-query.js.map +1 -0
- package/dist-server/service/activity-approval/activity-approval-type.js +39 -0
- package/dist-server/service/activity-approval/activity-approval-type.js.map +1 -0
- package/dist-server/service/activity-approval/activity-approval.js +135 -0
- package/dist-server/service/activity-approval/activity-approval.js.map +1 -0
- package/dist-server/service/activity-approval/event-subscriber.js +29 -0
- package/dist-server/service/activity-approval/event-subscriber.js.map +1 -0
- package/dist-server/service/activity-approval/index.js +11 -0
- package/dist-server/service/activity-approval/index.js.map +1 -0
- package/dist-server/service/activity-instance/activity-instance-query.js +1 -1
- package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
- package/dist-server/service/activity-template/activity-template-query.js +1 -1
- package/dist-server/service/activity-template/activity-template-query.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-mutation.js +14 -0
- package/dist-server/service/activity-thread/activity-thread-mutation.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-query.js +7 -2
- package/dist-server/service/activity-thread/activity-thread-query.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-type.js +1 -23
- package/dist-server/service/activity-thread/activity-thread-type.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread.js +31 -2
- package/dist-server/service/activity-thread/activity-thread.js.map +1 -1
- package/dist-server/service/index.js +5 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/worklist/activity-approval.md +160 -0
- package/package.json +7 -7
- package/server/controllers/activity-approval/abort.ts +33 -0
- package/server/controllers/activity-approval/approve.ts +80 -0
- package/server/controllers/activity-approval/delegate.ts +33 -0
- package/server/controllers/activity-approval/escalate.ts +33 -0
- package/server/controllers/activity-approval/reject.ts +35 -0
- package/server/controllers/activity-instance/abort.ts +2 -4
- package/server/controllers/activity-instance/delegate.ts +2 -4
- package/server/controllers/activity-instance/draft.ts +1 -3
- package/server/controllers/activity-instance/end.ts +2 -4
- package/server/controllers/activity-instance/pick.ts +2 -4
- package/server/controllers/activity-instance/terminate.ts +2 -4
- package/server/controllers/activity-thread/abort.ts +2 -4
- package/server/controllers/activity-thread/delegate.ts +2 -4
- package/server/controllers/activity-thread/end.ts +2 -4
- package/server/controllers/activity-thread/index.ts +1 -0
- package/server/controllers/activity-thread/submit.ts +71 -0
- package/server/controllers/activity-thread/terminate.ts +2 -4
- package/server/controllers/common.ts +28 -0
- package/server/service/activity/activity-query.ts +1 -1
- package/server/service/activity-approval/activity-approval-mutation.ts +71 -0
- package/server/service/activity-approval/activity-approval-query.ts +90 -0
- package/server/service/activity-approval/activity-approval-type.ts +28 -0
- package/server/service/activity-approval/activity-approval.ts +118 -0
- package/server/service/activity-approval/event-subscriber.ts +28 -0
- package/server/service/activity-approval/index.ts +8 -0
- package/server/service/activity-instance/activity-instance-query.ts +1 -1
- package/server/service/activity-template/activity-template-query.ts +1 -1
- package/server/service/activity-thread/activity-thread-mutation.ts +12 -1
- package/server/service/activity-thread/activity-thread-query.ts +7 -2
- package/server/service/activity-thread/activity-thread-type.ts +1 -15
- package/server/service/activity-thread/activity-thread.ts +24 -0
- package/server/service/index.ts +5 -0
- package/things-factory.config.js +4 -1
- package/translations/en.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +4 -1
- package/translations/zh.json +3 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
|
|
2
|
+
import { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'
|
|
3
|
+
import { getSystemUserFromApprovalLineItem, updateActivityInstanceState } from '../common'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { Department, Employee, ApprovalLineItem, ApprovalLineItemType } from '@things-factory/organization'
|
|
6
|
+
|
|
7
|
+
export async function submit(
|
|
8
|
+
{ id, output, reason }: { id: string; output?: object; reason?: string },
|
|
9
|
+
context: any
|
|
10
|
+
): Promise<ActivityThread> {
|
|
11
|
+
const { domain, user, tx } = context.state
|
|
12
|
+
|
|
13
|
+
const repository = tx.getRepository(ActivityThread)
|
|
14
|
+
|
|
15
|
+
var activityThread = await repository.findOne({
|
|
16
|
+
where: { domain: { id: domain.id }, id },
|
|
17
|
+
relations: ['domain', 'activityInstance', 'assignee', 'creator', 'updater']
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
if (!activityThread) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
context.t('error.activity-thread not found', {
|
|
23
|
+
activityThread: id
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const approvalLine: ApprovalLineItem[] = activityThread.activityInstance.approvalLine
|
|
29
|
+
|
|
30
|
+
if (approvalLine && approvalLine.length > 0) {
|
|
31
|
+
var approverUser = await getSystemUserFromApprovalLineItem(approvalLine[0], context)
|
|
32
|
+
|
|
33
|
+
if (!approverUser) {
|
|
34
|
+
throw 'Cannot specify the approval user for this approval line'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
await tx.getRepository(ActivityApproval).save({
|
|
38
|
+
domain,
|
|
39
|
+
activityThread,
|
|
40
|
+
order: 1,
|
|
41
|
+
judgment: ActivityApprovalJudgment.Pending,
|
|
42
|
+
transaction: 'submit',
|
|
43
|
+
approver: approverUser,
|
|
44
|
+
creator: user,
|
|
45
|
+
updater: user
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
var result = await repository.save({
|
|
49
|
+
...activityThread,
|
|
50
|
+
reason,
|
|
51
|
+
output,
|
|
52
|
+
transaction: 'submit',
|
|
53
|
+
state: ActivityThreadStatus.Submitted,
|
|
54
|
+
updater: user
|
|
55
|
+
})
|
|
56
|
+
} else {
|
|
57
|
+
var result = await repository.save({
|
|
58
|
+
...activityThread,
|
|
59
|
+
reason,
|
|
60
|
+
output,
|
|
61
|
+
transaction: 'end',
|
|
62
|
+
state: ActivityThreadStatus.Ended,
|
|
63
|
+
updater: user,
|
|
64
|
+
terminatedAt: new Date()
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await updateActivityInstanceState(activityThread.activityInstanceId, context)
|
|
69
|
+
|
|
70
|
+
return result
|
|
71
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
1
|
import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
|
|
4
2
|
import { updateActivityInstanceState } from '../common'
|
|
5
3
|
|
|
@@ -8,7 +6,7 @@ export async function terminate(
|
|
|
8
6
|
context: any
|
|
9
7
|
): Promise<ActivityThread> {
|
|
10
8
|
const { domain, user, tx } = context.state
|
|
11
|
-
var repository = getRepository(ActivityThread)
|
|
9
|
+
var repository = tx.getRepository(ActivityThread)
|
|
12
10
|
|
|
13
11
|
var activityThread = await repository.findOne({
|
|
14
12
|
where: { domain: { id: domain.id }, id },
|
|
@@ -23,7 +21,7 @@ export async function terminate(
|
|
|
23
21
|
)
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
const result = await
|
|
24
|
+
const result = await repository.save({
|
|
27
25
|
...activityThread,
|
|
28
26
|
reason,
|
|
29
27
|
output,
|
|
@@ -2,6 +2,7 @@ import { Role, User } from '@things-factory/auth-base'
|
|
|
2
2
|
|
|
3
3
|
import { ActivityInstance, ActivityInstanceStatus } from '../service/activity-instance/activity-instance'
|
|
4
4
|
import { ActivityThread, ActivityThreadStatus } from '../service/activity-thread/activity-thread'
|
|
5
|
+
import { Department, Employee, ApprovalLineItem, ApprovalLineItemType } from '@things-factory/organization'
|
|
5
6
|
|
|
6
7
|
export async function updateActivityInstanceState(id: string, context: ResolverContext) {
|
|
7
8
|
const { tx } = context.state
|
|
@@ -109,3 +110,30 @@ export async function createActivityThreadsForAllRoleUsers(
|
|
|
109
110
|
// create activity-thread for all of users having given role
|
|
110
111
|
return await createActivityThreadsForUsers(transaction, activityInstance, assignees, context)
|
|
111
112
|
}
|
|
113
|
+
|
|
114
|
+
export async function getSystemUserFromApprovalLineItem(
|
|
115
|
+
approvalLineItem: ApprovalLineItem,
|
|
116
|
+
context: any
|
|
117
|
+
): Promise<User> {
|
|
118
|
+
const { domain, user, tx } = context.state
|
|
119
|
+
|
|
120
|
+
const { type, value, approver } = approvalLineItem
|
|
121
|
+
const { id: approverId, name, description, controlNo } = approver
|
|
122
|
+
|
|
123
|
+
if (type == ApprovalLineItemType.Employee) {
|
|
124
|
+
const employee = await tx.getRepository(Employee).findOne({ where: { id: approverId }, relations: ['user'] })
|
|
125
|
+
|
|
126
|
+
if (!employee || !employee.user) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
return employee.user
|
|
130
|
+
} else if (type == ApprovalLineItemType.Department) {
|
|
131
|
+
const department = await tx.getRepository(Department).findOne({ where: { id: approverId }, relations: ['manager'] })
|
|
132
|
+
|
|
133
|
+
if (!department || !department.manager) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
return await tx.getRepository(User).findOneBy({ id: department.manager.userId })
|
|
137
|
+
} else if (type == ApprovalLineItemType.Role) {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -35,7 +35,7 @@ export class ActivityQuery {
|
|
|
35
35
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
36
36
|
domain,
|
|
37
37
|
params,
|
|
38
|
-
repository:
|
|
38
|
+
repository: getRepository(Activity),
|
|
39
39
|
alias: 'activity',
|
|
40
40
|
searchables: ['name', 'description', 'issuerRole', 'assigneeRole', 'supervisoryRole']
|
|
41
41
|
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { ActivityApproval, ActivityApprovalJudgment } from './activity-approval'
|
|
4
|
+
import { abort } from '../../controllers/activity-approval/abort'
|
|
5
|
+
import { reject } from '../../controllers/activity-approval/reject'
|
|
6
|
+
import { approve } from '../../controllers/activity-approval/approve'
|
|
7
|
+
|
|
8
|
+
@Resolver(ActivityApproval)
|
|
9
|
+
export class ActivityApprovalMutation {
|
|
10
|
+
/* transactions ... */
|
|
11
|
+
|
|
12
|
+
@Directive('@transaction')
|
|
13
|
+
@Mutation(returns => ActivityApproval!, { nullable: true, description: 'To approve ActivityApproval' })
|
|
14
|
+
async saveActivityApproval(
|
|
15
|
+
@Arg('id') id: string,
|
|
16
|
+
@Arg('comment', { nullable: true }) comment: string,
|
|
17
|
+
@Ctx() context: ResolverContext
|
|
18
|
+
): Promise<ActivityApproval> {
|
|
19
|
+
const { domain, user, tx } = context.state
|
|
20
|
+
|
|
21
|
+
var repository = tx.getRepository(ActivityApproval)
|
|
22
|
+
|
|
23
|
+
var activityApproval = await repository.findOne({
|
|
24
|
+
where: { domain: { id: domain.id }, id }
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (!activityApproval) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
context.t('error.activity-approval not found', {
|
|
30
|
+
activityApproval: id
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return await repository.save({
|
|
36
|
+
...activityApproval,
|
|
37
|
+
comment,
|
|
38
|
+
updater: user
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Directive('@transaction')
|
|
43
|
+
@Mutation(returns => ActivityApproval!, { nullable: true, description: 'To approve ActivityApproval' })
|
|
44
|
+
async approveActivityApproval(
|
|
45
|
+
@Arg('id') id: string,
|
|
46
|
+
@Arg('comment', { nullable: true }) comment: string,
|
|
47
|
+
@Ctx() context: ResolverContext
|
|
48
|
+
): Promise<ActivityApproval> {
|
|
49
|
+
return await approve({ id, comment }, context)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Directive('@transaction')
|
|
53
|
+
@Mutation(returns => ActivityApproval!, { nullable: true, description: 'To reject ActivityApproval' })
|
|
54
|
+
async rejectActivityApproval(
|
|
55
|
+
@Arg('id') id: string,
|
|
56
|
+
@Arg('comment', { nullable: true }) comment: string,
|
|
57
|
+
@Ctx() context: ResolverContext
|
|
58
|
+
): Promise<ActivityApproval> {
|
|
59
|
+
return await reject({ id, comment }, context)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Directive('@transaction')
|
|
63
|
+
@Mutation(returns => ActivityApproval!, { nullable: true, description: 'To abort ActivityApproval' })
|
|
64
|
+
async abortActivityApproval(
|
|
65
|
+
@Arg('id') id: string,
|
|
66
|
+
@Arg('comment', { nullable: true }) comment: string,
|
|
67
|
+
@Ctx() context: ResolverContext
|
|
68
|
+
): Promise<ActivityApproval> {
|
|
69
|
+
return await abort({ id, comment }, context)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { ActivityInstance } from '../activity-instance/activity-instance'
|
|
5
|
+
import { ActivityThread } from '../activity-thread/activity-thread'
|
|
6
|
+
import { ActivityApproval, ActivityApprovalJudgment } from './activity-approval'
|
|
7
|
+
import { ActivityApprovalList } from './activity-approval-type'
|
|
8
|
+
|
|
9
|
+
@Resolver(ActivityApproval)
|
|
10
|
+
export class ActivityApprovalQuery {
|
|
11
|
+
@Query(returns => ActivityApproval!, { nullable: true, description: 'To fetch a ActivityApproval' })
|
|
12
|
+
async activityApproval(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActivityApproval> {
|
|
13
|
+
const { domain } = context.state
|
|
14
|
+
|
|
15
|
+
return await getRepository(ActivityApproval).findOne({
|
|
16
|
+
where: { domain: { id: domain.id }, id }
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Query(returns => ActivityApprovalList, { description: 'To fetch multiple ActivityApprovals' })
|
|
21
|
+
async activityApprovals(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityApprovalList> {
|
|
22
|
+
const { domain } = context.state
|
|
23
|
+
|
|
24
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
25
|
+
domain,
|
|
26
|
+
params,
|
|
27
|
+
repository: getRepository(ActivityApproval),
|
|
28
|
+
searchables: ['name', 'description']
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
32
|
+
|
|
33
|
+
return { items, total }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Query(returns => ActivityApprovalList, { description: 'To fetch my own ActivityApprovals' })
|
|
37
|
+
async approvalWaitingList(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityApprovalList> {
|
|
38
|
+
var { domain, user } = context.state
|
|
39
|
+
|
|
40
|
+
const judgment = [
|
|
41
|
+
ActivityApprovalJudgment.Escalated,
|
|
42
|
+
ActivityApprovalJudgment.Delegated,
|
|
43
|
+
ActivityApprovalJudgment.Approved,
|
|
44
|
+
ActivityApprovalJudgment.Rejected
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
const [items, total] = await getQueryBuilderFromListParams({
|
|
48
|
+
repository: getRepository(ActivityApproval),
|
|
49
|
+
params,
|
|
50
|
+
domain,
|
|
51
|
+
alias: 'ap',
|
|
52
|
+
searchables: ['name', 'description'],
|
|
53
|
+
filtersMap: {
|
|
54
|
+
name: {
|
|
55
|
+
relationColumn: 'activityThread.activityInstance',
|
|
56
|
+
columnName: 'name'
|
|
57
|
+
},
|
|
58
|
+
description: {
|
|
59
|
+
relationColumn: 'activityThread.activityInstance',
|
|
60
|
+
columnName: 'description'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.andWhere('ap.judgment NOT IN (:...judgment)', { judgment })
|
|
65
|
+
.andWhere('ap.approver = :user', { user: user.id })
|
|
66
|
+
.getManyAndCount()
|
|
67
|
+
|
|
68
|
+
return { items, total }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@FieldResolver(type => ActivityThread)
|
|
72
|
+
async activityThread(@Root() activityApproval: ActivityApproval): Promise<ActivityThread> {
|
|
73
|
+
return await getRepository(ActivityThread).findOneBy({ id: activityApproval.activityThreadId })
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@FieldResolver(type => Domain)
|
|
77
|
+
async domain(@Root() activityApproval: ActivityApproval): Promise<Domain> {
|
|
78
|
+
return await getRepository(Domain).findOneBy({ id: activityApproval.domainId })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@FieldResolver(type => User)
|
|
82
|
+
async updater(@Root() activityApproval: ActivityApproval): Promise<User> {
|
|
83
|
+
return await getRepository(User).findOneBy({ id: activityApproval.updaterId })
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@FieldResolver(type => User)
|
|
87
|
+
async creator(@Root() activityApproval: ActivityApproval): Promise<User> {
|
|
88
|
+
return await getRepository(User).findOneBy({ id: activityApproval.creatorId })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
+
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
+
|
|
5
|
+
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { ActivityApproval, ActivityApprovalJudgment } from './activity-approval'
|
|
8
|
+
|
|
9
|
+
@InputType()
|
|
10
|
+
export class ActivityApprovalPatch {
|
|
11
|
+
@Field(type => ID, { nullable: true })
|
|
12
|
+
id?: string
|
|
13
|
+
|
|
14
|
+
@Field({ nullable: true })
|
|
15
|
+
judgment?: ActivityApprovalJudgment
|
|
16
|
+
|
|
17
|
+
@Field({ nullable: true })
|
|
18
|
+
comment?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@ObjectType()
|
|
22
|
+
export class ActivityApprovalList {
|
|
23
|
+
@Field(type => [ActivityApproval])
|
|
24
|
+
items: ActivityApproval[]
|
|
25
|
+
|
|
26
|
+
@Field(type => Int)
|
|
27
|
+
total: number
|
|
28
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
Index,
|
|
6
|
+
Column,
|
|
7
|
+
RelationId,
|
|
8
|
+
ManyToOne,
|
|
9
|
+
PrimaryGeneratedColumn
|
|
10
|
+
} from 'typeorm'
|
|
11
|
+
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
12
|
+
|
|
13
|
+
import { Domain } from '@things-factory/shell'
|
|
14
|
+
import { User } from '@things-factory/auth-base'
|
|
15
|
+
import { ActivityThread } from '../activity-thread/activity-thread'
|
|
16
|
+
|
|
17
|
+
export enum ActivityApprovalJudgment {
|
|
18
|
+
Pending = '',
|
|
19
|
+
Rejected = 'rejected',
|
|
20
|
+
Escalated = 'escalated',
|
|
21
|
+
Delegated = 'delegated',
|
|
22
|
+
Approved = 'approved',
|
|
23
|
+
Aborted = 'aborted'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
registerEnumType(ActivityApprovalJudgment, {
|
|
27
|
+
name: 'ActivityApprovalJudgment',
|
|
28
|
+
description: 'judgment enumeration of a activityApproval'
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
@Entity()
|
|
32
|
+
@Index(
|
|
33
|
+
'ix_activity_approval_0',
|
|
34
|
+
(activityApproval: ActivityApproval) => [
|
|
35
|
+
activityApproval.domain,
|
|
36
|
+
activityApproval.activityThread,
|
|
37
|
+
activityApproval.order,
|
|
38
|
+
activityApproval.approver,
|
|
39
|
+
activityApproval.createdAt
|
|
40
|
+
],
|
|
41
|
+
{ unique: true }
|
|
42
|
+
)
|
|
43
|
+
@ObjectType({ description: 'Entity for ActivityApproval' })
|
|
44
|
+
export class ActivityApproval {
|
|
45
|
+
@PrimaryGeneratedColumn('uuid')
|
|
46
|
+
@Field(type => ID)
|
|
47
|
+
readonly id: string
|
|
48
|
+
|
|
49
|
+
@ManyToOne(type => Domain)
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
domain?: Domain
|
|
52
|
+
|
|
53
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.domain)
|
|
54
|
+
domainId?: string
|
|
55
|
+
|
|
56
|
+
@ManyToOne(type => ActivityThread, { nullable: true })
|
|
57
|
+
@Field(type => ActivityThread, { nullable: true })
|
|
58
|
+
activityThread?: ActivityThread
|
|
59
|
+
|
|
60
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.activityThread)
|
|
61
|
+
activityThreadId?: string
|
|
62
|
+
|
|
63
|
+
@Column({ nullable: true, default: 0 })
|
|
64
|
+
@Field({ nullable: true, description: 'Nth order approval for given activity thread' })
|
|
65
|
+
order?: number = 0
|
|
66
|
+
|
|
67
|
+
@ManyToOne(type => User, { nullable: true })
|
|
68
|
+
@Field(type => User, { nullable: true })
|
|
69
|
+
approver?: User
|
|
70
|
+
|
|
71
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.approver)
|
|
72
|
+
approverId?: string
|
|
73
|
+
|
|
74
|
+
@Column({ nullable: true, default: '' })
|
|
75
|
+
@Field({ nullable: true })
|
|
76
|
+
judgment?: ActivityApprovalJudgment = ActivityApprovalJudgment.Pending
|
|
77
|
+
|
|
78
|
+
@Column({ nullable: true })
|
|
79
|
+
@Field({ nullable: true })
|
|
80
|
+
comment?: string
|
|
81
|
+
|
|
82
|
+
@Column({ nullable: true })
|
|
83
|
+
@Field({ nullable: true })
|
|
84
|
+
transaction?: string
|
|
85
|
+
|
|
86
|
+
@CreateDateColumn()
|
|
87
|
+
@Field({ nullable: true })
|
|
88
|
+
createdAt?: Date
|
|
89
|
+
|
|
90
|
+
@UpdateDateColumn()
|
|
91
|
+
@Field({ nullable: true })
|
|
92
|
+
updatedAt?: Date
|
|
93
|
+
|
|
94
|
+
@Column({ nullable: true })
|
|
95
|
+
@Field({ nullable: true })
|
|
96
|
+
terminatedAt?: Date
|
|
97
|
+
|
|
98
|
+
@ManyToOne(type => User, { nullable: true })
|
|
99
|
+
@Field(type => User, { nullable: true })
|
|
100
|
+
creator?: User
|
|
101
|
+
|
|
102
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.creator)
|
|
103
|
+
creatorId?: string
|
|
104
|
+
|
|
105
|
+
@ManyToOne(type => User, { nullable: true })
|
|
106
|
+
@Field(type => User, { nullable: true })
|
|
107
|
+
updater?: User
|
|
108
|
+
|
|
109
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.updater)
|
|
110
|
+
updaterId?: string
|
|
111
|
+
|
|
112
|
+
@ManyToOne(type => User, { nullable: true })
|
|
113
|
+
@Field({ nullable: true })
|
|
114
|
+
terminator?: User
|
|
115
|
+
|
|
116
|
+
@RelationId((activityApproval: ActivityApproval) => activityApproval.terminator)
|
|
117
|
+
terminatorId?: string
|
|
118
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { pubsub } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
import { ActivityApproval } from './activity-approval'
|
|
6
|
+
|
|
7
|
+
@EventSubscriber()
|
|
8
|
+
export class ActivityApprovalSubscriber implements EntitySubscriberInterface<ActivityApproval> {
|
|
9
|
+
listenTo() {
|
|
10
|
+
return ActivityApproval
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
afterInsert(event: InsertEvent<ActivityApproval>): Promise<any> | void {
|
|
14
|
+
const activityApproval = event.entity
|
|
15
|
+
|
|
16
|
+
pubsub.publish('activity-approval', {
|
|
17
|
+
activityApproval
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
afterUpdate(event: UpdateEvent<ActivityApproval>): Promise<any> | void {
|
|
22
|
+
const activityApproval = event.entity
|
|
23
|
+
|
|
24
|
+
pubsub.publish('activity-approval', {
|
|
25
|
+
activityApproval
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActivityApproval } from './activity-approval'
|
|
2
|
+
import { ActivityApprovalQuery } from './activity-approval-query'
|
|
3
|
+
import { ActivityApprovalMutation } from './activity-approval-mutation'
|
|
4
|
+
import { ActivityApprovalSubscriber } from './event-subscriber'
|
|
5
|
+
|
|
6
|
+
export const entities = [ActivityApproval]
|
|
7
|
+
export const resolvers = [ActivityApprovalQuery, ActivityApprovalMutation]
|
|
8
|
+
export const subscribers = [ActivityApprovalSubscriber]
|
|
@@ -27,7 +27,7 @@ export class ActivityInstanceQuery {
|
|
|
27
27
|
const [items, total] = await getQueryBuilderFromListParams({
|
|
28
28
|
domain,
|
|
29
29
|
params,
|
|
30
|
-
repository:
|
|
30
|
+
repository: getRepository(ActivityInstance),
|
|
31
31
|
searchables: ['name', 'description']
|
|
32
32
|
}).getManyAndCount()
|
|
33
33
|
|
|
@@ -26,7 +26,7 @@ export class ActivityTemplateQuery {
|
|
|
26
26
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
27
27
|
domain,
|
|
28
28
|
params,
|
|
29
|
-
repository:
|
|
29
|
+
repository: getRepository(ActivityTemplate),
|
|
30
30
|
searchables: ['name', 'description']
|
|
31
31
|
})
|
|
32
32
|
|
|
@@ -3,7 +3,7 @@ import { In } from 'typeorm'
|
|
|
3
3
|
|
|
4
4
|
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
5
5
|
|
|
6
|
-
import { abort, delegate, end, save as saveActivityThread, start } from '../../controllers/activity-thread'
|
|
6
|
+
import { abort, delegate, end, save as saveActivityThread, start, submit } from '../../controllers/activity-thread'
|
|
7
7
|
import { ActivityThread } from './activity-thread'
|
|
8
8
|
import { ActivityThreadSave } from './activity-thread-type'
|
|
9
9
|
|
|
@@ -55,6 +55,17 @@ export class ActivityThreadMutation {
|
|
|
55
55
|
return await end({ id, output, reason }, context)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
@Directive('@transaction')
|
|
59
|
+
@Mutation(returns => ActivityThread, { description: 'To submit a ActivityThread' })
|
|
60
|
+
async submitActivityThread(
|
|
61
|
+
@Arg('id') id: string,
|
|
62
|
+
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
63
|
+
@Arg('reason', { nullable: true }) reason: string,
|
|
64
|
+
@Ctx() context: ResolverContext
|
|
65
|
+
): Promise<ActivityThread> {
|
|
66
|
+
return await submit({ id, output, reason }, context)
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
@Directive('@transaction')
|
|
59
70
|
@Mutation(returns => ActivityThread, { description: 'To abort a ActivityThread' })
|
|
60
71
|
async abortActivityThread(
|
|
@@ -25,7 +25,7 @@ export class ActivityThreadQuery {
|
|
|
25
25
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
26
26
|
domain,
|
|
27
27
|
params,
|
|
28
|
-
repository:
|
|
28
|
+
repository: getRepository(ActivityThread),
|
|
29
29
|
searchables: ['name', 'description']
|
|
30
30
|
})
|
|
31
31
|
|
|
@@ -38,7 +38,12 @@ export class ActivityThreadQuery {
|
|
|
38
38
|
async todoList(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityThreadList> {
|
|
39
39
|
var { domain, user } = context.state
|
|
40
40
|
|
|
41
|
-
const status = [
|
|
41
|
+
const status = [
|
|
42
|
+
ActivityThreadStatus.Assigned,
|
|
43
|
+
ActivityThreadStatus.Started,
|
|
44
|
+
ActivityThreadStatus.Submitted,
|
|
45
|
+
ActivityThreadStatus.Rejected
|
|
46
|
+
]
|
|
42
47
|
|
|
43
48
|
const [items, total] = await getQueryBuilderFromListParams({
|
|
44
49
|
repository: getRepository(ActivityThread),
|
|
@@ -3,18 +3,7 @@ import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
|
3
3
|
import { ScalarObject } from '@things-factory/shell'
|
|
4
4
|
|
|
5
5
|
import { ActivityThread, ActivityThreadStatus } from './activity-thread'
|
|
6
|
-
|
|
7
|
-
@InputType()
|
|
8
|
-
export class NewActivityThread {
|
|
9
|
-
@Field({ nullable: true })
|
|
10
|
-
state?: ActivityThreadStatus
|
|
11
|
-
|
|
12
|
-
@Field({ nullable: true })
|
|
13
|
-
active?: boolean
|
|
14
|
-
|
|
15
|
-
@Field({ nullable: true })
|
|
16
|
-
params?: string
|
|
17
|
-
}
|
|
6
|
+
import { User } from '@things-factory/auth-base'
|
|
18
7
|
|
|
19
8
|
@InputType()
|
|
20
9
|
export class ActivityThreadPatch {
|
|
@@ -26,9 +15,6 @@ export class ActivityThreadPatch {
|
|
|
26
15
|
|
|
27
16
|
@Field({ nullable: true })
|
|
28
17
|
active?: boolean
|
|
29
|
-
|
|
30
|
-
@Field({ nullable: true })
|
|
31
|
-
cuFlag?: string
|
|
32
18
|
}
|
|
33
19
|
|
|
34
20
|
@InputType()
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
CreateDateColumn,
|
|
5
5
|
Entity,
|
|
6
6
|
Index,
|
|
7
|
+
OneToMany,
|
|
7
8
|
ManyToOne,
|
|
8
9
|
PrimaryGeneratedColumn,
|
|
9
10
|
RelationId,
|
|
@@ -19,6 +20,9 @@ export enum ActivityThreadStatus {
|
|
|
19
20
|
Assigned = 'assigned',
|
|
20
21
|
Started = 'started',
|
|
21
22
|
Delegated = 'delegated',
|
|
23
|
+
Submitted = 'submitted',
|
|
24
|
+
Escalated = 'escalated',
|
|
25
|
+
Rejected = 'rejected',
|
|
22
26
|
Ended = 'ended',
|
|
23
27
|
Aborted = 'aborted'
|
|
24
28
|
}
|
|
@@ -56,6 +60,17 @@ export class ActivityThread {
|
|
|
56
60
|
@RelationId((activityThread: ActivityThread) => activityThread.activityInstance)
|
|
57
61
|
activityInstanceId?: string
|
|
58
62
|
|
|
63
|
+
@ManyToOne(type => ActivityThread, { nullable: true })
|
|
64
|
+
@Field(type => ActivityThread, { nullable: true })
|
|
65
|
+
originalThread?: ActivityThread
|
|
66
|
+
|
|
67
|
+
@RelationId((activityThread: ActivityThread) => activityThread.originalThread)
|
|
68
|
+
originalThreadId?: string
|
|
69
|
+
|
|
70
|
+
@OneToMany(type => ActivityThread, activityThread => activityThread.originalThread)
|
|
71
|
+
@Field(type => [ActivityThread])
|
|
72
|
+
derivedThreads?: ActivityThread
|
|
73
|
+
|
|
59
74
|
@Column({ nullable: true })
|
|
60
75
|
@Field({ nullable: true })
|
|
61
76
|
active?: boolean
|
|
@@ -113,6 +128,13 @@ export class ActivityThread {
|
|
|
113
128
|
@RelationId((activityThread: ActivityThread) => activityThread.updater)
|
|
114
129
|
updaterId?: string
|
|
115
130
|
|
|
131
|
+
@ManyToOne(type => User, { nullable: true })
|
|
132
|
+
@Field({ nullable: true })
|
|
133
|
+
terminator?: User
|
|
134
|
+
|
|
135
|
+
@RelationId((activityThread: ActivityThread) => activityThread.terminator)
|
|
136
|
+
terminatorId?: string
|
|
137
|
+
|
|
116
138
|
isPendingStarted(): boolean {
|
|
117
139
|
switch (this.state) {
|
|
118
140
|
case ActivityThreadStatus.Assigned:
|
|
@@ -125,6 +147,7 @@ export class ActivityThread {
|
|
|
125
147
|
isPendingEnded(): boolean {
|
|
126
148
|
switch (this.state) {
|
|
127
149
|
case ActivityThreadStatus.Started:
|
|
150
|
+
case ActivityThreadStatus.Rejected:
|
|
128
151
|
return true
|
|
129
152
|
default:
|
|
130
153
|
return false
|
|
@@ -136,6 +159,7 @@ export class ActivityThread {
|
|
|
136
159
|
case ActivityThreadStatus.Assigned:
|
|
137
160
|
case ActivityThreadStatus.Started:
|
|
138
161
|
case ActivityThreadStatus.Ended:
|
|
162
|
+
case ActivityThreadStatus.Rejected:
|
|
139
163
|
return true
|
|
140
164
|
case ActivityThreadStatus.Delegated:
|
|
141
165
|
case ActivityThreadStatus.Aborted:
|