@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.
Files changed (129) hide show
  1. package/client/pages/activity-approval/activity-approval-importer.ts +97 -0
  2. package/client/pages/activity-approval/activity-approval-list-page.ts +348 -0
  3. package/client/pages/activity-approval/activity-approval-page.ts +418 -0
  4. package/client/pages/activity-thread/activity-thread-page.ts +5 -5
  5. package/client/pages/todo/approval-waiting-list-page.ts +376 -0
  6. package/client/route.ts +12 -0
  7. package/dist-client/pages/activity-approval/activity-approval-importer.d.ts +22 -0
  8. package/dist-client/pages/activity-approval/activity-approval-importer.js +100 -0
  9. package/dist-client/pages/activity-approval/activity-approval-importer.js.map +1 -0
  10. package/dist-client/pages/activity-approval/activity-approval-list-page.d.ts +62 -0
  11. package/dist-client/pages/activity-approval/activity-approval-list-page.js +326 -0
  12. package/dist-client/pages/activity-approval/activity-approval-list-page.js.map +1 -0
  13. package/dist-client/pages/activity-approval/activity-approval-page.d.ts +55 -0
  14. package/dist-client/pages/activity-approval/activity-approval-page.js +365 -0
  15. package/dist-client/pages/activity-approval/activity-approval-page.js.map +1 -0
  16. package/dist-client/pages/activity-thread/activity-thread-page.d.ts +1 -1
  17. package/dist-client/pages/activity-thread/activity-thread-page.js +4 -4
  18. package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
  19. package/dist-client/pages/todo/approval-waiting-list-page.d.ts +45 -0
  20. package/dist-client/pages/todo/approval-waiting-list-page.js +371 -0
  21. package/dist-client/pages/todo/approval-waiting-list-page.js.map +1 -0
  22. package/dist-client/route.d.ts +1 -1
  23. package/dist-client/route.js +9 -0
  24. package/dist-client/route.js.map +1 -1
  25. package/dist-client/tsconfig.tsbuildinfo +1 -1
  26. package/dist-server/controllers/activity-approval/abort.js +20 -0
  27. package/dist-server/controllers/activity-approval/abort.js.map +1 -0
  28. package/dist-server/controllers/activity-approval/approve.js +50 -0
  29. package/dist-server/controllers/activity-approval/approve.js.map +1 -0
  30. package/dist-server/controllers/activity-approval/delegate.js +20 -0
  31. package/dist-server/controllers/activity-approval/delegate.js.map +1 -0
  32. package/dist-server/controllers/activity-approval/escalate.js +20 -0
  33. package/dist-server/controllers/activity-approval/escalate.js.map +1 -0
  34. package/dist-server/controllers/activity-approval/reject.js +21 -0
  35. package/dist-server/controllers/activity-approval/reject.js.map +1 -0
  36. package/dist-server/controllers/activity-instance/abort.js +2 -3
  37. package/dist-server/controllers/activity-instance/abort.js.map +1 -1
  38. package/dist-server/controllers/activity-instance/delegate.js +2 -3
  39. package/dist-server/controllers/activity-instance/delegate.js.map +1 -1
  40. package/dist-server/controllers/activity-instance/draft.js +1 -2
  41. package/dist-server/controllers/activity-instance/draft.js.map +1 -1
  42. package/dist-server/controllers/activity-instance/end.js +2 -3
  43. package/dist-server/controllers/activity-instance/end.js.map +1 -1
  44. package/dist-server/controllers/activity-instance/pick.js +2 -3
  45. package/dist-server/controllers/activity-instance/pick.js.map +1 -1
  46. package/dist-server/controllers/activity-instance/terminate.js +2 -3
  47. package/dist-server/controllers/activity-instance/terminate.js.map +1 -1
  48. package/dist-server/controllers/activity-thread/abort.js +2 -3
  49. package/dist-server/controllers/activity-thread/abort.js.map +1 -1
  50. package/dist-server/controllers/activity-thread/delegate.js +2 -3
  51. package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
  52. package/dist-server/controllers/activity-thread/end.js +2 -3
  53. package/dist-server/controllers/activity-thread/end.js.map +1 -1
  54. package/dist-server/controllers/activity-thread/index.js +1 -0
  55. package/dist-server/controllers/activity-thread/index.js.map +1 -1
  56. package/dist-server/controllers/activity-thread/submit.js +46 -0
  57. package/dist-server/controllers/activity-thread/submit.js.map +1 -0
  58. package/dist-server/controllers/activity-thread/terminate.js +2 -3
  59. package/dist-server/controllers/activity-thread/terminate.js.map +1 -1
  60. package/dist-server/controllers/common.js +24 -1
  61. package/dist-server/controllers/common.js.map +1 -1
  62. package/dist-server/service/activity/activity-query.js +1 -1
  63. package/dist-server/service/activity/activity-query.js.map +1 -1
  64. package/dist-server/service/activity-approval/activity-approval-mutation.js +79 -0
  65. package/dist-server/service/activity-approval/activity-approval-mutation.js.map +1 -0
  66. package/dist-server/service/activity-approval/activity-approval-query.js +128 -0
  67. package/dist-server/service/activity-approval/activity-approval-query.js.map +1 -0
  68. package/dist-server/service/activity-approval/activity-approval-type.js +39 -0
  69. package/dist-server/service/activity-approval/activity-approval-type.js.map +1 -0
  70. package/dist-server/service/activity-approval/activity-approval.js +135 -0
  71. package/dist-server/service/activity-approval/activity-approval.js.map +1 -0
  72. package/dist-server/service/activity-approval/event-subscriber.js +29 -0
  73. package/dist-server/service/activity-approval/event-subscriber.js.map +1 -0
  74. package/dist-server/service/activity-approval/index.js +11 -0
  75. package/dist-server/service/activity-approval/index.js.map +1 -0
  76. package/dist-server/service/activity-instance/activity-instance-query.js +1 -1
  77. package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
  78. package/dist-server/service/activity-template/activity-template-query.js +1 -1
  79. package/dist-server/service/activity-template/activity-template-query.js.map +1 -1
  80. package/dist-server/service/activity-thread/activity-thread-mutation.js +14 -0
  81. package/dist-server/service/activity-thread/activity-thread-mutation.js.map +1 -1
  82. package/dist-server/service/activity-thread/activity-thread-query.js +7 -2
  83. package/dist-server/service/activity-thread/activity-thread-query.js.map +1 -1
  84. package/dist-server/service/activity-thread/activity-thread-type.js +1 -23
  85. package/dist-server/service/activity-thread/activity-thread-type.js.map +1 -1
  86. package/dist-server/service/activity-thread/activity-thread.js +31 -2
  87. package/dist-server/service/activity-thread/activity-thread.js.map +1 -1
  88. package/dist-server/service/index.js +5 -0
  89. package/dist-server/service/index.js.map +1 -1
  90. package/dist-server/tsconfig.tsbuildinfo +1 -1
  91. package/helps/worklist/activity-approval.md +160 -0
  92. package/package.json +7 -7
  93. package/server/controllers/activity-approval/abort.ts +33 -0
  94. package/server/controllers/activity-approval/approve.ts +80 -0
  95. package/server/controllers/activity-approval/delegate.ts +33 -0
  96. package/server/controllers/activity-approval/escalate.ts +33 -0
  97. package/server/controllers/activity-approval/reject.ts +35 -0
  98. package/server/controllers/activity-instance/abort.ts +2 -4
  99. package/server/controllers/activity-instance/delegate.ts +2 -4
  100. package/server/controllers/activity-instance/draft.ts +1 -3
  101. package/server/controllers/activity-instance/end.ts +2 -4
  102. package/server/controllers/activity-instance/pick.ts +2 -4
  103. package/server/controllers/activity-instance/terminate.ts +2 -4
  104. package/server/controllers/activity-thread/abort.ts +2 -4
  105. package/server/controllers/activity-thread/delegate.ts +2 -4
  106. package/server/controllers/activity-thread/end.ts +2 -4
  107. package/server/controllers/activity-thread/index.ts +1 -0
  108. package/server/controllers/activity-thread/submit.ts +71 -0
  109. package/server/controllers/activity-thread/terminate.ts +2 -4
  110. package/server/controllers/common.ts +28 -0
  111. package/server/service/activity/activity-query.ts +1 -1
  112. package/server/service/activity-approval/activity-approval-mutation.ts +71 -0
  113. package/server/service/activity-approval/activity-approval-query.ts +90 -0
  114. package/server/service/activity-approval/activity-approval-type.ts +28 -0
  115. package/server/service/activity-approval/activity-approval.ts +118 -0
  116. package/server/service/activity-approval/event-subscriber.ts +28 -0
  117. package/server/service/activity-approval/index.ts +8 -0
  118. package/server/service/activity-instance/activity-instance-query.ts +1 -1
  119. package/server/service/activity-template/activity-template-query.ts +1 -1
  120. package/server/service/activity-thread/activity-thread-mutation.ts +12 -1
  121. package/server/service/activity-thread/activity-thread-query.ts +7 -2
  122. package/server/service/activity-thread/activity-thread-type.ts +1 -15
  123. package/server/service/activity-thread/activity-thread.ts +24 -0
  124. package/server/service/index.ts +5 -0
  125. package/things-factory.config.js +4 -1
  126. package/translations/en.json +3 -0
  127. package/translations/ko.json +3 -0
  128. package/translations/ms.json +4 -1
  129. package/translations/zh.json +3 -0
@@ -0,0 +1,418 @@
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 { keyed } from 'lit/directives/keyed.js'
10
+ import { connect } from 'pwa-helpers/connect-mixin.js'
11
+
12
+ import { client } from '@operato/graphql'
13
+ import { i18next, localize } from '@operato/i18n'
14
+ import { PageView, store } from '@operato/shell'
15
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
16
+ import { provider } from '@things-factory/board-ui'
17
+
18
+ const formatter = new Intl.DateTimeFormat(navigator.language, { dateStyle: 'full', timeStyle: 'short' })
19
+
20
+ const ActivityApprovalFetchResult = `\
21
+ {
22
+ id
23
+ judgment
24
+ comment
25
+ activityThread {
26
+ state
27
+ dueAt
28
+ assignedAt
29
+ assignee {
30
+ id
31
+ name
32
+ }
33
+ output
34
+ activityInstance {
35
+ id
36
+ name
37
+ description
38
+ state
39
+ activity {
40
+ model {
41
+ name
42
+ description
43
+ active
44
+ tag
45
+ inout
46
+ type
47
+ unit
48
+ options
49
+ quantifier
50
+ spec
51
+ }
52
+ }
53
+ approvalLine {
54
+ type
55
+ approver {
56
+ id
57
+ name
58
+ description
59
+ controlNo
60
+ }
61
+ }
62
+ thumbnail
63
+ input
64
+ output
65
+ uiType
66
+ uiSource
67
+ dueAt
68
+ createdAt
69
+ }
70
+ }
71
+ }`
72
+
73
+ export const ActivityThreadStatus = {
74
+ Assigned: 'assigned',
75
+ Started: 'started',
76
+ Delegated: 'delegated',
77
+ Ended: 'ended',
78
+ Aborted: 'aborted'
79
+ }
80
+
81
+ @customElement('activity-approval-page')
82
+ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageView)) {
83
+ static styles = [
84
+ ScrollbarStyles,
85
+ CommonGristStyles,
86
+ css`
87
+ :host {
88
+ display: flex;
89
+ flex-direction: column;
90
+
91
+ width: 100%;
92
+ padding: 5px;
93
+ overflow: auto;
94
+ }
95
+
96
+ [header] {
97
+ display: flex;
98
+ padding: 5px;
99
+ }
100
+
101
+ [header] > div {
102
+ flex: 1;
103
+ }
104
+
105
+ [content] {
106
+ clear: left;
107
+
108
+ flex: 1;
109
+ display: block;
110
+ padding: 5px;
111
+ }
112
+
113
+ ox-board-viewer {
114
+ width: 100%;
115
+ height: 100%;
116
+ }
117
+ `
118
+ ]
119
+
120
+ @property({ type: Object }) activityApproval: any
121
+ @property({ type: Object }) activityThread: any
122
+ @property({ type: Object }) board: any
123
+
124
+ get context() {
125
+ const judgment = this.activityApproval.judgment
126
+
127
+ return {
128
+ title: this.lifecycle?.params?.['title'] || i18next.t('title.activity-approval'),
129
+ help: 'worklist/activity-approval',
130
+ actions: judgment
131
+ ? []
132
+ : [
133
+ {
134
+ title: i18next.t('button.reject'),
135
+ action: this._rejectActivityApproval.bind(this),
136
+ ...CommonButtonStyles.play
137
+ },
138
+
139
+ {
140
+ title: i18next.t('button.approve'),
141
+ action: this._approveActivityApproval.bind(this),
142
+ ...CommonButtonStyles.save
143
+ },
144
+
145
+ {
146
+ title: i18next.t('button.save'),
147
+ action: this._saveActivityApproval.bind(this),
148
+ ...CommonButtonStyles.save
149
+ }
150
+ ]
151
+ }
152
+ }
153
+
154
+ render() {
155
+ const { state, dueAt, assignedAt, assignee, activityInstance } = this.activityThread || {}
156
+ const { name, description, thumbnail, approvalLine } = activityInstance || {}
157
+
158
+ return html`
159
+ <div header>
160
+ <div>
161
+ <div>name: ${name}</div>
162
+ <div>description: ${description}</div>
163
+ <div>state: ${state}</div>
164
+ <div>assigned at: ${assignedAt && formatter.format(new Date(assignedAt))}</div>
165
+ <div>due at: ${dueAt && formatter.format(new Date(dueAt))}</div>
166
+ <div>assignee: ${assignee?.name}</div>
167
+ </div>
168
+ <div>
169
+ <div approval-line>
170
+ ${approvalLine ? html` <approval-line-view .model=${approvalLine}></approval-line-view> ` : html``}
171
+ </div>
172
+ <img src=${thumbnail} />
173
+ </div>
174
+ </div>
175
+
176
+ <div content>${this.activityContent()}</div>
177
+ `
178
+ }
179
+
180
+ activityContent() {
181
+ switch (this.activityThread?.activityInstance?.uiType) {
182
+ case 'template':
183
+ return this.templateContent()
184
+ case 'generated':
185
+ return this.generatedContent()
186
+ case 'board':
187
+ return this.boardContent()
188
+ case 'page':
189
+ case 'external':
190
+ default:
191
+ return html``
192
+ }
193
+ }
194
+
195
+ templateContent() {
196
+ const { uiSource: template } = this.activityThread?.activityInstance
197
+ return unsafeHTML(template)
198
+ }
199
+
200
+ getInputSpec() {
201
+ const model = this.activityThread?.activityInstance?.activity?.model
202
+
203
+ return (model || [])
204
+ .filter(item => item.inout === 'in' || item.inout === 'inout')
205
+ .map(item => {
206
+ return {
207
+ ...item,
208
+ label: item.name
209
+ }
210
+ })
211
+ }
212
+
213
+ getOutputSpec() {
214
+ const model = this.activityThread?.activityInstance?.activity?.model
215
+
216
+ return (model || [])
217
+ .filter(item => item.inout === 'inout' || item.inout === 'out')
218
+ .map(item => {
219
+ return {
220
+ ...item,
221
+ label: item.name
222
+ }
223
+ })
224
+ }
225
+
226
+ generatedContent() {
227
+ var { output, activityInstance } = this.activityThread || {}
228
+ var { input } = activityInstance || {}
229
+
230
+ const inputSpec = this.getInputSpec()
231
+ const outputSpec = this.getOutputSpec()
232
+
233
+ if (!output) {
234
+ output = inputSpec
235
+ .filter(item => item.inout === 'inout')
236
+ .reduce((inout, item) => {
237
+ inout[item.name] = input[item.name]
238
+ return inout
239
+ }, {})
240
+ }
241
+
242
+ return keyed(
243
+ activityInstance.id,
244
+ html`
245
+ <fieldset>
246
+ <legend>Input</legend>
247
+ <ox-properties-dynamic-view
248
+ data-name="input"
249
+ .props=${inputSpec}
250
+ .value=${input}
251
+ ></ox-properties-dynamic-view>
252
+ </fieldset>
253
+
254
+ <fieldset>
255
+ <legend>Output</legend>
256
+ <ox-properties-dynamic-view
257
+ data-name="output"
258
+ .props=${outputSpec}
259
+ .value=${output}
260
+ @property-change=${e => (this.activityApproval.output = e.currentTarget.value)}
261
+ ></ox-properties-dynamic-view>
262
+ </fieldset>
263
+ `
264
+ )
265
+ }
266
+
267
+ boardContent() {
268
+ const { output, activityInstance } = this.activityThread
269
+ const { uiSource: boardId, input } = activityInstance || {}
270
+
271
+ if (!this.board || this.board.id !== boardId) {
272
+ this.board = {
273
+ id: boardId
274
+ }
275
+ }
276
+
277
+ return keyed(
278
+ activityInstance.id,
279
+ html`
280
+ <ox-board-viewer
281
+ style="background-color: white;"
282
+ .board=${this.board}
283
+ .provider=${provider}
284
+ .values=${{ ...input, ...output }}
285
+ hide-fullscreen
286
+ hide-navigation
287
+ ></ox-board-viewer>
288
+ `
289
+ )
290
+ }
291
+
292
+ @query('ox-board-viewer') oxBoardViewer: any
293
+
294
+ getOutputFromBoard() {
295
+ const outputSpec = this.getOutputSpec()
296
+ const data = this.oxBoardViewer.getSceneValues()
297
+
298
+ return outputSpec.reduce((output, spec) => {
299
+ output[spec.name] = data[spec.name]
300
+ return output
301
+ }, {})
302
+ }
303
+
304
+ updated(changes) {
305
+ if (changes.has('activityApproval')) {
306
+ this.updateContext()
307
+ }
308
+ }
309
+
310
+ async pageUpdated(changes, lifecycle, changedBefore) {
311
+ if (this.active) {
312
+ this.fetchActivityApproval(lifecycle.resourceId)
313
+ }
314
+ }
315
+
316
+ async fetchActivityApproval(id) {
317
+ const response = await client.query({
318
+ query: gql`
319
+ query activityApproval($id: String!) {
320
+ activityApproval(id: $id) ${ActivityApprovalFetchResult}
321
+ }
322
+ `,
323
+ variables: {
324
+ id
325
+ }
326
+ })
327
+
328
+ this.activityApproval = response.data.activityApproval
329
+ this.activityThread = this.activityApproval.activityThread
330
+ }
331
+
332
+ async _rejectActivityApproval() {
333
+ var { id } = this.activityApproval
334
+ var comment = 'xxxxxxxxxxxxxxxxxxx'
335
+
336
+ const response = await client.mutate({
337
+ mutation: gql`
338
+ mutation ($id: String!, $comment: String!) {
339
+ rejectActivityApproval(id: $id, comment: $comment) ${ActivityApprovalFetchResult}
340
+ }
341
+ `,
342
+ variables: {
343
+ id,
344
+ comment
345
+ }
346
+ })
347
+
348
+ if (!response.errors) {
349
+ this.activityApproval = response.data.startActivityApproval
350
+
351
+ document.dispatchEvent(
352
+ new CustomEvent('notify', {
353
+ detail: {
354
+ message: i18next.t('text.task_is_rejected_successfully')
355
+ }
356
+ })
357
+ )
358
+ }
359
+ }
360
+
361
+ async _approveActivityApproval() {
362
+ var { id } = this.activityApproval
363
+ var comment = 'xxxxxxxxxxxxxxxxxxx'
364
+
365
+ const response = await client.mutate({
366
+ mutation: gql`
367
+ mutation ($id: String!, $comment: String!) {
368
+ approveActivityApproval(id: $id, comment: $comment) ${ActivityApprovalFetchResult}
369
+ }
370
+ `,
371
+ variables: {
372
+ id,
373
+ comment
374
+ }
375
+ })
376
+
377
+ if (!response.errors) {
378
+ this.activityApproval = response.data.approveActivityApproval
379
+
380
+ document.dispatchEvent(
381
+ new CustomEvent('notify', {
382
+ detail: {
383
+ message: i18next.t('text.task_is_approved_successfully')
384
+ }
385
+ })
386
+ )
387
+ }
388
+ }
389
+
390
+ async _saveActivityApproval() {
391
+ var { id } = this.activityApproval
392
+ var comment = 'yyyyyyyyyyyyyyyyyyy'
393
+
394
+ const response = await client.mutate({
395
+ mutation: gql`
396
+ mutation ($id: String!, $comment: String) {
397
+ saveActivityApproval(id: $id, comment: $comment) ${ActivityApprovalFetchResult}
398
+ }
399
+ `,
400
+ variables: {
401
+ id,
402
+ comment
403
+ }
404
+ })
405
+
406
+ if (!response.errors) {
407
+ this.activityApproval = response.data.saveActivityApproval
408
+
409
+ document.dispatchEvent(
410
+ new CustomEvent('notify', {
411
+ detail: {
412
+ message: i18next.t('text.task_is_saved_successfully')
413
+ }
414
+ })
415
+ )
416
+ }
417
+ }
418
+ }
@@ -139,8 +139,8 @@ export class ActivityThreadPage extends connect(store)(localize(i18next)(PageVie
139
139
  },
140
140
 
141
141
  endable && {
142
- title: i18next.t('button.finish'),
143
- action: this._endActivityThread.bind(this),
142
+ title: i18next.t('button.submit'),
143
+ action: this._submitActivityThread.bind(this),
144
144
  ...CommonButtonStyles.save
145
145
  }
146
146
  ].filter(Boolean /* truthy only */)
@@ -392,7 +392,7 @@ export class ActivityThreadPage extends connect(store)(localize(i18next)(PageVie
392
392
  }
393
393
  }
394
394
 
395
- async _endActivityThread() {
395
+ async _submitActivityThread() {
396
396
  var { id, output, reason, activityInstance } = this.activityThread
397
397
  var { uiType } = activityInstance || {}
398
398
 
@@ -403,7 +403,7 @@ export class ActivityThreadPage extends connect(store)(localize(i18next)(PageVie
403
403
  const response = await client.mutate({
404
404
  mutation: gql`
405
405
  mutation ($id: String!, $output: Object, $reason: String) {
406
- endActivityThread(id: $id, output: $output, reason: $reason) ${ActivityThreadFetchResult}
406
+ submitActivityThread(id: $id, output: $output, reason: $reason) ${ActivityThreadFetchResult}
407
407
  }
408
408
  `,
409
409
  variables: {
@@ -414,7 +414,7 @@ export class ActivityThreadPage extends connect(store)(localize(i18next)(PageVie
414
414
  })
415
415
 
416
416
  if (!response.errors) {
417
- this.activityThread = response.data.endActivityThread
417
+ this.activityThread = response.data.submitActivityThread
418
418
 
419
419
  document.dispatchEvent(
420
420
  new CustomEvent('notify', {