@things-factory/worklist 6.0.45 → 6.0.47
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/bootstrap.ts +5 -0
- package/client/components/activity-starter-form.ts +53 -303
- package/client/pages/activity/activity-list-page.ts +44 -28
- package/client/pages/activity/activity-page.ts +7 -5
- package/client/pages/activity/activity-partial-view.ts +2 -1
- package/client/pages/activity/starter-list-page.ts +16 -11
- package/client/pages/activity-approval/activity-approval-page.ts +21 -9
- package/client/pages/activity-instance/activity-instance-search-page.ts +2 -19
- package/client/pages/activity-instance/activity-instance-start-page.ts +517 -0
- package/client/pages/activity-thread/activity-thread-page.ts +5 -3
- package/client/pages/activity-thread/activity-thread-view-page.ts +4 -2
- package/client/pages/installable-activity/installable-activity-list-page.ts +7 -5
- package/client/pages/todo/approval-done-list-page.ts +7 -7
- package/client/pages/todo/approval-pending-list-page.ts +48 -10
- package/client/pages/todo/done-list-page.ts +1 -1
- package/client/pages/todo/draft-list-page.ts +26 -102
- package/client/pages/todo/todo-list-page.ts +1 -1
- package/client/route.ts +2 -2
- package/client/templates/activity-approval-context-template.ts +4 -0
- package/client/templates/activity-instance-context-template.ts +171 -0
- package/client/templates/activity-thread-context-template.ts +4 -0
- package/client/types/activity-instance-type.ts +4 -2
- package/client/types/activity-instance.ts +2 -2
- package/client/types/activity.ts +7 -0
- package/client/types/types.ts +8 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +5 -0
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/components/activity-starter-form.d.ts +2 -5
- package/dist-client/components/activity-starter-form.js +55 -247
- package/dist-client/components/activity-starter-form.js.map +1 -1
- package/dist-client/pages/activity/activity-list-page.d.ts +1 -1
- package/dist-client/pages/activity/activity-list-page.js +45 -30
- package/dist-client/pages/activity/activity-list-page.js.map +1 -1
- package/dist-client/pages/activity/activity-page.d.ts +1 -1
- package/dist-client/pages/activity/activity-page.js +5 -5
- package/dist-client/pages/activity/activity-page.js.map +1 -1
- package/dist-client/pages/activity/activity-partial-view.js +2 -2
- package/dist-client/pages/activity/activity-partial-view.js.map +1 -1
- package/dist-client/pages/activity/starter-list-page.d.ts +1 -0
- package/dist-client/pages/activity/starter-list-page.js +14 -11
- package/dist-client/pages/activity/starter-list-page.js.map +1 -1
- package/dist-client/pages/activity-approval/activity-approval-page.d.ts +3 -3
- package/dist-client/pages/activity-approval/activity-approval-page.js +16 -9
- package/dist-client/pages/activity-approval/activity-approval-page.js.map +1 -1
- package/dist-client/pages/activity-instance/activity-instance-page.d.ts +2 -2
- package/dist-client/pages/activity-instance/activity-instance-page.js +19 -10
- package/dist-client/pages/activity-instance/activity-instance-page.js.map +1 -1
- package/dist-client/pages/activity-instance/activity-instance-search-page.js +1 -8
- package/dist-client/pages/activity-instance/activity-instance-search-page.js.map +1 -1
- package/dist-client/pages/activity-instance/activity-instance-start-page.d.ts +49 -0
- package/dist-client/pages/activity-instance/activity-instance-start-page.js +451 -0
- package/dist-client/pages/activity-instance/activity-instance-start-page.js.map +1 -0
- package/dist-client/pages/activity-thread/activity-thread-page.js +3 -3
- package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-view-page.js +2 -2
- package/dist-client/pages/activity-thread/activity-thread-view-page.js.map +1 -1
- package/dist-client/pages/installable-activity/installable-activity-list-page.js +7 -5
- package/dist-client/pages/installable-activity/installable-activity-list-page.js.map +1 -1
- package/dist-client/pages/todo/approval-done-list-page.js +7 -7
- package/dist-client/pages/todo/approval-done-list-page.js.map +1 -1
- package/dist-client/pages/todo/approval-pending-list-page.js +44 -9
- package/dist-client/pages/todo/approval-pending-list-page.js.map +1 -1
- package/dist-client/pages/todo/done-list-page.js +1 -1
- package/dist-client/pages/todo/done-list-page.js.map +1 -1
- package/dist-client/pages/todo/draft-list-page.d.ts +1 -0
- package/dist-client/pages/todo/draft-list-page.js +25 -99
- package/dist-client/pages/todo/draft-list-page.js.map +1 -1
- package/dist-client/pages/todo/todo-list-page.js +1 -1
- package/dist-client/pages/todo/todo-list-page.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +2 -2
- package/dist-client/route.js.map +1 -1
- package/dist-client/templates/activity-approval-context-template.js +4 -0
- package/dist-client/templates/activity-approval-context-template.js.map +1 -1
- package/dist-client/templates/activity-instance-context-template.d.ts +2 -0
- package/dist-client/templates/activity-instance-context-template.js +145 -0
- package/dist-client/templates/activity-instance-context-template.js.map +1 -0
- package/dist-client/templates/activity-thread-context-template.js +4 -0
- package/dist-client/templates/activity-thread-context-template.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/types/activity-instance-type.d.ts +3 -2
- package/dist-client/types/activity-instance-type.js +2 -2
- package/dist-client/types/activity-instance-type.js.map +1 -1
- package/dist-client/types/activity-instance.d.ts +1 -1
- package/dist-client/types/activity-instance.js +2 -2
- package/dist-client/types/activity-instance.js.map +1 -1
- package/dist-client/types/activity.d.ts +5 -0
- package/dist-client/types/activity.js +5 -0
- package/dist-client/types/activity.js.map +1 -1
- package/dist-client/types/types.d.ts +4 -0
- package/dist-client/types/types.js +6 -0
- package/dist-client/types/types.js.map +1 -1
- package/dist-server/controllers/activity-instance/assign.js +1 -1
- package/dist-server/controllers/activity-instance/assign.js.map +1 -1
- package/dist-server/controllers/activity-instance/draft.js +24 -6
- package/dist-server/controllers/activity-instance/draft.js.map +1 -1
- package/dist-server/controllers/activity-instance/index.js +1 -1
- package/dist-server/controllers/activity-instance/index.js.map +1 -1
- package/dist-server/controllers/activity-instance/issue.js +105 -0
- package/dist-server/controllers/activity-instance/issue.js.map +1 -0
- package/dist-server/controllers/activity-instance/pick.js +1 -1
- package/dist-server/controllers/activity-instance/pick.js.map +1 -1
- package/dist-server/controllers/activity-instance/post.js +7 -7
- package/dist-server/controllers/activity-instance/post.js.map +1 -1
- package/dist-server/controllers/common.js +33 -9
- package/dist-server/controllers/common.js.map +1 -1
- package/dist-server/routes.js +2 -2
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/activity/activity-history.js +6 -2
- package/dist-server/service/activity/activity-history.js.map +1 -1
- package/dist-server/service/activity/activity-query.js +84 -1
- package/dist-server/service/activity/activity-query.js.map +1 -1
- package/dist-server/service/activity/activity-type.js +8 -0
- package/dist-server/service/activity/activity-type.js.map +1 -1
- package/dist-server/service/activity/activity.js +36 -3
- package/dist-server/service/activity/activity.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-history.js +1 -1
- package/dist-server/service/activity-instance/activity-instance-history.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-mutation.js +6 -6
- package/dist-server/service/activity-instance/activity-instance-mutation.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-query.js +2 -2
- package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-type.js +62 -50
- package/dist-server/service/activity-instance/activity-instance-type.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance.js +4 -23
- package/dist-server/service/activity-instance/activity-instance.js.map +1 -1
- package/dist-server/service/activity-summary/activity-summary-query.js +1 -1
- package/dist-server/service/activity-summary/activity-summary-query.js.map +1 -1
- package/dist-server/service/installable-activity/installable-activity.js +4 -0
- package/dist-server/service/installable-activity/installable-activity.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/worklist/activity.md +91 -0
- package/helps/worklist/draft-list.md +5 -1
- package/helps/worklist/starter-list.md +34 -0
- package/package.json +2 -2
- package/server/controllers/activity-instance/assign.ts +1 -1
- package/server/controllers/activity-instance/draft.ts +33 -6
- package/server/controllers/activity-instance/index.ts +1 -1
- package/server/controllers/activity-instance/issue.ts +175 -0
- package/server/controllers/activity-instance/pick.ts +1 -1
- package/server/controllers/common.ts +43 -9
- package/server/routes.ts +2 -2
- package/server/service/activity/activity-history.ts +5 -2
- package/server/service/activity/activity-query.ts +85 -2
- package/server/service/activity/activity-type.ts +15 -2
- package/server/service/activity/activity.ts +28 -2
- package/server/service/activity-instance/activity-instance-history.ts +1 -1
- package/server/service/activity-instance/activity-instance-mutation.ts +7 -7
- package/server/service/activity-instance/activity-instance-query.ts +3 -3
- package/server/service/activity-instance/activity-instance-type.ts +13 -4
- package/server/service/activity-instance/activity-instance.ts +4 -16
- package/server/service/activity-summary/activity-summary-query.ts +1 -1
- package/server/service/installable-activity/installable-activity.ts +4 -1
- package/things-factory.config.js +1 -1
- package/translations/en.json +13 -0
- package/translations/ko.json +17 -4
- package/translations/ms.json +13 -0
- package/translations/zh.json +13 -0
- package/client/pages/activity-instance/activity-instance-page.ts +0 -445
- package/server/controllers/activity-instance/post.ts +0 -140
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import '@operato/property-editor/ox-properties-dynamic-view.js'
|
|
2
|
-
import '@operato/board/ox-board-viewer.js'
|
|
3
|
-
import '@things-factory/organization'
|
|
4
|
-
|
|
5
|
-
import gql from 'graphql-tag'
|
|
6
|
-
import { css, html } from 'lit'
|
|
7
|
-
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
|
|
8
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
9
|
-
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
10
|
-
|
|
11
|
-
import { client } from '@operato/graphql'
|
|
12
|
-
import { i18next, localize } from '@operato/i18n'
|
|
13
|
-
import { PageView, store } from '@operato/shell'
|
|
14
|
-
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
|
15
|
-
import { provider } from '@things-factory/board-ui'
|
|
16
|
-
|
|
17
|
-
const formatter = new Intl.DateTimeFormat(navigator.language, { dateStyle: 'full', timeStyle: 'short' })
|
|
18
|
-
|
|
19
|
-
export const ActivityInstanceStatus = {
|
|
20
|
-
Draft: 'draft',
|
|
21
|
-
Posted: 'posted',
|
|
22
|
-
PendingAssignment: 'pending-assignment',
|
|
23
|
-
Assigned: 'assigned',
|
|
24
|
-
Started: 'started',
|
|
25
|
-
Pending: 'pending',
|
|
26
|
-
Ended: 'ended',
|
|
27
|
-
Aborted: 'aborted'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@customElement('activity-instance-page')
|
|
31
|
-
export class ActivityInstancePage extends connect(store)(localize(i18next)(PageView)) {
|
|
32
|
-
static styles = [
|
|
33
|
-
ScrollbarStyles,
|
|
34
|
-
CommonGristStyles,
|
|
35
|
-
css`
|
|
36
|
-
:host {
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
|
|
40
|
-
width: 100%;
|
|
41
|
-
padding: 5px;
|
|
42
|
-
overflow: auto;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
[header] {
|
|
46
|
-
display: block;
|
|
47
|
-
padding: 5px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[content] {
|
|
51
|
-
flex: 1;
|
|
52
|
-
display: block;
|
|
53
|
-
padding: 5px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
ox-board-viewer {
|
|
57
|
-
width: 100%;
|
|
58
|
-
height: 100%;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
#custom-content {
|
|
62
|
-
flex: 1;
|
|
63
|
-
}
|
|
64
|
-
`
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
@property({ type: Object }) activityInstance: any
|
|
68
|
-
@property({ type: Object }) board: any
|
|
69
|
-
|
|
70
|
-
get context() {
|
|
71
|
-
const assignable = [ActivityInstanceStatus.Posted, ActivityInstanceStatus.PendingAssignment].includes(
|
|
72
|
-
this.activityInstance?.state
|
|
73
|
-
)
|
|
74
|
-
const abortable = [ActivityInstanceStatus.Draft, ActivityInstanceStatus.Posted].includes(
|
|
75
|
-
this.activityInstance?.state
|
|
76
|
-
)
|
|
77
|
-
const finishable = [ActivityInstanceStatus.Started].includes(this.activityInstance?.state)
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
title: this.lifecycle?.params?.['title'] || i18next.t('title.activity'),
|
|
81
|
-
help: 'worklist/activity',
|
|
82
|
-
actions: [
|
|
83
|
-
finishable && {
|
|
84
|
-
title: i18next.t('button.finish'),
|
|
85
|
-
action: this._endActivityInstance.bind(this)
|
|
86
|
-
}
|
|
87
|
-
].filter(Boolean /* truthy only */)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@query('ox-board-viewer') viewer: any
|
|
92
|
-
|
|
93
|
-
render() {
|
|
94
|
-
const { name, description, state, thumbnail, approvalLine, dueAt, createdAt } = this.activityInstance || {}
|
|
95
|
-
return html`
|
|
96
|
-
<div header>
|
|
97
|
-
<div>name: ${name}</div>
|
|
98
|
-
<div>description: ${description}</div>
|
|
99
|
-
<div>state: ${state}</div>
|
|
100
|
-
<div>posted at: ${createdAt && formatter.format(new Date(createdAt))}</div>
|
|
101
|
-
<div>due at: ${dueAt && formatter.format(new Date(dueAt))}</div>
|
|
102
|
-
<img src=${thumbnail} />
|
|
103
|
-
<approval-line-view .model=${approvalLine}></approval-line-view>
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
<div content>${this.activityContent()}</div>
|
|
107
|
-
`
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
activityContent() {
|
|
111
|
-
switch (this.activityInstance?.uiType) {
|
|
112
|
-
case 'template':
|
|
113
|
-
return this.templateContent()
|
|
114
|
-
case 'generated':
|
|
115
|
-
return this.generatedContent()
|
|
116
|
-
case 'board':
|
|
117
|
-
return this.boardContent()
|
|
118
|
-
case 'custom-element':
|
|
119
|
-
return this.customElementContent()
|
|
120
|
-
case 'page':
|
|
121
|
-
case 'external':
|
|
122
|
-
default:
|
|
123
|
-
return html``
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
templateContent() {
|
|
128
|
-
const { uiSource: template } = this.activityInstance
|
|
129
|
-
return unsafeHTML(template)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
getInputSpec() {
|
|
133
|
-
const model = this.activityInstance?.activity?.model
|
|
134
|
-
|
|
135
|
-
return (model || [])
|
|
136
|
-
.filter(item => item.inout === 'in' || item.inout === 'inout')
|
|
137
|
-
.map(item => {
|
|
138
|
-
return {
|
|
139
|
-
...item,
|
|
140
|
-
label: item.name
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
getOutputSpec() {
|
|
146
|
-
const model = this.activityInstance?.activity?.model
|
|
147
|
-
|
|
148
|
-
return (model || [])
|
|
149
|
-
.filter(item => item.inout === 'inout' || item.inout === 'out')
|
|
150
|
-
.map(item => {
|
|
151
|
-
return {
|
|
152
|
-
...item,
|
|
153
|
-
label: item.name
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
generatedContent() {
|
|
159
|
-
var { input, output } = this.activityInstance || {}
|
|
160
|
-
|
|
161
|
-
const inputSpec = this.getInputSpec()
|
|
162
|
-
const outputSpec = this.getOutputSpec()
|
|
163
|
-
|
|
164
|
-
if (!output) {
|
|
165
|
-
output = inputSpec
|
|
166
|
-
.filter(item => item.inout === 'inout')
|
|
167
|
-
.reduce((inout, item) => {
|
|
168
|
-
inout[item.name] = input[item.name]
|
|
169
|
-
return inout
|
|
170
|
-
}, {})
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return html`
|
|
174
|
-
<fieldset>
|
|
175
|
-
<legend>Input</legend>
|
|
176
|
-
<ox-properties-dynamic-view data-name="input" .props=${inputSpec} .value=${input}></ox-properties-dynamic-view>
|
|
177
|
-
</fieldset>
|
|
178
|
-
|
|
179
|
-
<fieldset>
|
|
180
|
-
<legend>Output</legend>
|
|
181
|
-
<ox-properties-dynamic-view
|
|
182
|
-
data-name="output"
|
|
183
|
-
.props=${outputSpec}
|
|
184
|
-
.value=${output}
|
|
185
|
-
@property-change=${e => (this.activityInstance.output = e.currentTarget.value)}
|
|
186
|
-
></ox-properties-dynamic-view>
|
|
187
|
-
</fieldset>
|
|
188
|
-
`
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
boardContent() {
|
|
192
|
-
const { uiSource: boardId, input, output } = this.activityInstance
|
|
193
|
-
|
|
194
|
-
if (!this.board || this.board.id !== boardId) {
|
|
195
|
-
this.board = {
|
|
196
|
-
id: boardId
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return html`
|
|
201
|
-
<ox-board-viewer
|
|
202
|
-
style="background-color: white;"
|
|
203
|
-
.board=${this.board}
|
|
204
|
-
.provider=${provider}
|
|
205
|
-
.values=${{ ...input, ...output }}
|
|
206
|
-
hide-fullscreen
|
|
207
|
-
hide-navigation
|
|
208
|
-
></ox-board-viewer>
|
|
209
|
-
`
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
customElementContent() {
|
|
213
|
-
const { uiSource: tagName, input, output } = this.activityInstance
|
|
214
|
-
|
|
215
|
-
const element = document.createElement(tagName)
|
|
216
|
-
element.id = 'custom-content'
|
|
217
|
-
element.input = input
|
|
218
|
-
element.output = output
|
|
219
|
-
|
|
220
|
-
return element
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
getOutputFromBoard() {
|
|
224
|
-
const outputSpec = this.getOutputSpec()
|
|
225
|
-
const data = this.viewer?.getSceneValues() || {}
|
|
226
|
-
|
|
227
|
-
return outputSpec.reduce((output, spec) => {
|
|
228
|
-
output[spec.name] = data[spec.name]
|
|
229
|
-
return output
|
|
230
|
-
}, {})
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
updated(changes) {
|
|
234
|
-
if (changes.has('activityInstance')) {
|
|
235
|
-
this.updateContext()
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async pageUpdated(changes, lifecycle, changedBefore) {
|
|
240
|
-
if (this.active) {
|
|
241
|
-
this.fetchActivityInstance(lifecycle.resourceId)
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async fetchActivityInstance(id) {
|
|
246
|
-
const response = await client.query({
|
|
247
|
-
query: gql`
|
|
248
|
-
query activityInstance($id: String!) {
|
|
249
|
-
activityInstance(id: $id) {
|
|
250
|
-
id
|
|
251
|
-
name
|
|
252
|
-
description
|
|
253
|
-
state
|
|
254
|
-
activity {
|
|
255
|
-
model {
|
|
256
|
-
name
|
|
257
|
-
description
|
|
258
|
-
active
|
|
259
|
-
tag
|
|
260
|
-
inout
|
|
261
|
-
type
|
|
262
|
-
unit
|
|
263
|
-
options
|
|
264
|
-
quantifier
|
|
265
|
-
spec
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
thumbnail
|
|
269
|
-
input
|
|
270
|
-
output
|
|
271
|
-
uiType
|
|
272
|
-
uiSource
|
|
273
|
-
approvalLine {
|
|
274
|
-
type
|
|
275
|
-
value
|
|
276
|
-
approver {
|
|
277
|
-
id
|
|
278
|
-
name
|
|
279
|
-
description
|
|
280
|
-
controlNo
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
dueAt
|
|
284
|
-
createdAt
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
`,
|
|
288
|
-
variables: {
|
|
289
|
-
id
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
this.activityInstance = response.data.activityInstance
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
async _startActivityInstance() {
|
|
297
|
-
var { id, output, reason, uiType } = this.activityInstance
|
|
298
|
-
if (uiType === 'board') {
|
|
299
|
-
output = this.getOutputFromBoard()
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const response = await client.mutate({
|
|
303
|
-
mutation: gql`
|
|
304
|
-
mutation ($id: String!, $output: Object) {
|
|
305
|
-
startActivityInstance(id: $id, output: $output) {
|
|
306
|
-
name
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
`,
|
|
310
|
-
variables: {
|
|
311
|
-
id,
|
|
312
|
-
output
|
|
313
|
-
}
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
if (!response.errors) {
|
|
317
|
-
await this.fetchActivityInstance(this.activityInstance.id)
|
|
318
|
-
|
|
319
|
-
document.dispatchEvent(
|
|
320
|
-
new CustomEvent('notify', {
|
|
321
|
-
detail: {
|
|
322
|
-
message: i18next.t('text.task_is_started_successfully')
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
)
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
async _saveActivityInstance() {
|
|
330
|
-
var { id, output, reason, uiType } = this.activityInstance
|
|
331
|
-
if (uiType === 'board') {
|
|
332
|
-
output = this.getOutputFromBoard()
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const response = await client.mutate({
|
|
336
|
-
mutation: gql`
|
|
337
|
-
mutation ($id: String!, $save: ActivityInstanceSave!) {
|
|
338
|
-
saveActivityInstance(id: $id, save: $save) {
|
|
339
|
-
id
|
|
340
|
-
name
|
|
341
|
-
description
|
|
342
|
-
state
|
|
343
|
-
activity {
|
|
344
|
-
model {
|
|
345
|
-
name
|
|
346
|
-
description
|
|
347
|
-
active
|
|
348
|
-
tag
|
|
349
|
-
inout
|
|
350
|
-
type
|
|
351
|
-
unit
|
|
352
|
-
options
|
|
353
|
-
quantifier
|
|
354
|
-
spec
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
thumbnail
|
|
358
|
-
input
|
|
359
|
-
output
|
|
360
|
-
uiType
|
|
361
|
-
uiSource
|
|
362
|
-
dueAt
|
|
363
|
-
createdAt
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
`,
|
|
367
|
-
variables: {
|
|
368
|
-
id,
|
|
369
|
-
save: {
|
|
370
|
-
output
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
if (!response.errors) {
|
|
376
|
-
this.activityInstance = response.data.saveActivityInstance
|
|
377
|
-
|
|
378
|
-
document.dispatchEvent(
|
|
379
|
-
new CustomEvent('notify', {
|
|
380
|
-
detail: {
|
|
381
|
-
message: i18next.t('text.task_is_saved_successfully')
|
|
382
|
-
}
|
|
383
|
-
})
|
|
384
|
-
)
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
async _endActivityInstance() {
|
|
389
|
-
var { id, output, reason, uiType } = this.activityInstance
|
|
390
|
-
if (uiType === 'board') {
|
|
391
|
-
output = this.getOutputFromBoard()
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const response = await client.mutate({
|
|
395
|
-
mutation: gql`
|
|
396
|
-
mutation ($id: String!, $output: Object, $reason: String) {
|
|
397
|
-
endActivityInstance(id: $id, output: $output, reason: $reason) {
|
|
398
|
-
id
|
|
399
|
-
name
|
|
400
|
-
description
|
|
401
|
-
state
|
|
402
|
-
activity {
|
|
403
|
-
model {
|
|
404
|
-
name
|
|
405
|
-
description
|
|
406
|
-
active
|
|
407
|
-
tag
|
|
408
|
-
inout
|
|
409
|
-
type
|
|
410
|
-
unit
|
|
411
|
-
options
|
|
412
|
-
quantifier
|
|
413
|
-
spec
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
thumbnail
|
|
417
|
-
input
|
|
418
|
-
output
|
|
419
|
-
uiType
|
|
420
|
-
uiSource
|
|
421
|
-
dueAt
|
|
422
|
-
createdAt
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
`,
|
|
426
|
-
variables: {
|
|
427
|
-
id,
|
|
428
|
-
output,
|
|
429
|
-
reason
|
|
430
|
-
}
|
|
431
|
-
})
|
|
432
|
-
|
|
433
|
-
if (!response.errors) {
|
|
434
|
-
this.activityInstance = response.data.endActivityInstance
|
|
435
|
-
|
|
436
|
-
document.dispatchEvent(
|
|
437
|
-
new CustomEvent('notify', {
|
|
438
|
-
detail: {
|
|
439
|
-
message: i18next.t('text.task_is_finished_successfully')
|
|
440
|
-
}
|
|
441
|
-
})
|
|
442
|
-
)
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Activity } from '../../service/activity/activity'
|
|
2
|
-
import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
|
|
3
|
-
import { ActivityInstancePost } from '../../service/activity-instance/activity-instance-type'
|
|
4
|
-
import {
|
|
5
|
-
createActivityThreadsForAllRoleUsers,
|
|
6
|
-
createActivityThreadsForUsers,
|
|
7
|
-
getSystemUserFromOrgMemberItem,
|
|
8
|
-
fillActivitySearchKeys
|
|
9
|
-
} from '../common'
|
|
10
|
-
|
|
11
|
-
export async function post(
|
|
12
|
-
activityInstance: ActivityInstancePost,
|
|
13
|
-
context: ResolverContext
|
|
14
|
-
): Promise<ActivityInstance> {
|
|
15
|
-
const { domain, user, tx } = context.state
|
|
16
|
-
const issuedAt = new Date()
|
|
17
|
-
var {
|
|
18
|
-
id,
|
|
19
|
-
name,
|
|
20
|
-
description,
|
|
21
|
-
assignees,
|
|
22
|
-
uiType,
|
|
23
|
-
uiSource,
|
|
24
|
-
viewType,
|
|
25
|
-
viewSource,
|
|
26
|
-
dueAt,
|
|
27
|
-
priority,
|
|
28
|
-
approvalLine,
|
|
29
|
-
activityId,
|
|
30
|
-
activityType,
|
|
31
|
-
assigneeRole,
|
|
32
|
-
supervisoryRole,
|
|
33
|
-
input
|
|
34
|
-
} = activityInstance
|
|
35
|
-
|
|
36
|
-
var origin = id
|
|
37
|
-
? await tx.getRepository(ActivityInstance).findOne({
|
|
38
|
-
where: { domain: { id: domain.id }, id },
|
|
39
|
-
relations: [
|
|
40
|
-
'domain',
|
|
41
|
-
'activity',
|
|
42
|
-
'assigneeRole',
|
|
43
|
-
'supervisoryRole',
|
|
44
|
-
'updater',
|
|
45
|
-
'creator',
|
|
46
|
-
'starter',
|
|
47
|
-
'terminator'
|
|
48
|
-
]
|
|
49
|
-
})
|
|
50
|
-
: null
|
|
51
|
-
|
|
52
|
-
/*
|
|
53
|
-
Prerequisites for a Task to Be Posted.
|
|
54
|
-
- The previous state of the task should be Draft.
|
|
55
|
-
*/
|
|
56
|
-
if (origin && origin.state !== ActivityInstanceStatus.Draft) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
context.t(`error.activity-instance is already posted`, {
|
|
59
|
-
id: id,
|
|
60
|
-
state: origin.state
|
|
61
|
-
})
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!origin && activityId) {
|
|
66
|
-
var repository = tx.getRepository(Activity)
|
|
67
|
-
var activity = {} as Activity
|
|
68
|
-
|
|
69
|
-
if (activityId) {
|
|
70
|
-
activity = await repository.findOne({
|
|
71
|
-
where: { domain: { id: domain.id }, id: activityId },
|
|
72
|
-
relations: ['assigneeRole', 'supervisoryRole']
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
if (!activity) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
context.t('error.activity not found', {
|
|
78
|
-
activity: activityId
|
|
79
|
-
})
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
activityInstance.name = name || activity.name
|
|
85
|
-
activityInstance.description = description || activity.description
|
|
86
|
-
activityInstance.activityType = activityType || activity.activityType
|
|
87
|
-
activityInstance.uiType = uiType || activity.uiType
|
|
88
|
-
activityInstance.uiSource = uiSource || activity.uiSource
|
|
89
|
-
activityInstance.viewType = viewType || activity.viewType
|
|
90
|
-
activityInstance.viewSource = viewSource || activity.viewSource
|
|
91
|
-
activityInstance.assigneeRole = assigneeRole || activity.assigneeRole
|
|
92
|
-
activityInstance.supervisoryRole = supervisoryRole || activity.supervisoryRole
|
|
93
|
-
activityInstance.priority = priority ?? activity.priority
|
|
94
|
-
|
|
95
|
-
if (!assignees || !approvalLine) {
|
|
96
|
-
activityInstance.adhocType = 'standard'
|
|
97
|
-
activityInstance.refBy = activityId
|
|
98
|
-
if (!assignees) {
|
|
99
|
-
assignees = activityInstance.assignees = activity.assignees
|
|
100
|
-
}
|
|
101
|
-
if (!approvalLine) {
|
|
102
|
-
approvalLine = activityInstance.approvalLine = activity.approvalLine
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!dueAt && activity.standardTime) {
|
|
106
|
-
activityInstance.dueAt = new Date(issuedAt.getTime() + activity.standardTime * 1000)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const activitySearchKeys = fillActivitySearchKeys(activity?.searchKeys, input)
|
|
112
|
-
|
|
113
|
-
const posted = await tx.getRepository(ActivityInstance).save({
|
|
114
|
-
creator: user,
|
|
115
|
-
...origin,
|
|
116
|
-
...activityInstance,
|
|
117
|
-
transaction: 'post',
|
|
118
|
-
activity,
|
|
119
|
-
...activitySearchKeys,
|
|
120
|
-
state: ActivityInstanceStatus.Posted,
|
|
121
|
-
domain,
|
|
122
|
-
issuer: user,
|
|
123
|
-
updater: user,
|
|
124
|
-
issuedAt
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
const assignedUsers = await Promise.all(
|
|
128
|
-
(assignees || []).map(assignee => getSystemUserFromOrgMemberItem(assignee, context))
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
if (assignedUsers.length == 0 && posted.threadsMin === 0 && posted.assigneeRoleId) {
|
|
132
|
-
await createActivityThreadsForAllRoleUsers('post', posted, context)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (assignedUsers.length > 0) {
|
|
136
|
-
await createActivityThreadsForUsers('post', posted, assignedUsers, context)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return await tx.getRepository(ActivityInstance).findOneBy({ id: posted.id })
|
|
140
|
-
}
|