@steedos-labs/plugin-workflow 3.0.1 → 3.0.3
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/main/default/objects/instance_tasks/listviews/inbox.listview.yml +0 -1
- package/main/default/objects/instance_tasks/listviews/outbox.listview.yml +0 -1
- package/main/default/objects/instances/buttons/instance_delete.button.yml +1 -1
- package/main/default/objects/instances/listviews/completed.listview.yml +0 -1
- package/main/default/objects/instances/listviews/draft.listview.yml +0 -1
- package/main/default/objects/instances/listviews/monitor.listview.yml +0 -1
- package/main/default/objects/instances/listviews/pending.listview.yml +0 -1
- package/main/default/routes/api_workflow_next_step.router.js +88 -0
- package/package.json +5 -5
- package/public/workflow/index.css +5 -0
|
@@ -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
|
});
|
|
@@ -58,7 +58,7 @@ amis_schema: |-
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"confirmText": "${'CustomLabels.confirm_delete' | t}",
|
|
61
|
-
"hiddenOn": "!(record.box == 'draft' || (record.box == 'monitor' && context.user.is_space_admin) \n || (_.includes(record.flow.perms.users_can_admin, context.user.userId) \n || _.intersection(record.flow.perms.orgs_can_admin, context.user.organizations_parents) > 0)\n
|
|
61
|
+
"hiddenOn": "!(record.box == 'draft' || (record.box == 'monitor' && context.user.is_space_admin) \n || (_.includes(record.flow.perms.users_can_admin, context.user.userId) \n || _.intersection(record.flow.perms.orgs_can_admin, context.user.organizations_parents) > 0)\n || (record.box == 'inbox' && record.state == 'draft' && record.forward_from_instance))"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"regions": [
|
|
@@ -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,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos-labs/plugin-workflow",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build:watch": "tsc --watch",
|
|
8
|
-
"release": "npm publish --registry https://registry.npmjs.org &&
|
|
8
|
+
"release": "npm publish --registry https://registry.npmjs.org && npx cnpm sync @steedos-labs/plugin-workflow"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"graphql-parse-resolve-info": "^4.12.3",
|
|
12
|
-
"he": "1.2.0",
|
|
12
|
+
"he": "^1.2.0",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
14
|
"node-schedule": "^2.0.0",
|
|
15
|
-
"formidable": "2.
|
|
16
|
-
"jszip": "3.10.1"
|
|
15
|
+
"formidable": "^2.1.5",
|
|
16
|
+
"jszip": "^3.10.1"
|
|
17
17
|
},
|
|
18
18
|
"private": false,
|
|
19
19
|
"publishConfig": {
|