@things-factory/worklist 5.0.15 → 6.0.0-alpha.10
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/components/activity-/{bowner-view.js → bowner-view.ts} +27 -34
- package/client/components/{activity-instance-preview.js → activity-instance-preview.ts} +38 -50
- package/client/components/{activity-reporter-view.js → activity-reporter-view.ts} +27 -39
- package/client/components/{activity-starter-form.js → activity-starter-form.ts} +53 -68
- package/client/pages/activity/activity-list-page.ts +4 -3
- package/client/pages/activity/{activity-model-item-list.js → activity-model-item-list.ts} +11 -18
- package/client/pages/activity/{activity-page.js → activity-page.ts} +36 -40
- package/client/pages/activity/{starter-list-page.js → starter-list-page.ts} +15 -20
- package/client/pages/activity-instance/{activity-instance-list-page.js → activity-instance-list-page.ts} +22 -30
- package/client/pages/activity-instance/{activity-instance-page.js → activity-instance-page.ts} +36 -41
- package/client/pages/activity-store/{activity-store-page.js → activity-store-page.ts} +22 -29
- package/client/pages/activity-supervisor/{reporter-list-page.js → reporter-list-page.ts} +14 -21
- package/client/pages/activity-template/{activity-template-importer.js → activity-template-importer.ts} +32 -38
- package/client/pages/activity-template/{activity-template-list-page.js → activity-template-list-page.ts} +30 -37
- package/client/pages/activity-template/{activity-template-model-item-list.js → activity-template-model-item-list.ts} +5 -4
- package/client/pages/activity-thread/{activity-thread-importer.js → activity-thread-importer.ts} +32 -37
- package/client/pages/activity-thread/{activity-thread-list-page.js → activity-thread-list-page.ts} +20 -27
- package/client/pages/activity-thread/{activity-thread-page.js → activity-thread-page.ts} +36 -40
- package/client/pages/dashboard/{dashboard-home.js → dashboard-home.ts} +3 -7
- package/client/pages/todo/{assigned-list-page.js → assigned-list-page.ts} +13 -20
- package/client/pages/todo/{draft-list-page.js → draft-list-page.ts} +13 -20
- package/client/pages/todo/{pickable-list-page.js → pickable-list-page.ts} +13 -20
- package/client/pages/todo/{todo-list-page.js → todo-list-page.ts} +12 -19
- package/client/pages/worklist-home.ts +1 -1
- package/dist-client/components/activity-/bowner-view.d.ts +1 -1
- package/dist-client/components/activity-/bowner-view.js +44 -36
- package/dist-client/components/activity-/bowner-view.js.map +1 -1
- package/dist-client/components/activity-instance-preview.d.ts +2 -1
- package/dist-client/components/activity-instance-preview.js +58 -51
- package/dist-client/components/activity-instance-preview.js.map +1 -1
- package/dist-client/components/activity-intro-view.js.map +1 -1
- package/dist-client/components/activity-reporter-view.d.ts +1 -1
- package/dist-client/components/activity-reporter-view.js +44 -37
- package/dist-client/components/activity-reporter-view.js.map +1 -1
- package/dist-client/components/activity-starter-form.d.ts +16 -0
- package/dist-client/components/activity-starter-form.js +68 -67
- package/dist-client/components/activity-starter-form.js.map +1 -1
- package/dist-client/pages/activity/activity-list-page.d.ts +1 -0
- package/dist-client/pages/activity/activity-list-page.js +7 -4
- package/dist-client/pages/activity/activity-list-page.js.map +1 -1
- package/dist-client/pages/activity/activity-model-item-list.d.ts +13 -180
- package/dist-client/pages/activity/activity-model-item-list.js +52 -44
- package/dist-client/pages/activity/activity-model-item-list.js.map +1 -1
- package/dist-client/pages/activity/activity-page.d.ts +29 -22
- package/dist-client/pages/activity/activity-page.js +53 -44
- package/dist-client/pages/activity/activity-page.js.map +1 -1
- package/dist-client/pages/activity/starter-list-page.d.ts +14 -120
- package/dist-client/pages/activity/starter-list-page.js +47 -31
- package/dist-client/pages/activity/starter-list-page.js.map +1 -1
- package/dist-client/pages/activity-instance/activity-instance-list-page.d.ts +9 -114
- package/dist-client/pages/activity-instance/activity-instance-list-page.js +40 -30
- package/dist-client/pages/activity-instance/activity-instance-list-page.js.map +1 -1
- package/dist-client/pages/activity-instance/activity-instance-page.d.ts +22 -22
- package/dist-client/pages/activity-instance/activity-instance-page.js +57 -44
- package/dist-client/pages/activity-instance/activity-instance-page.js.map +1 -1
- package/dist-client/pages/activity-store/activity-store-page.d.ts +23 -150
- package/dist-client/pages/activity-store/activity-store-page.js +40 -31
- package/dist-client/pages/activity-store/activity-store-page.js.map +1 -1
- package/dist-client/pages/activity-supervisor/reporter-list-page.d.ts +13 -120
- package/dist-client/pages/activity-supervisor/reporter-list-page.js +47 -31
- package/dist-client/pages/activity-supervisor/reporter-list-page.js.map +1 -1
- package/dist-client/pages/activity-template/activity-template-importer.d.ts +7 -21
- package/dist-client/pages/activity-template/activity-template-importer.js +42 -36
- package/dist-client/pages/activity-template/activity-template-importer.js.map +1 -1
- package/dist-client/pages/activity-template/activity-template-list-page.d.ts +17 -218
- package/dist-client/pages/activity-template/activity-template-list-page.js +58 -37
- package/dist-client/pages/activity-template/activity-template-list-page.js.map +1 -1
- package/dist-client/pages/activity-template/activity-template-model-item-list.js +10 -5
- package/dist-client/pages/activity-template/activity-template-model-item-list.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-importer.d.ts +7 -21
- package/dist-client/pages/activity-thread/activity-thread-importer.js +42 -36
- package/dist-client/pages/activity-thread/activity-thread-importer.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-list-page.d.ts +16 -100
- package/dist-client/pages/activity-thread/activity-thread-list-page.js +55 -36
- package/dist-client/pages/activity-thread/activity-thread-list-page.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-page.d.ts +26 -19
- package/dist-client/pages/activity-thread/activity-thread-page.js +53 -44
- package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
- package/dist-client/pages/dashboard/dashboard-home.js +8 -7
- package/dist-client/pages/dashboard/dashboard-home.js.map +1 -1
- package/dist-client/pages/todo/assigned-list-page.d.ts +12 -100
- package/dist-client/pages/todo/assigned-list-page.js +45 -30
- package/dist-client/pages/todo/assigned-list-page.js.map +1 -1
- package/dist-client/pages/todo/draft-list-page.d.ts +13 -174
- package/dist-client/pages/todo/draft-list-page.js +46 -30
- package/dist-client/pages/todo/draft-list-page.js.map +1 -1
- package/dist-client/pages/todo/pickable-list-page.d.ts +13 -126
- package/dist-client/pages/todo/pickable-list-page.js +46 -30
- package/dist-client/pages/todo/pickable-list-page.js.map +1 -1
- package/dist-client/pages/todo/todo-list-page.d.ts +12 -206
- package/dist-client/pages/todo/todo-list-page.js +44 -30
- package/dist-client/pages/todo/todo-list-page.js.map +1 -1
- package/dist-client/pages/worklist-home.js +1 -1
- package/dist-client/pages/worklist-home.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/activity-instance/abort.js +4 -3
- package/dist-server/controllers/activity-instance/abort.js.map +1 -1
- package/dist-server/controllers/activity-instance/adjust.js +2 -1
- package/dist-server/controllers/activity-instance/adjust.js.map +1 -1
- package/dist-server/controllers/activity-instance/assign.js +3 -3
- package/dist-server/controllers/activity-instance/assign.js.map +1 -1
- package/dist-server/controllers/activity-instance/delegate.js +4 -3
- package/dist-server/controllers/activity-instance/delegate.js.map +1 -1
- package/dist-server/controllers/activity-instance/draft.js +3 -3
- package/dist-server/controllers/activity-instance/draft.js.map +1 -1
- package/dist-server/controllers/activity-instance/end.js +4 -3
- package/dist-server/controllers/activity-instance/end.js.map +1 -1
- package/dist-server/controllers/activity-instance/pick.js +4 -3
- package/dist-server/controllers/activity-instance/pick.js.map +1 -1
- package/dist-server/controllers/activity-instance/post.js +17 -3
- package/dist-server/controllers/activity-instance/post.js.map +1 -1
- package/dist-server/controllers/activity-instance/start.js +2 -1
- package/dist-server/controllers/activity-instance/start.js.map +1 -1
- package/dist-server/controllers/activity-instance/terminate.js +4 -3
- package/dist-server/controllers/activity-instance/terminate.js.map +1 -1
- package/dist-server/controllers/activity-thread/abort.js +4 -3
- package/dist-server/controllers/activity-thread/abort.js.map +1 -1
- package/dist-server/controllers/activity-thread/adjust.js +2 -1
- package/dist-server/controllers/activity-thread/adjust.js.map +1 -1
- package/dist-server/controllers/activity-thread/delegate.js +4 -3
- package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
- package/dist-server/controllers/activity-thread/end.js +4 -3
- package/dist-server/controllers/activity-thread/end.js.map +1 -1
- package/dist-server/controllers/activity-thread/save.js +2 -1
- package/dist-server/controllers/activity-thread/save.js.map +1 -1
- package/dist-server/controllers/activity-thread/start.js +2 -1
- package/dist-server/controllers/activity-thread/start.js.map +1 -1
- package/dist-server/controllers/activity-thread/terminate.js +4 -3
- package/dist-server/controllers/activity-thread/terminate.js.map +1 -1
- package/dist-server/controllers/common.js +8 -4
- package/dist-server/controllers/common.js.map +1 -1
- package/dist-server/service/activity/activity-history.js +6 -7
- package/dist-server/service/activity/activity-history.js.map +1 -1
- package/dist-server/service/activity/activity-model-type.js.map +1 -1
- package/dist-server/service/activity/activity-mutation.js +10 -4
- package/dist-server/service/activity/activity-mutation.js.map +1 -1
- package/dist-server/service/activity/activity-query.js +18 -19
- package/dist-server/service/activity/activity-query.js.map +1 -1
- package/dist-server/service/activity/activity-type.js +6 -7
- package/dist-server/service/activity/activity-type.js.map +1 -1
- package/dist-server/service/activity/activity.js +6 -7
- package/dist-server/service/activity/activity.js.map +1 -1
- package/dist-server/service/activity/event-subscriber.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-history.js +7 -8
- package/dist-server/service/activity-instance/activity-instance-history.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-mutation.js +2 -2
- package/dist-server/service/activity-instance/activity-instance-mutation.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-query.js +24 -25
- package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-subscription.js +1 -2
- package/dist-server/service/activity-instance/activity-instance-subscription.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-type.js +4 -5
- package/dist-server/service/activity-instance/activity-instance-type.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance.js +7 -8
- package/dist-server/service/activity-instance/activity-instance.js.map +1 -1
- package/dist-server/service/activity-instance/event-subscriber.js +0 -5
- package/dist-server/service/activity-instance/event-subscriber.js.map +1 -1
- package/dist-server/service/activity-template/activity-template-history.js +3 -4
- package/dist-server/service/activity-template/activity-template-history.js.map +1 -1
- package/dist-server/service/activity-template/activity-template-mutation.js +4 -4
- package/dist-server/service/activity-template/activity-template-mutation.js.map +1 -1
- package/dist-server/service/activity-template/activity-template-query.js +9 -11
- package/dist-server/service/activity-template/activity-template-query.js.map +1 -1
- package/dist-server/service/activity-template/activity-template-type.js.map +1 -1
- package/dist-server/service/activity-template/activity-template.js +3 -4
- package/dist-server/service/activity-template/activity-template.js.map +1 -1
- package/dist-server/service/activity-template/event-subscriber.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-mutation.js +10 -6
- package/dist-server/service/activity-thread/activity-thread-mutation.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-query.js +11 -13
- package/dist-server/service/activity-thread/activity-thread-query.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-subscription.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-type.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread.js +4 -5
- package/dist-server/service/activity-thread/activity-thread.js.map +1 -1
- package/dist-server/service/activity-thread/event-subscriber.js +15 -3
- package/dist-server/service/activity-thread/event-subscriber.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/server/controllers/activity-instance/abort.ts +7 -3
- package/server/controllers/activity-instance/adjust.ts +7 -2
- package/server/controllers/activity-instance/assign.ts +3 -3
- package/server/controllers/activity-instance/delegate.ts +3 -2
- package/server/controllers/activity-instance/draft.ts +6 -3
- package/server/controllers/activity-instance/end.ts +3 -2
- package/server/controllers/activity-instance/pick.ts +4 -3
- package/server/controllers/activity-instance/post.ts +21 -4
- package/server/controllers/activity-instance/start.ts +3 -2
- package/server/controllers/activity-instance/terminate.ts +3 -2
- package/server/controllers/activity-thread/abort.ts +7 -3
- package/server/controllers/activity-thread/adjust.ts +7 -2
- package/server/controllers/activity-thread/delegate.ts +3 -2
- package/server/controllers/activity-thread/end.ts +3 -2
- package/server/controllers/activity-thread/save.ts +3 -2
- package/server/controllers/activity-thread/start.ts +8 -2
- package/server/controllers/activity-thread/terminate.ts +3 -2
- package/server/controllers/common.ts +15 -11
- package/server/service/activity/activity-mutation.ts +19 -10
- package/server/service/activity/activity-query.ts +14 -14
- package/server/service/activity-instance/activity-instance-mutation.ts +8 -8
- package/server/service/activity-instance/activity-instance-query.ts +27 -21
- package/server/service/activity-instance/activity-instance-subscription.ts +1 -2
- package/server/service/activity-instance/event-subscriber.ts +1 -8
- package/server/service/activity-template/activity-template-mutation.ts +13 -10
- package/server/service/activity-template/activity-template-query.ts +8 -9
- package/server/service/activity-thread/activity-thread-mutation.ts +22 -15
- package/server/service/activity-thread/activity-thread-query.ts +10 -11
- package/server/service/activity-thread/event-subscriber.ts +16 -5
- package/translations/en.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
|
@@ -13,7 +13,7 @@ export class ActivityInstanceMutation {
|
|
|
13
13
|
@Mutation(returns => ActivityInstance, { description: 'To draft standard ActivityInstance' })
|
|
14
14
|
async draftActivityInstance(
|
|
15
15
|
@Arg('activityInstance') activityInstance: NewActivityInstance,
|
|
16
|
-
@Ctx() context:
|
|
16
|
+
@Ctx() context: ResolverContext
|
|
17
17
|
): Promise<ActivityInstance> {
|
|
18
18
|
return await draft(activityInstance, context)
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ export class ActivityInstanceMutation {
|
|
|
22
22
|
@Mutation(returns => ActivityInstance, { description: 'To post standard ActivityInstance' })
|
|
23
23
|
async postActivityInstance(
|
|
24
24
|
@Arg('activityInstance') activityInstance: ActivityInstancePost,
|
|
25
|
-
@Ctx() context:
|
|
25
|
+
@Ctx() context: ResolverContext
|
|
26
26
|
): Promise<ActivityInstance> {
|
|
27
27
|
return await post(activityInstance, context)
|
|
28
28
|
}
|
|
@@ -33,7 +33,7 @@ export class ActivityInstanceMutation {
|
|
|
33
33
|
description:
|
|
34
34
|
'To pick an activity ActivityInstance voluntarily. [cautions] This resolver will return a assigned ActivityThread.'
|
|
35
35
|
})
|
|
36
|
-
async pickActivityInstance(@Arg('id') id: string, @Ctx() context:
|
|
36
|
+
async pickActivityInstance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActivityThread> {
|
|
37
37
|
return await pick(id, context)
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -44,7 +44,7 @@ export class ActivityInstanceMutation {
|
|
|
44
44
|
@Arg('assignees', type => [String], { nullable: true, description: 'Email of assignee users' }) assignees: string[],
|
|
45
45
|
@Arg('reason', { nullable: true }) reason: string,
|
|
46
46
|
@Arg('dueAt', { nullable: true }) dueAt: Date,
|
|
47
|
-
@Ctx() context:
|
|
47
|
+
@Ctx() context: ResolverContext
|
|
48
48
|
): Promise<ActivityInstance> {
|
|
49
49
|
return await assign(
|
|
50
50
|
{
|
|
@@ -62,7 +62,7 @@ export class ActivityInstanceMutation {
|
|
|
62
62
|
async updateActivityInstance(
|
|
63
63
|
@Arg('id') id: string,
|
|
64
64
|
@Arg('patch') patch: ActivityInstancePatch,
|
|
65
|
-
@Ctx() context:
|
|
65
|
+
@Ctx() context: ResolverContext
|
|
66
66
|
): Promise<ActivityInstance> {
|
|
67
67
|
return await adjust(id, patch, context)
|
|
68
68
|
}
|
|
@@ -74,7 +74,7 @@ export class ActivityInstanceMutation {
|
|
|
74
74
|
@Arg('assigneeRole', type => ObjectRef, { nullable: true }) assigneeRole: ObjectRef,
|
|
75
75
|
@Arg('dueAt', { nullable: true }) dueAt: Date,
|
|
76
76
|
@Arg('reason', { nullable: true }) reason: string,
|
|
77
|
-
@Ctx() context:
|
|
77
|
+
@Ctx() context: ResolverContext
|
|
78
78
|
): Promise<ActivityInstance> {
|
|
79
79
|
return await delegate({ id, assigneeRole, dueAt, reason }, context)
|
|
80
80
|
}
|
|
@@ -85,7 +85,7 @@ export class ActivityInstanceMutation {
|
|
|
85
85
|
@Arg('id') id: string,
|
|
86
86
|
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
87
87
|
@Arg('reason', { nullable: true }) reason: string,
|
|
88
|
-
@Ctx() context:
|
|
88
|
+
@Ctx() context: ResolverContext
|
|
89
89
|
): Promise<ActivityInstance> {
|
|
90
90
|
return await end({ id, output, reason }, context)
|
|
91
91
|
}
|
|
@@ -95,7 +95,7 @@ export class ActivityInstanceMutation {
|
|
|
95
95
|
async abortActivityInstance(
|
|
96
96
|
@Arg('id') id: string,
|
|
97
97
|
@Arg('reason', { nullable: true }) reason: string,
|
|
98
|
-
@Ctx() context:
|
|
98
|
+
@Ctx() context: ResolverContext
|
|
99
99
|
): Promise<ActivityInstance> {
|
|
100
100
|
return await abort({ id, reason }, context)
|
|
101
101
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { Attachment } from '@things-factory/attachment-base'
|
|
5
4
|
import { Role, User } from '@things-factory/auth-base'
|
|
6
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
5
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
7
6
|
|
|
8
7
|
import { ActivityThread } from '../activity-thread/activity-thread'
|
|
9
8
|
import { Activity } from '../activity/activity'
|
|
@@ -13,16 +12,16 @@ import { ActivityInstanceList } from './activity-instance-type'
|
|
|
13
12
|
@Resolver(ActivityInstance)
|
|
14
13
|
export class ActivityInstanceQuery {
|
|
15
14
|
@Query(returns => ActivityInstance!, { nullable: true, description: 'To fetch a ActivityInstance' })
|
|
16
|
-
async activityInstance(@Arg('id') id: string, @Ctx() context:
|
|
15
|
+
async activityInstance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActivityInstance> {
|
|
17
16
|
const { domain } = context.state
|
|
18
17
|
|
|
19
18
|
return await getRepository(ActivityInstance).findOne({
|
|
20
|
-
where: { domain, id }
|
|
19
|
+
where: { domain: { id: domain.id }, id }
|
|
21
20
|
})
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
@Query(returns => ActivityInstanceList, { description: 'To fetch multiple ActivityInstances' })
|
|
25
|
-
async activityInstances(@Args() params: ListParam, @Ctx() context:
|
|
24
|
+
async activityInstances(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityInstanceList> {
|
|
26
25
|
const { domain } = context.state
|
|
27
26
|
|
|
28
27
|
const [items, total] = await getQueryBuilderFromListParams({
|
|
@@ -36,7 +35,10 @@ export class ActivityInstanceQuery {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
@Query(returns => ActivityInstanceList, { description: 'To get list of activity instance that a user can pick' })
|
|
39
|
-
async pickableActivityList(
|
|
38
|
+
async pickableActivityList(
|
|
39
|
+
@Args() params: ListParam,
|
|
40
|
+
@Ctx() context: ResolverContext
|
|
41
|
+
): Promise<ActivityInstanceList> {
|
|
40
42
|
var { domain, user } = context.state
|
|
41
43
|
|
|
42
44
|
/*
|
|
@@ -74,7 +76,7 @@ export class ActivityInstanceQuery {
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
@Query(returns => ActivityInstanceList, { description: 'To fetch my own ActivityInstances' })
|
|
77
|
-
async draftList(@Args() params: ListParam, @Ctx() context:
|
|
79
|
+
async draftList(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityInstanceList> {
|
|
78
80
|
var { domain, user } = context.state
|
|
79
81
|
|
|
80
82
|
/* 생성자가 자신이면서, 아직 Draft 상태인 activity-instance 리스트만 반환 */
|
|
@@ -102,32 +104,36 @@ export class ActivityInstanceQuery {
|
|
|
102
104
|
return null
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
return await getRepository(Activity).
|
|
107
|
+
return await getRepository(Activity).findOneBy({ id: activityId })
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
@FieldResolver(type => [ActivityThread])
|
|
109
|
-
async activityThreads(
|
|
111
|
+
async activityThreads(
|
|
112
|
+
@Root() activityInstance: ActivityInstance,
|
|
113
|
+
@Ctx() context: ResolverContext
|
|
114
|
+
): Promise<ActivityThread[]> {
|
|
110
115
|
const { user } = context.state
|
|
111
116
|
const { supervisoryRoleId } = activityInstance
|
|
112
117
|
|
|
113
118
|
if (supervisoryRoleId) {
|
|
114
119
|
/* only user having supervisoryRole can get whole activityThreads */
|
|
115
120
|
const roles = (
|
|
116
|
-
(await getRepository(User).findOne(
|
|
121
|
+
(await getRepository(User).findOne({
|
|
122
|
+
where: { id: user.id },
|
|
117
123
|
relations: ['roles']
|
|
118
124
|
})) as User
|
|
119
125
|
).roles.map(role => role.id)
|
|
120
126
|
|
|
121
127
|
if (!roles.includes(supervisoryRoleId)) {
|
|
122
|
-
return await getRepository(ActivityThread).
|
|
123
|
-
activityInstance,
|
|
124
|
-
|
|
128
|
+
return await getRepository(ActivityThread).findBy({
|
|
129
|
+
activityInstance: { id: activityInstance.id },
|
|
130
|
+
assignee: { id: user.id }
|
|
125
131
|
})
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
|
|
129
|
-
return await getRepository(ActivityThread).
|
|
130
|
-
activityInstance
|
|
135
|
+
return await getRepository(ActivityThread).findBy({
|
|
136
|
+
activityInstance: { id: activityInstance.id }
|
|
131
137
|
})
|
|
132
138
|
}
|
|
133
139
|
|
|
@@ -135,7 +141,7 @@ export class ActivityInstanceQuery {
|
|
|
135
141
|
async assigneeRole(@Root() activityInstance: ActivityInstance): Promise<Role> {
|
|
136
142
|
return (
|
|
137
143
|
activityInstance.assigneeRole ||
|
|
138
|
-
(await getRepository(Role).
|
|
144
|
+
(await getRepository(Role).findOneBy({
|
|
139
145
|
id: activityInstance.assigneeRoleId
|
|
140
146
|
}))
|
|
141
147
|
)
|
|
@@ -145,7 +151,7 @@ export class ActivityInstanceQuery {
|
|
|
145
151
|
async supervisoryRole(@Root() activityInstance: ActivityInstance): Promise<Role> {
|
|
146
152
|
return (
|
|
147
153
|
activityInstance.supervisoryRole ||
|
|
148
|
-
(await getRepository(Role).
|
|
154
|
+
(await getRepository(Role).findOneBy({
|
|
149
155
|
id: activityInstance.supervisoryRoleId
|
|
150
156
|
}))
|
|
151
157
|
)
|
|
@@ -158,7 +164,7 @@ export class ActivityInstanceQuery {
|
|
|
158
164
|
activityId &&
|
|
159
165
|
(await getRepository(Attachment).findOne({
|
|
160
166
|
where: {
|
|
161
|
-
domain: activityInstance.domainId,
|
|
167
|
+
domain: { id: activityInstance.domainId },
|
|
162
168
|
refBy: activityId
|
|
163
169
|
}
|
|
164
170
|
}))
|
|
@@ -168,16 +174,16 @@ export class ActivityInstanceQuery {
|
|
|
168
174
|
|
|
169
175
|
@FieldResolver(type => Domain)
|
|
170
176
|
async domain(@Root() activityInstance: ActivityInstance): Promise<Domain> {
|
|
171
|
-
return await getRepository(Domain).
|
|
177
|
+
return await getRepository(Domain).findOneBy({ id: activityInstance.domainId })
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
@FieldResolver(type => User)
|
|
175
181
|
async updater(@Root() activityInstance: ActivityInstance): Promise<User> {
|
|
176
|
-
return await getRepository(User).
|
|
182
|
+
return await getRepository(User).findOneBy({ id: activityInstance.updaterId })
|
|
177
183
|
}
|
|
178
184
|
|
|
179
185
|
@FieldResolver(type => User)
|
|
180
186
|
async creator(@Root() activityInstance: ActivityInstance): Promise<User> {
|
|
181
|
-
return await getRepository(User).
|
|
187
|
+
return await getRepository(User).findOneBy({ id: activityInstance.creatorId })
|
|
182
188
|
}
|
|
183
189
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { withFilter } from 'graphql-subscriptions'
|
|
2
2
|
import { Resolver, Root, Subscription } from 'type-graphql'
|
|
3
|
-
import { getRepository } from 'typeorm'
|
|
4
3
|
|
|
5
4
|
import { User } from '@things-factory/auth-base'
|
|
6
|
-
import { pubsub } from '@things-factory/shell'
|
|
5
|
+
import { getRepository, pubsub } from '@things-factory/shell'
|
|
7
6
|
|
|
8
7
|
import { ActivityInstance } from './activity-instance'
|
|
9
8
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { EventSubscriber } from 'typeorm'
|
|
2
|
-
import { EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm/index'
|
|
1
|
+
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { HistoryEntitySubscriber } from '@anchan828/typeorm-history'
|
|
5
4
|
import { pubsub } from '@things-factory/shell'
|
|
@@ -9,10 +8,6 @@ import { ActivityInstanceHistory } from './activity-instance-history'
|
|
|
9
8
|
|
|
10
9
|
@EventSubscriber()
|
|
11
10
|
export class ActivityInstanceSubscriber implements EntitySubscriberInterface<ActivityInstance> {
|
|
12
|
-
// constructor(connection: Connection) {
|
|
13
|
-
// connection.subscribers.push(this)
|
|
14
|
-
// }
|
|
15
|
-
|
|
16
11
|
listenTo() {
|
|
17
12
|
return ActivityInstance
|
|
18
13
|
}
|
|
@@ -23,7 +18,6 @@ export class ActivityInstanceSubscriber implements EntitySubscriberInterface<Act
|
|
|
23
18
|
pubsub.publish('activity-instance', {
|
|
24
19
|
activityInstance
|
|
25
20
|
})
|
|
26
|
-
console.log('activity-instance created', activityInstance.id)
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
afterUpdate(event: UpdateEvent<ActivityInstance>): Promise<any> | void {
|
|
@@ -32,7 +26,6 @@ export class ActivityInstanceSubscriber implements EntitySubscriberInterface<Act
|
|
|
32
26
|
pubsub.publish('activity-instance', {
|
|
33
27
|
activityInstance
|
|
34
28
|
})
|
|
35
|
-
console.log('activity-instance updated', activityInstance.id)
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
31
|
|
|
@@ -12,7 +12,7 @@ export class ActivityTemplateMutation {
|
|
|
12
12
|
@Mutation(returns => ActivityTemplate, { description: 'To create new ActivityTemplate' })
|
|
13
13
|
async createActivityTemplate(
|
|
14
14
|
@Arg('activityTemplate') activityTemplate: NewActivityTemplate,
|
|
15
|
-
@Ctx() context:
|
|
15
|
+
@Ctx() context: ResolverContext
|
|
16
16
|
): Promise<ActivityTemplate> {
|
|
17
17
|
const { domain, user, tx } = context.state
|
|
18
18
|
|
|
@@ -45,13 +45,13 @@ export class ActivityTemplateMutation {
|
|
|
45
45
|
async updateActivityTemplate(
|
|
46
46
|
@Arg('id') id: string,
|
|
47
47
|
@Arg('patch') patch: ActivityTemplatePatch,
|
|
48
|
-
@Ctx() context:
|
|
48
|
+
@Ctx() context: ResolverContext
|
|
49
49
|
): Promise<ActivityTemplate> {
|
|
50
50
|
const { domain, user, tx } = context.state
|
|
51
51
|
|
|
52
52
|
const repository = tx.getRepository(ActivityTemplate)
|
|
53
53
|
const activityTemplate = await repository.findOne({
|
|
54
|
-
where: { domain, id }
|
|
54
|
+
where: { domain: { id: domain.id }, id }
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
const result = await repository.save({
|
|
@@ -82,7 +82,7 @@ export class ActivityTemplateMutation {
|
|
|
82
82
|
@Mutation(returns => [ActivityTemplate], { description: "To modify multiple ActivityTemplates' information" })
|
|
83
83
|
async updateMultipleActivityTemplate(
|
|
84
84
|
@Arg('patches', type => [ActivityTemplatePatch]) patches: ActivityTemplatePatch[],
|
|
85
|
-
@Ctx() context:
|
|
85
|
+
@Ctx() context: ResolverContext
|
|
86
86
|
): Promise<ActivityTemplate[]> {
|
|
87
87
|
const { domain, user, tx } = context.state
|
|
88
88
|
|
|
@@ -123,7 +123,7 @@ export class ActivityTemplateMutation {
|
|
|
123
123
|
if (_updateRecords.length > 0) {
|
|
124
124
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
125
125
|
const newRecord = _updateRecords[i]
|
|
126
|
-
const activityTemplate = await activityTemplateRepo.
|
|
126
|
+
const activityTemplate = await activityTemplateRepo.findOneBy({ id: newRecord.id })
|
|
127
127
|
|
|
128
128
|
const result = await activityTemplateRepo.save({
|
|
129
129
|
...activityTemplate,
|
|
@@ -155,10 +155,10 @@ export class ActivityTemplateMutation {
|
|
|
155
155
|
|
|
156
156
|
@Directive('@transaction')
|
|
157
157
|
@Mutation(returns => Boolean, { description: 'To delete ActivityTemplate' })
|
|
158
|
-
async deleteActivityTemplate(@Arg('id') id: string, @Ctx() context:
|
|
158
|
+
async deleteActivityTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
159
159
|
const { domain, tx } = context.state
|
|
160
160
|
|
|
161
|
-
await tx.getRepository(ActivityTemplate).delete({ domain, id })
|
|
161
|
+
await tx.getRepository(ActivityTemplate).delete({ domain: { id: domain.id }, id })
|
|
162
162
|
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
163
163
|
|
|
164
164
|
return true
|
|
@@ -166,11 +166,14 @@ export class ActivityTemplateMutation {
|
|
|
166
166
|
|
|
167
167
|
@Directive('@transaction')
|
|
168
168
|
@Mutation(returns => Boolean, { description: 'To delete multiple ActivityTemplates' })
|
|
169
|
-
async deleteActivityTemplates(
|
|
169
|
+
async deleteActivityTemplates(
|
|
170
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
171
|
+
@Ctx() context: ResolverContext
|
|
172
|
+
): Promise<boolean> {
|
|
170
173
|
const { domain, tx } = context.state
|
|
171
174
|
|
|
172
175
|
await tx.getRepository(ActivityTemplate).delete({
|
|
173
|
-
domain,
|
|
176
|
+
domain: { id: domain.id },
|
|
174
177
|
id: In(ids)
|
|
175
178
|
})
|
|
176
179
|
|
|
@@ -183,7 +186,7 @@ export class ActivityTemplateMutation {
|
|
|
183
186
|
@Mutation(returns => Boolean, { description: 'To import multiple ActivityTemplates' })
|
|
184
187
|
async importActivityTemplates(
|
|
185
188
|
@Arg('activityTemplates', type => [ActivityTemplatePatch]) activityTemplates: ActivityTemplatePatch[],
|
|
186
|
-
@Ctx() context:
|
|
189
|
+
@Ctx() context: ResolverContext
|
|
187
190
|
): Promise<boolean> {
|
|
188
191
|
const { domain, tx } = context.state
|
|
189
192
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { Attachment } from '@things-factory/attachment-base'
|
|
5
4
|
import { User } from '@things-factory/auth-base'
|
|
6
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
5
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
7
6
|
|
|
8
7
|
import { ActivityModelItem } from '../activity/activity-model-type'
|
|
9
8
|
import { ActivityTemplate } from './activity-template'
|
|
@@ -12,16 +11,16 @@ import { ActivityTemplateList } from './activity-template-type'
|
|
|
12
11
|
@Resolver(ActivityTemplate)
|
|
13
12
|
export class ActivityTemplateQuery {
|
|
14
13
|
@Query(returns => ActivityTemplate!, { nullable: true, description: 'To fetch a ActivityTemplate' })
|
|
15
|
-
async activityTemplate(@Arg('id') id: string, @Ctx() context:
|
|
14
|
+
async activityTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActivityTemplate> {
|
|
16
15
|
const { domain } = context.state
|
|
17
16
|
|
|
18
17
|
return await getRepository(ActivityTemplate).findOne({
|
|
19
|
-
where: { domain, id }
|
|
18
|
+
where: { domain: { id: domain.id }, id }
|
|
20
19
|
})
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
@Query(returns => ActivityTemplateList, { description: 'To fetch multiple ActivityTemplates' })
|
|
24
|
-
async activityTemplates(@Args() params: ListParam, @Ctx() context:
|
|
23
|
+
async activityTemplates(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityTemplateList> {
|
|
25
24
|
const { domain } = context.state
|
|
26
25
|
|
|
27
26
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -49,7 +48,7 @@ export class ActivityTemplateQuery {
|
|
|
49
48
|
async thumbnail(@Root() activityTemplate: ActivityTemplate): Promise<string | undefined> {
|
|
50
49
|
const attachment: Attachment = await getRepository(Attachment).findOne({
|
|
51
50
|
where: {
|
|
52
|
-
domain: activityTemplate.domainId,
|
|
51
|
+
domain: { id: activityTemplate.domainId },
|
|
53
52
|
refType: ActivityTemplate.name,
|
|
54
53
|
refBy: activityTemplate.id
|
|
55
54
|
}
|
|
@@ -60,16 +59,16 @@ export class ActivityTemplateQuery {
|
|
|
60
59
|
|
|
61
60
|
@FieldResolver(type => Domain)
|
|
62
61
|
async domain(@Root() activityTemplate: ActivityTemplate): Promise<Domain> {
|
|
63
|
-
return await getRepository(Domain).
|
|
62
|
+
return await getRepository(Domain).findOneBy({ id: activityTemplate.domainId })
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
@FieldResolver(type => User)
|
|
67
66
|
async updater(@Root() activityTemplate: ActivityTemplate): Promise<User> {
|
|
68
|
-
return await getRepository(User).
|
|
67
|
+
return await getRepository(User).findOneBy({ id: activityTemplate.updaterId })
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
@FieldResolver(type => User)
|
|
72
71
|
async creator(@Root() activityTemplate: ActivityTemplate): Promise<User> {
|
|
73
|
-
return await getRepository(User).
|
|
72
|
+
return await getRepository(User).findOneBy({ id: activityTemplate.creatorId })
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -13,7 +13,7 @@ export class ActivityThreadMutation {
|
|
|
13
13
|
@Mutation(returns => ActivityThread, { description: 'To create new ActivityThread' })
|
|
14
14
|
async createActivityThread(
|
|
15
15
|
@Arg('activityThread') activityThread: NewActivityThread,
|
|
16
|
-
@Ctx() context:
|
|
16
|
+
@Ctx() context: ResolverContext
|
|
17
17
|
): Promise<ActivityThread> {
|
|
18
18
|
const { domain, user, tx } = context.state
|
|
19
19
|
|
|
@@ -30,13 +30,14 @@ export class ActivityThreadMutation {
|
|
|
30
30
|
async updateActivityThread(
|
|
31
31
|
@Arg('id') id: string,
|
|
32
32
|
@Arg('patch') patch: ActivityThreadPatch,
|
|
33
|
-
@Ctx() context:
|
|
33
|
+
@Ctx() context: ResolverContext
|
|
34
34
|
): Promise<ActivityThread> {
|
|
35
35
|
const { domain, user, tx } = context.state
|
|
36
36
|
|
|
37
37
|
const repository = tx.getRepository(ActivityThread)
|
|
38
38
|
const activityThread = await repository.findOne({
|
|
39
|
-
where: { domain, id }
|
|
39
|
+
where: { domain: { id: domain.id }, id },
|
|
40
|
+
relations: ['domain', 'activityInstance', 'assignee', 'creator', 'updater']
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
return await repository.save({
|
|
@@ -50,7 +51,7 @@ export class ActivityThreadMutation {
|
|
|
50
51
|
@Mutation(returns => [ActivityThread], { description: "To modify multiple ActivityThreads' information" })
|
|
51
52
|
async updateMultipleActivityThread(
|
|
52
53
|
@Arg('patches', type => [ActivityThreadPatch]) patches: ActivityThreadPatch[],
|
|
53
|
-
@Ctx() context:
|
|
54
|
+
@Ctx() context: ResolverContext
|
|
54
55
|
): Promise<ActivityThread[]> {
|
|
55
56
|
const { domain, user, tx } = context.state
|
|
56
57
|
|
|
@@ -77,7 +78,10 @@ export class ActivityThreadMutation {
|
|
|
77
78
|
if (_updateRecords.length > 0) {
|
|
78
79
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
79
80
|
const newRecord = _updateRecords[i]
|
|
80
|
-
const activityThread = await activityThreadRepo.findOne(
|
|
81
|
+
const activityThread = await activityThreadRepo.findOne({
|
|
82
|
+
where: { domain: { id: domain.id }, id: newRecord.id },
|
|
83
|
+
relations: ['domain', 'activityInstance', 'assignee', 'creator', 'updater']
|
|
84
|
+
})
|
|
81
85
|
|
|
82
86
|
const result = await activityThreadRepo.save({
|
|
83
87
|
...activityThread,
|
|
@@ -94,20 +98,23 @@ export class ActivityThreadMutation {
|
|
|
94
98
|
|
|
95
99
|
@Directive('@transaction')
|
|
96
100
|
@Mutation(returns => Boolean, { description: 'To delete ActivityThread' })
|
|
97
|
-
async deleteActivityThread(@Arg('id') id: string, @Ctx() context:
|
|
101
|
+
async deleteActivityThread(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
98
102
|
const { domain, tx } = context.state
|
|
99
103
|
|
|
100
|
-
await tx.getRepository(ActivityThread).delete({ domain, id })
|
|
104
|
+
await tx.getRepository(ActivityThread).delete({ domain: { id: domain.id }, id })
|
|
101
105
|
return true
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
@Directive('@transaction')
|
|
105
109
|
@Mutation(returns => Boolean, { description: 'To delete multiple ActivityThreads' })
|
|
106
|
-
async deleteActivityThreads(
|
|
110
|
+
async deleteActivityThreads(
|
|
111
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
112
|
+
@Ctx() context: ResolverContext
|
|
113
|
+
): Promise<boolean> {
|
|
107
114
|
const { domain, tx } = context.state
|
|
108
115
|
|
|
109
116
|
await tx.getRepository(ActivityThread).delete({
|
|
110
|
-
domain,
|
|
117
|
+
domain: { id: domain.id },
|
|
111
118
|
id: In(ids)
|
|
112
119
|
})
|
|
113
120
|
|
|
@@ -118,7 +125,7 @@ export class ActivityThreadMutation {
|
|
|
118
125
|
@Mutation(returns => Boolean, { description: 'To import multiple ActivityThreads' })
|
|
119
126
|
async importActivityThreads(
|
|
120
127
|
@Arg('activityThreads', type => [ActivityThreadPatch]) activityThreads: ActivityThreadPatch[],
|
|
121
|
-
@Ctx() context:
|
|
128
|
+
@Ctx() context: ResolverContext
|
|
122
129
|
): Promise<boolean> {
|
|
123
130
|
const { domain, tx } = context.state
|
|
124
131
|
|
|
@@ -141,7 +148,7 @@ export class ActivityThreadMutation {
|
|
|
141
148
|
@Arg('id') id: string,
|
|
142
149
|
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
143
150
|
@Arg('reason', { nullable: true }) reason: string,
|
|
144
|
-
@Ctx() context:
|
|
151
|
+
@Ctx() context: ResolverContext
|
|
145
152
|
): Promise<ActivityThread> {
|
|
146
153
|
return await start(id, output, reason, context)
|
|
147
154
|
}
|
|
@@ -153,7 +160,7 @@ export class ActivityThreadMutation {
|
|
|
153
160
|
@Arg('assigneeRole', type => ObjectRef, { nullable: true }) assigneeRole: ObjectRef,
|
|
154
161
|
@Arg('dueAt', { nullable: true }) dueAt: Date,
|
|
155
162
|
@Arg('reason', { nullable: true }) reason: string,
|
|
156
|
-
@Ctx() context:
|
|
163
|
+
@Ctx() context: ResolverContext
|
|
157
164
|
): Promise<ActivityThread> {
|
|
158
165
|
return await delegate({ id, assigneeRole, dueAt, reason }, context)
|
|
159
166
|
}
|
|
@@ -163,7 +170,7 @@ export class ActivityThreadMutation {
|
|
|
163
170
|
async saveActivityThread(
|
|
164
171
|
@Arg('id') id: string,
|
|
165
172
|
@Arg('save') save: ActivityThreadSave,
|
|
166
|
-
@Ctx() context:
|
|
173
|
+
@Ctx() context: ResolverContext
|
|
167
174
|
): Promise<ActivityThread> {
|
|
168
175
|
return await saveActivityThread(id, save, context)
|
|
169
176
|
}
|
|
@@ -174,7 +181,7 @@ export class ActivityThreadMutation {
|
|
|
174
181
|
@Arg('id') id: string,
|
|
175
182
|
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
176
183
|
@Arg('reason', { nullable: true }) reason: string,
|
|
177
|
-
@Ctx() context:
|
|
184
|
+
@Ctx() context: ResolverContext
|
|
178
185
|
): Promise<ActivityThread> {
|
|
179
186
|
return await end({ id, output, reason }, context)
|
|
180
187
|
}
|
|
@@ -184,7 +191,7 @@ export class ActivityThreadMutation {
|
|
|
184
191
|
async abortActivityThread(
|
|
185
192
|
@Arg('id') id: string,
|
|
186
193
|
@Arg('reason', { nullable: true }) reason: string,
|
|
187
|
-
@Ctx() context:
|
|
194
|
+
@Ctx() context: ResolverContext
|
|
188
195
|
): Promise<ActivityThread> {
|
|
189
196
|
return await abort({ id, reason }, context)
|
|
190
197
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { ActivityInstance } from '../activity-instance/activity-instance'
|
|
8
7
|
import { ActivityThread, ActivityThreadStatus } from './activity-thread'
|
|
@@ -11,16 +10,16 @@ import { ActivityThreadList } from './activity-thread-type'
|
|
|
11
10
|
@Resolver(ActivityThread)
|
|
12
11
|
export class ActivityThreadQuery {
|
|
13
12
|
@Query(returns => ActivityThread!, { nullable: true, description: 'To fetch a ActivityThread' })
|
|
14
|
-
async activityThread(@Arg('id') id: string, @Ctx() context:
|
|
13
|
+
async activityThread(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActivityThread> {
|
|
15
14
|
const { domain } = context.state
|
|
16
15
|
|
|
17
16
|
return await getRepository(ActivityThread).findOne({
|
|
18
|
-
where: { domain, id }
|
|
17
|
+
where: { domain: { id: domain.id }, id }
|
|
19
18
|
})
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
@Query(returns => ActivityThreadList, { description: 'To fetch multiple ActivityThreads' })
|
|
23
|
-
async activityThreads(@Args() params: ListParam, @Ctx() context:
|
|
22
|
+
async activityThreads(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityThreadList> {
|
|
24
23
|
const { domain } = context.state
|
|
25
24
|
|
|
26
25
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -36,7 +35,7 @@ export class ActivityThreadQuery {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
@Query(returns => ActivityThreadList, { description: 'To fetch my own ActivityThreads' })
|
|
39
|
-
async todoList(@Args() params: ListParam, @Ctx() context:
|
|
38
|
+
async todoList(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityThreadList> {
|
|
40
39
|
var { domain, user } = context.state
|
|
41
40
|
|
|
42
41
|
const status = [ActivityThreadStatus.Assigned, ActivityThreadStatus.Started]
|
|
@@ -62,27 +61,27 @@ export class ActivityThreadQuery {
|
|
|
62
61
|
@FieldResolver(type => User)
|
|
63
62
|
async assignee(@Root() activityThread: ActivityThread): Promise<User> {
|
|
64
63
|
return activityThread.assigneeId
|
|
65
|
-
? activityThread.assignee || (await getRepository(User).
|
|
64
|
+
? activityThread.assignee || (await getRepository(User).findOneBy({ id: activityThread.assigneeId }))
|
|
66
65
|
: null
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
@FieldResolver(type => ActivityInstance)
|
|
70
69
|
async activityInstance(@Root() activityThread: ActivityThread): Promise<ActivityInstance> {
|
|
71
|
-
return await getRepository(ActivityInstance).
|
|
70
|
+
return await getRepository(ActivityInstance).findOneBy({ id: activityThread.activityInstanceId })
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
@FieldResolver(type => Domain)
|
|
75
74
|
async domain(@Root() activityThread: ActivityThread): Promise<Domain> {
|
|
76
|
-
return await getRepository(Domain).
|
|
75
|
+
return await getRepository(Domain).findOneBy({ id: activityThread.domainId })
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
@FieldResolver(type => User)
|
|
80
79
|
async updater(@Root() activityThread: ActivityThread): Promise<User> {
|
|
81
|
-
return await getRepository(User).
|
|
80
|
+
return await getRepository(User).findOneBy({ id: activityThread.updaterId })
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
@FieldResolver(type => User)
|
|
85
84
|
async creator(@Root() activityThread: ActivityThread): Promise<User> {
|
|
86
|
-
return await getRepository(User).
|
|
85
|
+
return await getRepository(User).findOneBy({ id: activityThread.creatorId })
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { EventSubscriber } from 'typeorm'
|
|
2
|
-
import { EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from 'typeorm/index'
|
|
1
|
+
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { pubsub } from '@things-factory/shell'
|
|
5
4
|
|
|
@@ -14,8 +13,12 @@ export class ActivityThreadSubscriber implements EntitySubscriberInterface<Activ
|
|
|
14
13
|
|
|
15
14
|
async afterInsert(event: InsertEvent<ActivityThread>): Promise<any> {
|
|
16
15
|
const activityThread = event.entity
|
|
16
|
+
const { domain, creator: user } = activityThread
|
|
17
17
|
|
|
18
|
-
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
18
|
+
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
19
|
+
state: { tx: event.manager, domain, user },
|
|
20
|
+
t: null
|
|
21
|
+
})
|
|
19
22
|
|
|
20
23
|
pubsub.publish('activity-thread', {
|
|
21
24
|
activityThread
|
|
@@ -26,8 +29,12 @@ export class ActivityThreadSubscriber implements EntitySubscriberInterface<Activ
|
|
|
26
29
|
|
|
27
30
|
async afterUpdate(event: UpdateEvent<ActivityThread>): Promise<any> {
|
|
28
31
|
const activityThread = event.entity
|
|
32
|
+
const { domain, updater: user } = activityThread
|
|
29
33
|
|
|
30
|
-
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
34
|
+
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
35
|
+
state: { tx: event.manager, domain, user },
|
|
36
|
+
t: null
|
|
37
|
+
})
|
|
31
38
|
|
|
32
39
|
pubsub.publish('activity-thread', {
|
|
33
40
|
activityThread
|
|
@@ -37,7 +44,11 @@ export class ActivityThreadSubscriber implements EntitySubscriberInterface<Activ
|
|
|
37
44
|
|
|
38
45
|
async afterRemove(event: RemoveEvent<ActivityThread>): Promise<any> {
|
|
39
46
|
const activityThread = event.entity
|
|
47
|
+
const { domain, updater: user } = activityThread
|
|
40
48
|
|
|
41
|
-
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
49
|
+
await updateActivityInstanceState(activityThread.activityInstanceId, {
|
|
50
|
+
state: { tx: event.manager, domain, user },
|
|
51
|
+
t: null
|
|
52
|
+
})
|
|
42
53
|
}
|
|
43
54
|
}
|
package/translations/en.json
CHANGED