@steedos-labs/plugin-workflow 3.0.1 → 3.0.2

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.
@@ -19,7 +19,6 @@ mobile_columns:
19
19
  filter_scope: space
20
20
  filters: !!js/function |
21
21
  function(filters, data){
22
- console.log('inbox ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
23
22
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
24
23
  type: 'get', async: false
25
24
  });
@@ -18,7 +18,6 @@ mobile_columns:
18
18
  filter_scope: space
19
19
  filters: !!js/function |
20
20
  function(filters, data){
21
- console.log('outbox ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
22
21
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
23
22
  type: 'get', async: false
24
23
  });
@@ -18,7 +18,6 @@ mobile_columns:
18
18
  filter_scope: space
19
19
  filters: !!js/function |
20
20
  function(filters, data){
21
- console.log('completed ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
22
21
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
23
22
  type: 'get', async: false
24
23
  });
@@ -9,7 +9,6 @@ columns:
9
9
  filter_scope: space
10
10
  filters: !!js/function |
11
11
  function(filters, data){
12
- console.log('draft ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
13
12
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
14
13
  type: 'get', async: false
15
14
  });
@@ -18,7 +18,6 @@ mobile_columns:
18
18
  filter_scope: space
19
19
  filters: !!js/function |
20
20
  function(filters, data){
21
- console.log('monitor ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
22
21
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
23
22
  type: 'get', async: false
24
23
  });
@@ -18,7 +18,6 @@ mobile_columns:
18
18
  filter_scope: space
19
19
  filters: !!js/function |
20
20
  function(filters, data){
21
- console.log('pending ===filters ===> ',data, `/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`);
22
21
  var result = Steedos.authRequest(`/api/workflow/v2/\${data.listName}/filter?app=\${data.appId}`, {
23
22
  type: 'get', async: false
24
23
  });
@@ -215,4 +215,92 @@ router.post('/api/workflow/v2/nextStep', requireAuthentication, async function (
215
215
  }
216
216
  });
217
217
 
218
+ const calcSteps = async function(instance, flow, flowVersionId, formFields, values, step, track){
219
+ if (!step) {
220
+ step = getStep(flow, flowVersionId, instance.traces[0].step);
221
+ }
222
+ if (!track) {
223
+ track = []
224
+ }
225
+
226
+ var _steps = [];
227
+ var judge = 'approved';
228
+
229
+ _steps.push(step);
230
+ var nextSteps = await getNextSteps(flow, flowVersionId, instance, step, judge, values);
231
+ for (const nextStep of nextSteps) {
232
+ try {
233
+ if (!_.includes(track, nextStep._id)) {
234
+ const __steps = await calcSteps(instance, flow, flowVersionId, formFields, values, nextStep, track.concat(_.map(_steps, '_id')));
235
+ _steps = _steps.concat(__steps)
236
+ }
237
+ } catch (e) {
238
+ console.log(e)
239
+ }
240
+ }
241
+ _steps = _.compact(_.uniqBy(_steps, 'id'));
242
+ return _steps;
243
+ }
244
+
245
+ router.post('/api/workflow/v2/nextSteps', requireAuthentication, async function (req, res) {
246
+ try {
247
+ const userSession = req.user;
248
+ const { instanceId, flowId, values, flowVersionId } = req.body;
249
+ const flow = await objectql.getObject('flows').findOne(flowId);
250
+ const instance = await objectql.getObject('instances').findOne(instanceId);
251
+ const form = await objectql.getObject('forms').findOne(instance.form);
252
+ const { fields } = await UUFlowManager.getFormVersion(form, instance.form_version);
253
+ const resNextSteps = await calcSteps(instance, flow, flowVersionId, fields, values);
254
+ res.status(200).send({
255
+ 'nextSteps': resNextSteps
256
+ });
257
+ } catch (error) {
258
+ console.error(error);
259
+ res.status(200).send({
260
+ error: error.message
261
+ });
262
+ }
263
+ })
264
+
265
+ router.post('/api/workflow/v2/set_instance_steps', requireAuthentication, async function (req, res) {
266
+ try {
267
+ const userSession = req.user;
268
+ const { instanceId, stepId, selected, handler } = req.body;
269
+ if(instanceId === 'none'){
270
+ return res.status(200).send({ status: 0 });
271
+ }
272
+ const instance = await objectql.getObject('instances').findOne(instanceId);
273
+ if(!instance){
274
+ return res.status(200).send({
275
+ error: 'not find instance'
276
+ });
277
+ }
278
+ if(instance.state != 'draft'){
279
+ return res.status(200).send({
280
+ error: 'not allow'
281
+ });
282
+ }
283
+ const doc = {
284
+ ['step_approve.' + stepId]: handler
285
+ };
286
+ if(selected){
287
+ doc.$pull = {
288
+ skip_steps: stepId
289
+ }
290
+ }else{
291
+ doc.$push = {
292
+ skip_steps: stepId
293
+ }
294
+ }
295
+ await objectql.getObject('instances').update(instanceId, doc);
296
+
297
+ return res.status(200).send({ status: 0 });
298
+ } catch (error) {
299
+ console.error(error);
300
+ res.status(200).send({
301
+ error: error.message
302
+ });
303
+ }
304
+ })
305
+
218
306
  exports.default = router;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -372,6 +372,11 @@ tbody .color-priority-muted *{
372
372
  z-index: 900;
373
373
  }
374
374
 
375
+ .instances-sidebar-wrapper{
376
+ overflow-y: auto;
377
+ height: calc(100vh - 50px);
378
+ }
379
+
375
380
  .steedos-instance-related-view-wrapper{
376
381
  .antd-Page-header{
377
382
  display: none;