@things-factory/worklist 6.0.26 → 6.0.28

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 (213) hide show
  1. package/client/bootstrap.ts +13 -4
  2. package/client/components/activity-starter-form.ts +41 -10
  3. package/client/grist-editor/grist-editor-activity-search-key.ts +79 -0
  4. package/client/grist-editor/popup-activity-search-keys-input.ts +167 -0
  5. package/client/pages/activity/activity-list-page.ts +74 -11
  6. package/client/pages/activity/activity-partial-view.ts +82 -0
  7. package/client/pages/activity/starter-list-page.ts +1 -0
  8. package/client/pages/activity-approval/activity-approval-page.ts +61 -14
  9. package/client/pages/activity-instance/activity-instance-page.ts +18 -0
  10. package/client/pages/activity-instance/activity-instance-search-page.ts +377 -0
  11. package/client/pages/activity-instance/activity-instance-view.ts +135 -0
  12. package/client/pages/activity-store/activity-store-page.ts +1 -1
  13. package/client/pages/activity-template/activity-template-list-page.ts +1 -1
  14. package/client/pages/activity-thread/activity-thread-page.ts +32 -6
  15. package/client/pages/activity-thread/activity-thread-view.ts +102 -0
  16. package/client/pages/installable-activity/installable-activity-list-page.ts +1 -1
  17. package/client/pages/todo/approval-waiting-list-page.ts +12 -2
  18. package/client/pages/todo/draft-list-page.ts +19 -5
  19. package/client/pages/todo/todo-list-page.ts +14 -3
  20. package/client/route.ts +4 -0
  21. package/client/types/activity-instance-type.ts +123 -0
  22. package/client/types/activity-instance.ts +124 -0
  23. package/client/types/activity-model-type.ts +40 -0
  24. package/client/types/activity-search-key-item-type.ts +9 -0
  25. package/client/types/activity-thread-type.ts +19 -0
  26. package/client/types/activity-thread.ts +88 -0
  27. package/client/types/activity.ts +97 -0
  28. package/client/{types.js → types/types.ts} +1 -9
  29. package/dist-client/bootstrap.d.ts +1 -0
  30. package/dist-client/bootstrap.js +7 -3
  31. package/dist-client/bootstrap.js.map +1 -1
  32. package/dist-client/components/activity-starter-form.d.ts +1 -1
  33. package/dist-client/components/activity-starter-form.js +40 -9
  34. package/dist-client/components/activity-starter-form.js.map +1 -1
  35. package/dist-client/grist-editor/grist-editor-activity-search-key.d.ts +12 -0
  36. package/dist-client/grist-editor/grist-editor-activity-search-key.js +70 -0
  37. package/dist-client/grist-editor/grist-editor-activity-search-key.js.map +1 -0
  38. package/dist-client/grist-editor/popup-activity-search-keys-input.d.ts +17 -0
  39. package/dist-client/grist-editor/popup-activity-search-keys-input.js +177 -0
  40. package/dist-client/grist-editor/popup-activity-search-keys-input.js.map +1 -0
  41. package/dist-client/pages/activity/activity-list-page.d.ts +4 -0
  42. package/dist-client/pages/activity/activity-list-page.js +73 -11
  43. package/dist-client/pages/activity/activity-list-page.js.map +1 -1
  44. package/dist-client/pages/activity/activity-partial-view.d.ts +13 -0
  45. package/dist-client/pages/activity/activity-partial-view.js +56 -0
  46. package/dist-client/pages/activity/activity-partial-view.js.map +1 -0
  47. package/dist-client/pages/activity/starter-list-page.js.map +1 -1
  48. package/dist-client/pages/activity-approval/activity-approval-page.d.ts +2 -2
  49. package/dist-client/pages/activity-approval/activity-approval-page.js +59 -14
  50. package/dist-client/pages/activity-approval/activity-approval-page.js.map +1 -1
  51. package/dist-client/pages/activity-instance/activity-instance-page.d.ts +2 -1
  52. package/dist-client/pages/activity-instance/activity-instance-page.js +15 -0
  53. package/dist-client/pages/activity-instance/activity-instance-page.js.map +1 -1
  54. package/dist-client/pages/activity-instance/activity-instance-search-page.d.ts +76 -0
  55. package/dist-client/pages/activity-instance/activity-instance-search-page.js +371 -0
  56. package/dist-client/pages/activity-instance/activity-instance-search-page.js.map +1 -0
  57. package/dist-client/pages/activity-instance/activity-instance-view.d.ts +14 -0
  58. package/dist-client/pages/activity-instance/activity-instance-view.js +130 -0
  59. package/dist-client/pages/activity-instance/activity-instance-view.js.map +1 -0
  60. package/dist-client/pages/activity-store/activity-store-page.js +1 -1
  61. package/dist-client/pages/activity-store/activity-store-page.js.map +1 -1
  62. package/dist-client/pages/activity-template/activity-template-list-page.js +1 -1
  63. package/dist-client/pages/activity-template/activity-template-list-page.js.map +1 -1
  64. package/dist-client/pages/activity-thread/activity-thread-page.d.ts +2 -2
  65. package/dist-client/pages/activity-thread/activity-thread-page.js +29 -6
  66. package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
  67. package/dist-client/pages/activity-thread/activity-thread-view.d.ts +11 -0
  68. package/dist-client/pages/activity-thread/activity-thread-view.js +103 -0
  69. package/dist-client/pages/activity-thread/activity-thread-view.js.map +1 -0
  70. package/dist-client/pages/installable-activity/installable-activity-list-page.js +1 -1
  71. package/dist-client/pages/installable-activity/installable-activity-list-page.js.map +1 -1
  72. package/dist-client/pages/todo/approval-waiting-list-page.js +12 -2
  73. package/dist-client/pages/todo/approval-waiting-list-page.js.map +1 -1
  74. package/dist-client/pages/todo/draft-list-page.d.ts +4 -8
  75. package/dist-client/pages/todo/draft-list-page.js +16 -3
  76. package/dist-client/pages/todo/draft-list-page.js.map +1 -1
  77. package/dist-client/pages/todo/todo-list-page.js +13 -3
  78. package/dist-client/pages/todo/todo-list-page.js.map +1 -1
  79. package/dist-client/route.d.ts +1 -1
  80. package/dist-client/route.js +3 -0
  81. package/dist-client/route.js.map +1 -1
  82. package/dist-client/tsconfig.tsbuildinfo +1 -1
  83. package/dist-client/types/activity-instance-type.d.ts +76 -0
  84. package/dist-client/types/activity-instance-type.js +11 -0
  85. package/dist-client/types/activity-instance-type.js.map +1 -0
  86. package/dist-client/types/activity-instance.d.ts +70 -0
  87. package/dist-client/types/activity-instance.js +36 -0
  88. package/dist-client/types/activity-instance.js.map +1 -0
  89. package/dist-client/types/activity-model-type.d.ts +31 -0
  90. package/dist-client/types/activity-model-type.js +18 -0
  91. package/dist-client/types/activity-model-type.js.map +1 -0
  92. package/dist-client/types/activity-search-key-item-type.d.ts +6 -0
  93. package/dist-client/types/activity-search-key-item-type.js +3 -0
  94. package/dist-client/types/activity-search-key-item-type.js.map +1 -0
  95. package/dist-client/types/activity-thread-type.d.ts +15 -0
  96. package/dist-client/types/activity-thread-type.js +7 -0
  97. package/dist-client/types/activity-thread-type.js.map +1 -0
  98. package/dist-client/types/activity-thread.d.ts +37 -0
  99. package/dist-client/types/activity-thread.js +51 -0
  100. package/dist-client/types/activity-thread.js.map +1 -0
  101. package/dist-client/types/activity.d.ts +62 -0
  102. package/dist-client/types/activity.js +35 -0
  103. package/dist-client/types/activity.js.map +1 -0
  104. package/dist-client/types/types.d.ts +15 -0
  105. package/dist-client/types/types.js +30 -0
  106. package/dist-client/types/types.js.map +1 -0
  107. package/dist-client/types.js +1 -0
  108. package/dist-client/types.js.map +1 -1
  109. package/dist-server/controllers/activity-approval/approve.js +3 -1
  110. package/dist-server/controllers/activity-approval/approve.js.map +1 -1
  111. package/dist-server/controllers/activity-approval/reject.js +2 -0
  112. package/dist-server/controllers/activity-approval/reject.js.map +1 -1
  113. package/dist-server/controllers/activity-installation/activity-installation-controller.js +25 -0
  114. package/dist-server/controllers/activity-installation/activity-installation-controller.js.map +1 -0
  115. package/dist-server/controllers/activity-installation/call-webhook.js +41 -0
  116. package/dist-server/controllers/activity-installation/call-webhook.js.map +1 -0
  117. package/dist-server/controllers/activity-installation/callback-registry.js +21 -0
  118. package/dist-server/controllers/activity-installation/callback-registry.js.map +1 -0
  119. package/dist-server/controllers/activity-instance/abort.js +1 -1
  120. package/dist-server/controllers/activity-instance/abort.js.map +1 -1
  121. package/dist-server/controllers/activity-instance/adjust.js +1 -1
  122. package/dist-server/controllers/activity-instance/adjust.js.map +1 -1
  123. package/dist-server/controllers/activity-instance/delegate.js +5 -0
  124. package/dist-server/controllers/activity-instance/delegate.js.map +1 -1
  125. package/dist-server/controllers/activity-instance/draft.js +27 -1
  126. package/dist-server/controllers/activity-instance/draft.js.map +1 -1
  127. package/dist-server/controllers/activity-instance/post.js +39 -4
  128. package/dist-server/controllers/activity-instance/post.js.map +1 -1
  129. package/dist-server/controllers/activity-instance/start.js +1 -1
  130. package/dist-server/controllers/activity-instance/start.js.map +1 -1
  131. package/dist-server/controllers/activity-thread/submit.js +2 -2
  132. package/dist-server/controllers/activity-thread/submit.js.map +1 -1
  133. package/dist-server/controllers/common.js +105 -57
  134. package/dist-server/controllers/common.js.map +1 -1
  135. package/dist-server/controllers/index.js +1 -1
  136. package/dist-server/controllers/index.js.map +1 -1
  137. package/dist-server/service/activity/activity-history.js +15 -0
  138. package/dist-server/service/activity/activity-history.js.map +1 -1
  139. package/dist-server/service/activity/activity-search-key-item-type.js +28 -0
  140. package/dist-server/service/activity/activity-search-key-item-type.js.map +1 -0
  141. package/dist-server/service/activity/activity-type.js +32 -0
  142. package/dist-server/service/activity/activity-type.js.map +1 -1
  143. package/dist-server/service/activity/activity.js +25 -3
  144. package/dist-server/service/activity/activity.js.map +1 -1
  145. package/dist-server/service/activity-approval/event-subscriber.js +1 -1
  146. package/dist-server/service/activity-approval/event-subscriber.js.map +1 -1
  147. package/dist-server/service/activity-instance/activity-instance-history.js +53 -0
  148. package/dist-server/service/activity-instance/activity-instance-history.js.map +1 -1
  149. package/dist-server/service/activity-instance/activity-instance-query.js +70 -0
  150. package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
  151. package/dist-server/service/activity-instance/activity-instance.js +53 -0
  152. package/dist-server/service/activity-instance/activity-instance.js.map +1 -1
  153. package/dist-server/service/activity-instance/event-subscriber.js +4 -4
  154. package/dist-server/service/activity-instance/event-subscriber.js.map +1 -1
  155. package/dist-server/service/activity-thread/activity-thread.js +4 -1
  156. package/dist-server/service/activity-thread/activity-thread.js.map +1 -1
  157. package/dist-server/service/installable-activity/installable-activity-mutation.js +1 -1
  158. package/dist-server/service/installable-activity/installable-activity-mutation.js.map +1 -1
  159. package/dist-server/service/installable-activity/installable-activity-query.js +1 -1
  160. package/dist-server/service/installable-activity/installable-activity-query.js.map +1 -1
  161. package/dist-server/service/installable-activity/installable-activity.js.map +1 -1
  162. package/dist-server/tsconfig.tsbuildinfo +1 -1
  163. package/package.json +8 -7
  164. package/server/controllers/activity-approval/approve.ts +5 -2
  165. package/server/controllers/activity-approval/reject.ts +3 -0
  166. package/server/controllers/{activity-installation-controller.ts → activity-installation/activity-installation-controller.ts} +12 -1
  167. package/server/controllers/activity-instance/abort.ts +1 -1
  168. package/server/controllers/activity-instance/adjust.ts +1 -1
  169. package/server/controllers/activity-instance/delegate.ts +9 -1
  170. package/server/controllers/activity-instance/draft.ts +30 -3
  171. package/server/controllers/activity-instance/post.ts +55 -7
  172. package/server/controllers/activity-instance/start.ts +1 -1
  173. package/server/controllers/activity-thread/submit.ts +3 -2
  174. package/server/controllers/common.ts +133 -56
  175. package/server/controllers/index.ts +1 -1
  176. package/server/service/activity/activity-history.ts +13 -0
  177. package/server/service/activity/activity-search-key-item-type.ts +16 -0
  178. package/server/service/activity/activity-type.ts +28 -1
  179. package/server/service/activity/activity.ts +22 -3
  180. package/server/service/activity-approval/event-subscriber.ts +1 -1
  181. package/server/service/activity-instance/activity-instance-history.ts +41 -0
  182. package/server/service/activity-instance/activity-instance-query.ts +74 -1
  183. package/server/service/activity-instance/activity-instance.ts +41 -0
  184. package/server/service/activity-instance/event-subscriber.ts +4 -4
  185. package/server/service/activity-thread/activity-thread.ts +6 -3
  186. package/server/service/installable-activity/installable-activity-mutation.ts +1 -1
  187. package/server/service/installable-activity/installable-activity-query.ts +1 -1
  188. package/server/service/installable-activity/installable-activity.ts +3 -1
  189. package/things-factory.config.js +5 -5
  190. package/translations/en.json +5 -0
  191. package/translations/ko.json +5 -0
  192. package/translations/ms.json +5 -0
  193. package/translations/zh.json +5 -0
  194. package/dist-client/pages/installed-activity/installed-activity-list-page.d.ts +0 -45
  195. package/dist-client/pages/installed-activity/installed-activity-list-page.js +0 -412
  196. package/dist-client/pages/installed-activity/installed-activity-list-page.js.map +0 -1
  197. package/dist-client/pages/installed-activity/installed-activity-model-item-list.d.ts +0 -1
  198. package/dist-client/pages/installed-activity/installed-activity-model-item-list.js +0 -20
  199. package/dist-client/pages/installed-activity/installed-activity-model-item-list.js.map +0 -1
  200. package/dist-client/templates/activity-context-template.d.ts +0 -2
  201. package/dist-client/templates/activity-context-template.js +0 -62
  202. package/dist-client/templates/activity-context-template.js.map +0 -1
  203. package/dist-server/service/installed-activity/index.js +0 -10
  204. package/dist-server/service/installed-activity/index.js.map +0 -1
  205. package/dist-server/service/installed-activity/installed-activity-mutation.js +0 -60
  206. package/dist-server/service/installed-activity/installed-activity-mutation.js.map +0 -1
  207. package/dist-server/service/installed-activity/installed-activity-query.js +0 -48
  208. package/dist-server/service/installed-activity/installed-activity-query.js.map +0 -1
  209. package/dist-server/service/installed-activity/installed-activity-type.js +0 -21
  210. package/dist-server/service/installed-activity/installed-activity-type.js.map +0 -1
  211. package/dist-server/service/installed-activity/installed-activity.js +0 -70
  212. package/dist-server/service/installed-activity/installed-activity.js.map +0 -1
  213. /package/server/controllers/{call-webhook.ts → activity-installation/call-webhook.ts} +0 -0
@@ -1,11 +1,10 @@
1
1
  import '@operato/property-editor/ox-properties-dynamic-view.js'
2
2
  import '@operato/board/ox-board-viewer.js'
3
- import '@things-factory/organization'
4
3
 
5
4
  import gql from 'graphql-tag'
6
5
  import { css, html } from 'lit'
7
6
  import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
8
- import { customElement, property, query } from 'lit/decorators.js'
7
+ import { customElement, property, query, state } from 'lit/decorators.js'
9
8
  import { keyed } from 'lit/directives/keyed.js'
10
9
  import { connect } from 'pwa-helpers/connect-mixin.js'
11
10
 
@@ -57,6 +56,7 @@ const ActivityApprovalFetchResult = `\
57
56
  }
58
57
  approvalLine {
59
58
  type
59
+ value
60
60
  approver {
61
61
  id
62
62
  name
@@ -92,6 +92,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
92
92
  :host {
93
93
  display: flex;
94
94
  flex-direction: column;
95
+ position: relative;
95
96
 
96
97
  width: 100%;
97
98
  padding: 5px;
@@ -102,12 +103,36 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
102
103
  width: 100%;
103
104
  height: 100%;
104
105
  }
106
+
107
+ #custom-content {
108
+ flex: 1;
109
+ }
110
+
111
+ div[comment] {
112
+ display: flex;
113
+ width: 100%;
114
+ height: 100px;
115
+ right: 0;
116
+ bottom: 0;
117
+ margin: 0;
118
+ padding: 0;
119
+ opacity: 0.8;
120
+ }
121
+
122
+ textarea {
123
+ flex: 1;
124
+ padding: 10px;
125
+ resize: none;
126
+ background-color: black;
127
+ color: yellow;
128
+ outline: none;
129
+ }
105
130
  `
106
131
  ]
107
132
 
108
- @property({ type: Object }) activityApproval: any
109
- @property({ type: Object }) activityThread: any
110
- @property({ type: Object }) board: any
133
+ @state() activityApproval: any
134
+ @state() activityThread: any
135
+ @state() board: any
111
136
 
112
137
  get context() {
113
138
  const judgment = this.activityApproval?.judgment
@@ -141,7 +166,18 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
141
166
  }
142
167
 
143
168
  render() {
144
- return html` ${this.activityContent()}`
169
+ return html`
170
+ ${this.activityContent()}
171
+ <div comment>
172
+ <textarea
173
+ placeholder="Jot down your comment here."
174
+ .value=${this.activityApproval?.comment}
175
+ @change=${(e: Event) => {
176
+ this.activityApproval.comment = (e.target as HTMLTextAreaElement).value
177
+ }}
178
+ ></textarea>
179
+ </div>
180
+ `
145
181
  }
146
182
 
147
183
  activityContent() {
@@ -152,6 +188,8 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
152
188
  return this.generatedContent()
153
189
  case 'board':
154
190
  return this.boardContent()
191
+ case 'custom-element':
192
+ return this.customElementContent()
155
193
  case 'page':
156
194
  case 'external':
157
195
  default:
@@ -207,7 +245,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
207
245
  }
208
246
 
209
247
  return keyed(
210
- activityInstance.id,
248
+ this.activityApproval.id,
211
249
  html`
212
250
  <fieldset>
213
251
  <legend>Input</legend>
@@ -242,7 +280,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
242
280
  }
243
281
 
244
282
  return keyed(
245
- activityInstance.id,
283
+ this.activityApproval.id,
246
284
  html`
247
285
  <ox-board-viewer
248
286
  style="background-color: white;"
@@ -256,6 +294,18 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
256
294
  )
257
295
  }
258
296
 
297
+ customElementContent() {
298
+ const { output, activityInstance } = this.activityThread
299
+ const { uiSource: tagName, input } = activityInstance || {}
300
+
301
+ const element = document.createElement(tagName)
302
+ element.id = 'custom-content'
303
+ element.input = input
304
+ element.output = output
305
+
306
+ return element
307
+ }
308
+
259
309
  @query('ox-board-viewer') oxBoardViewer: any
260
310
 
261
311
  getOutputFromBoard() {
@@ -299,8 +349,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
299
349
  }
300
350
 
301
351
  async _rejectActivityApproval() {
302
- var { id } = this.activityApproval
303
- var comment = 'xxxxxxxxxxxxxxxxxxx'
352
+ var { id, comment } = this.activityApproval
304
353
 
305
354
  const response = await client.mutate({
306
355
  mutation: gql`
@@ -328,8 +377,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
328
377
  }
329
378
 
330
379
  async _approveActivityApproval() {
331
- var { id } = this.activityApproval
332
- var comment = 'xxxxxxxxxxxxxxxxxxx'
380
+ var { id, comment } = this.activityApproval
333
381
 
334
382
  const response = await client.mutate({
335
383
  mutation: gql`
@@ -357,8 +405,7 @@ export class ActivityApprovalPage extends connect(store)(localize(i18next)(PageV
357
405
  }
358
406
 
359
407
  async _saveActivityApproval() {
360
- var { id } = this.activityApproval
361
- var comment = 'yyyyyyyyyyyyyyyyyyy'
408
+ var { id, comment } = this.activityApproval
362
409
 
363
410
  const response = await client.mutate({
364
411
  mutation: gql`
@@ -57,6 +57,10 @@ export class ActivityInstancePage extends connect(store)(localize(i18next)(PageV
57
57
  width: 100%;
58
58
  height: 100%;
59
59
  }
60
+
61
+ #custom-content {
62
+ flex: 1;
63
+ }
60
64
  `
61
65
  ]
62
66
 
@@ -111,6 +115,8 @@ export class ActivityInstancePage extends connect(store)(localize(i18next)(PageV
111
115
  return this.generatedContent()
112
116
  case 'board':
113
117
  return this.boardContent()
118
+ case 'custom-element':
119
+ return this.customElementContent()
114
120
  case 'page':
115
121
  case 'external':
116
122
  default:
@@ -203,6 +209,17 @@ export class ActivityInstancePage extends connect(store)(localize(i18next)(PageV
203
209
  `
204
210
  }
205
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
+
206
223
  getOutputFromBoard() {
207
224
  const outputSpec = this.getOutputSpec()
208
225
  const data = this.viewer?.getSceneValues() || {}
@@ -255,6 +272,7 @@ export class ActivityInstancePage extends connect(store)(localize(i18next)(PageV
255
272
  uiSource
256
273
  approvalLine {
257
274
  type
275
+ value
258
276
  approver {
259
277
  id
260
278
  name
@@ -0,0 +1,377 @@
1
+ import '@operato/data-grist'
2
+ import './activity-instance-view.js'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query, state } from 'lit/decorators.js'
7
+ import { connect } from 'pwa-helpers/connect-mixin'
8
+
9
+ import {
10
+ getEditor,
11
+ getRenderer,
12
+ ColumnConfig,
13
+ DataGrist,
14
+ FetchOption,
15
+ SortersControl,
16
+ GristRecord
17
+ } from '@operato/data-grist'
18
+ import { client } from '@operato/graphql'
19
+ import { i18next, localize } from '@operato/i18n'
20
+ import { openPopup } from '@operato/layout'
21
+ import { PageView, store } from '@operato/shell'
22
+ import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
23
+ import { isMobileDevice } from '@operato/utils'
24
+ import { OxPopup } from '@operato/popup'
25
+ import { ActivitySearchKeyItem } from '../../types/activity-search-key-item-type'
26
+
27
+ @customElement('activity-instance-search-page')
28
+ export class ActivityInstanceSearchPage extends connect(store)(localize(i18next)(PageView)) {
29
+ static styles = [
30
+ ScrollbarStyles,
31
+ CommonGristStyles,
32
+ css`
33
+ :host {
34
+ display: flex;
35
+ flex-direction: column;
36
+
37
+ overflow: hidden;
38
+ }
39
+
40
+ ox-grist {
41
+ overflow-y: auto;
42
+ flex: 1;
43
+ }
44
+ `
45
+ ]
46
+
47
+ @state() activityId?: string
48
+ @state() activity: any
49
+ @state() searchKeys: ActivitySearchKeyItem[] = []
50
+
51
+ @state() gristConfig: any
52
+ @state() mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
53
+
54
+ @query('ox-grist') private grist!: DataGrist
55
+ @query('#sorter-control') private sortersControl!: OxPopup
56
+
57
+ get context() {
58
+ return {
59
+ search: {
60
+ handler: (search: string) => {
61
+ this.grist.searchText = search
62
+ },
63
+ placeholder: i18next.t('title.activity instance search'),
64
+ value: this.grist.searchText
65
+ },
66
+ filter: {
67
+ handler: () => {
68
+ this.grist.toggleHeadroom()
69
+ }
70
+ },
71
+ help: 'dataset/activity-instance-search',
72
+ actions: [],
73
+ exportable: {
74
+ name: i18next.t('title.activity instance search'),
75
+ data: this._exportableData.bind(this)
76
+ }
77
+ }
78
+ }
79
+
80
+ render() {
81
+ const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
82
+
83
+ return html`
84
+ <ox-grist
85
+ .mode=${mode}
86
+ .config=${this.gristConfig}
87
+ .fetchHandler=${this.fetchHandler.bind(this)}
88
+ ?url-params-sensitive=${this.active}
89
+ >
90
+ <div slot="headroom">
91
+ <div id="filters">
92
+ <ox-filters-form autofocus without-search></ox-filters-form>
93
+ </div>
94
+
95
+ <div id="sorters">
96
+ Sort
97
+ <mwc-icon
98
+ @click=${e => {
99
+ const target = e.currentTarget
100
+ this.sortersControl.open({
101
+ right: 0,
102
+ top: target.offsetTop + target.offsetHeight
103
+ })
104
+ }}
105
+ >expand_more</mwc-icon
106
+ >
107
+ <ox-popup id="sorter-control">
108
+ <ox-sorters-control> </ox-sorters-control>
109
+ </ox-popup>
110
+ </div>
111
+
112
+ <div id="modes">
113
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
114
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
115
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
116
+ </div>
117
+ </div>
118
+ </ox-grist>
119
+ `
120
+ }
121
+
122
+ pageUpdated(changes, lifecycle) {
123
+ if (this.active) {
124
+ this.activityId = lifecycle.resourceId
125
+ return
126
+ }
127
+ }
128
+
129
+ async updated(changes) {
130
+ if (changes.has('activityId')) {
131
+ const response = await client.query({
132
+ query: gql`
133
+ query ($id: String!) {
134
+ activity(id: $id) {
135
+ id
136
+ name
137
+ description
138
+ searchKeys {
139
+ name
140
+ description
141
+ inputKey
142
+ tKey
143
+ }
144
+ }
145
+ }
146
+ `,
147
+ variables: {
148
+ id: this.activityId
149
+ }
150
+ })
151
+
152
+ this.activity = response.data.activity
153
+ this.searchKeys = this.activity?.searchKeys
154
+ this.refreshGristConfig()
155
+
156
+ this.grist.fetch()
157
+ }
158
+ }
159
+
160
+ getSearchKeyColumns() {
161
+ return (
162
+ this.searchKeys?.map((item, index) => {
163
+ return {
164
+ type: 'string',
165
+ name: `key0${index + 1}`,
166
+ header: item.tKey ? i18next.t(item.tKey) : `key0${index + 1}`,
167
+ record: {
168
+ editable: false
169
+ },
170
+ sortable: true,
171
+ filter: 'i_like',
172
+ width: 120,
173
+ imex: true
174
+ }
175
+ }) || []
176
+ )
177
+ }
178
+
179
+ refreshGristConfig() {
180
+ const today = new Date().toISOString().split('T')[0]
181
+
182
+ this.gristConfig = {
183
+ list: {
184
+ fields: ['name', 'description'],
185
+ details: ['input', 'updatedAt']
186
+ },
187
+ columns: [
188
+ { type: 'gutter', gutterName: 'sequence' },
189
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
190
+ {
191
+ type: 'gutter',
192
+ gutterName: 'button',
193
+ icon: 'assignment',
194
+ handlers: {
195
+ click: (columns, data, column, record, rowIndex) => {
196
+ openPopup(
197
+ html`
198
+ <activity-instance-view
199
+ activity-instance-id=${record.id}
200
+ style="background-color: white;"
201
+ ></activity-instance-view>
202
+ `,
203
+ {
204
+ backdrop: true,
205
+ size: 'large',
206
+ title: i18next.t('title.activity instance view')
207
+ }
208
+ )
209
+ }
210
+ }
211
+ },
212
+ {
213
+ type: 'string',
214
+ name: 'name',
215
+ label: true,
216
+ header: i18next.t('field.name'),
217
+ record: {
218
+ editable: false
219
+ },
220
+ filter: 'search',
221
+ sortable: true,
222
+ width: 120,
223
+ imex: true
224
+ },
225
+ {
226
+ type: 'string',
227
+ name: 'description',
228
+ label: true,
229
+ header: i18next.t('field.description'),
230
+ record: {
231
+ editable: false
232
+ },
233
+ filter: 'search',
234
+ width: 150,
235
+ imex: true
236
+ },
237
+ ...this.getSearchKeyColumns(),
238
+ {
239
+ type: 'json5',
240
+ name: 'input',
241
+ header: i18next.t('field.input'),
242
+ record: {
243
+ editable: false
244
+ },
245
+ hidden: true,
246
+ imex: true
247
+ },
248
+ {
249
+ type: 'json5',
250
+ name: 'output',
251
+ header: i18next.t('field.output'),
252
+ record: {
253
+ editable: false
254
+ },
255
+ hidden: true,
256
+ imex: true
257
+ },
258
+ {
259
+ type: 'resource-object',
260
+ name: 'updater',
261
+ header: i18next.t('field.updater'),
262
+ sortable: true,
263
+ width: 120,
264
+ imex: true
265
+ },
266
+ {
267
+ type: 'datetime',
268
+ name: 'updatedAt',
269
+ header: i18next.t('field.updated_at'),
270
+ sortable: true,
271
+ width: 180,
272
+ imex: true
273
+ }
274
+ ],
275
+ rows: {
276
+ appendable: false,
277
+ selectable: {
278
+ multiple: true
279
+ }
280
+ },
281
+ sorters: [
282
+ {
283
+ name: 'updatedAt',
284
+ desc: true
285
+ }
286
+ ]
287
+ }
288
+ }
289
+
290
+ async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {
291
+ if (!this.activity) {
292
+ return { records: [], total: 0 }
293
+ }
294
+
295
+ const response = await client.query({
296
+ query: gql`
297
+ query ($activityId: String!, $filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
298
+ responses: activityInstancesByActivity(
299
+ activityId: $activityId
300
+ filters: $filters
301
+ pagination: $pagination
302
+ sortings: $sortings
303
+ ) {
304
+ items {
305
+ id
306
+ name
307
+ description
308
+ key01
309
+ key02
310
+ key03
311
+ key04
312
+ key05
313
+ input
314
+ output
315
+ updater {
316
+ id
317
+ name
318
+ }
319
+ updatedAt
320
+ }
321
+ total
322
+ }
323
+ }
324
+ `,
325
+ variables: {
326
+ activityId: this.activityId,
327
+ filters,
328
+ pagination: { page, limit },
329
+ sortings
330
+ }
331
+ })
332
+
333
+ return {
334
+ total: response.data.responses.total || 0,
335
+ records: response.data.responses.items || []
336
+ }
337
+ }
338
+
339
+ _exportableData() {
340
+ let records = [] as GristRecord[]
341
+ if (this.grist.selected && this.grist.selected.length > 0) {
342
+ records = this.grist.selected
343
+ } else {
344
+ records = this.grist.data.records
345
+ }
346
+
347
+ var headerSetting = this.grist.compiledConfig.columns
348
+ .filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
349
+ .map(column => {
350
+ return column.imex === true
351
+ ? {
352
+ header: column.header.renderer(column),
353
+ key: column.name,
354
+ width: column.width,
355
+ type: column.type
356
+ }
357
+ : column.imex
358
+ })
359
+
360
+ var data = records.map(item => {
361
+ return {
362
+ id: item.id,
363
+ ...this.gristConfig.columns
364
+ .filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
365
+ .reduce((record, column) => {
366
+ const key = column.imex === true ? column.name : column.imex.key
367
+ record[key] = key
368
+ .split('.')
369
+ .reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
370
+ return record
371
+ }, {})
372
+ }
373
+ })
374
+
375
+ return { header: headerSetting, data: data }
376
+ }
377
+ }
@@ -0,0 +1,135 @@
1
+ import gql from 'graphql-tag'
2
+ import { css, html, LitElement } from 'lit'
3
+ import { customElement, property, query, state } from 'lit/decorators.js'
4
+
5
+ import { client } from '@operato/graphql'
6
+ import { i18next, localize } from '@operato/i18n'
7
+ import { ScrollbarStyles } from '@operato/styles'
8
+
9
+ import { ActivityInstance } from '../../types/activity-instance'
10
+
11
+ @customElement('activity-instance-view')
12
+ export class ActivityInstanceView extends localize(i18next)(LitElement) {
13
+ static styles = [
14
+ ScrollbarStyles,
15
+ css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+
20
+ background-color: #fff;
21
+ }
22
+
23
+ div[content] {
24
+ flex: 1;
25
+
26
+ display: flex;
27
+ overflow: auto;
28
+ }
29
+ `
30
+ ]
31
+
32
+ @property({
33
+ type: String,
34
+ attribute: 'activity-instance-id'
35
+ })
36
+ activityInstanceId?: string
37
+
38
+ @state() activityInstance?: ActivityInstance
39
+
40
+ render() {
41
+ if (!this.activityInstance) {
42
+ return html`<div>no activity instance info.</div>`
43
+ }
44
+ const { id, name, description, activity } = this.activityInstance
45
+ const instance = this.activityInstance
46
+
47
+ return html`
48
+ <div>name: ${name}</div>
49
+ <div>description: ${description}</div>
50
+ ${this.renderSearchKeys()} ${this.renderInOut()}
51
+ `
52
+ }
53
+
54
+ renderSearchKeys() {
55
+ const { key01, key02, key03, key04, key05 } = this.activityInstance!
56
+
57
+ return html`
58
+ <div>key01: ${key01}</div>
59
+ <div>key02: ${key02}</div>
60
+ <div>key03: ${key03}</div>
61
+ <div>key04: ${key04}</div>
62
+ <div>key05: ${key05}</div>
63
+ `
64
+ }
65
+
66
+ renderInOut() {
67
+ const { input, output } = this.activityInstance!
68
+
69
+ return html`
70
+ <div>input: ${input}</div>
71
+ <div>output: ${output}</div>
72
+ `
73
+ }
74
+
75
+ updated(changes) {
76
+ if (changes.has('activityInstanceId')) {
77
+ this.fetchActivityInstance()
78
+ }
79
+ }
80
+
81
+ async fetchActivityInstance() {
82
+ const id = this.activityInstanceId
83
+
84
+ const response = await client.query({
85
+ query: gql`
86
+ query ($id: String!) {
87
+ activityInstance(id: $id) {
88
+ id
89
+ name
90
+ description
91
+ key01
92
+ key02
93
+ key03
94
+ key04
95
+ key05
96
+ input
97
+ output
98
+ activity {
99
+ id
100
+ name
101
+ description
102
+ }
103
+ activityThreads {
104
+ state
105
+ transaction
106
+ output
107
+ assignee {
108
+ id
109
+ name
110
+ email
111
+ }
112
+ round
113
+ assignedAt
114
+ startedAt
115
+ terminatedAt
116
+ }
117
+ updater {
118
+ id
119
+ name
120
+ }
121
+ assignedAt
122
+ startedAt
123
+ terminatedAt
124
+ updatedAt
125
+ }
126
+ }
127
+ `,
128
+ variables: {
129
+ id
130
+ }
131
+ })
132
+
133
+ this.activityInstance = response.data.activityInstance
134
+ }
135
+ }