@steedos/standard-process-approval 2.7.27-beta.6 → 3.0.0-beta.100
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/applications/process_automation.app.yml +1 -38
- package/main/default/client/core.client.js +0 -31
- package/main/default/client/process.client.js +17 -21
- package/main/default/objectTranslations/workflow_notifications.zh-CN/workflow_notifications.zh-CN.objectTranslation.yml +1 -1
- package/main/default/objectTranslations/workflow_outbound_messages.zh-CN/workflow_outbound_messages.zh-CN.objectTranslation.yml +1 -1
- package/main/default/objects/process/approval/process_definition/buttons/copy.button.yml +58 -0
- package/main/default/objects/process/approval/process_definition/buttons/customize.button.yml +135 -0
- package/main/default/objects/process/approval/process_definition/buttons/disable.button.yml +64 -0
- package/main/default/objects/process/approval/process_definition/buttons/enable.button.yml +64 -0
- package/main/default/objects/process/approval/{process_definition.object.yml → process_definition/process_definition.object.yml} +48 -16
- package/main/default/objects/process/approval/process_definition.action.js +39 -56
- package/main/default/objects/process/approval/process_node.object.yml +58 -24
- package/main/default/objects/process_instance_history/buttons/approve.button.yml +0 -3
- package/main/default/objects/process_instance_history/buttons/reassign.button.yml +0 -3
- package/main/default/objects/process_instance_history/buttons/recall.button.yml +0 -4
- package/main/default/objects/process_instance_history/buttons/reject.button.yml +0 -3
- package/main/default/objects/process_instance_history/pages/process_instance_detail.page.amis.json +38 -43
- package/main/default/objects/workflow-actions/action_field_updates.action.js +1 -1
- package/main/default/objects/workflow-actions/action_field_updates.object.yml +1 -0
- package/main/default/objects/workflow-actions/workflow_notifications.action.js +1 -1
- package/main/default/objects/workflow-actions/workflow_notifications.object.yml +1 -0
- package/main/default/objects/workflow-actions/workflow_outbound_messages/workflow_outbound_messages.object.yml +2 -1
- package/main/default/objects/workflow-actions/workflow_rule.action.js +1 -1
- package/main/default/objects/workflow-actions/workflow_rule.object.yml +26 -24
- package/main/default/pages/process_definition_form.page.amis.json +35 -0
- package/main/default/pages/process_definition_form.page.yml +13 -0
- package/main/default/pages/process_node_form.page.amis.json +65 -0
- package/main/default/pages/process_node_form.page.yml +13 -0
- package/main/default/pages/workflow_notifications_form.page.amis.json +47 -0
- package/main/default/pages/workflow_notifications_form.page.yml +13 -0
- package/main/default/pages/workflow_rule_form.page.amis.json +55 -0
- package/main/default/pages/workflow_rule_form.page.yml +13 -0
- package/main/default/services/action_field_updates.service.js +3 -3
- package/main/default/services/approval_process.service.js +70 -2
- package/main/default/triggers/action_field_updates.trigger.js +3 -121
- package/main/default/triggers/process_definition.trigger.js +73 -12
- package/main/default/triggers/process_instance_history.trigger.js +8 -1
- package/main/default/triggers/process_node.trigger.js +2 -4
- package/main/default/triggers/workflow_notifications.trigger.js +3 -115
- package/main/default/triggers/workflow_outbound_messages.trigger.js +3 -133
- package/main/default/triggers/workflow_rule.trigger.js +4 -77
- package/package.json +3 -3
- package/package.service.js +1 -1
- package/main/default/client/action_field_updates.client.js +0 -155
- package/main/default/client/workflow_notifications.client.js +0 -74
- package/public/.md +0 -3
- package/src/.md +0 -3
- package/webapp/.md +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "service",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "steedos-object-form",
|
|
6
|
+
"label": "对象表单",
|
|
7
|
+
"objectApiName": "process_definition",
|
|
8
|
+
"recordId": "${recordId}",
|
|
9
|
+
"className": "",
|
|
10
|
+
"enableTabs": false,
|
|
11
|
+
"mode": "edit",
|
|
12
|
+
"layout": "normal",
|
|
13
|
+
"tabsMode": "",
|
|
14
|
+
"fieldsExtend": {
|
|
15
|
+
"entry_criteria": {
|
|
16
|
+
"amis": {
|
|
17
|
+
"type": "service",
|
|
18
|
+
"schemaApi": {
|
|
19
|
+
"method": "get",
|
|
20
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
|
|
21
|
+
"cache": 30000,
|
|
22
|
+
"adaptor": "const field = context.uiSchema.fields.entry_criteria; const variables = SteedosUI.getFormulaVariables(payload.data.options); \n var fieldSchema={label: field.label, type:'input-formula', name: 'entry_criteria', 'evalMode': false, variableMode: 'tabs', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return {...payload, data:fieldSchema};",
|
|
23
|
+
"trackExpression": "${object_name}",
|
|
24
|
+
"sendOn": "${object_name}"
|
|
25
|
+
},
|
|
26
|
+
"dsType": "api"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"data": {},
|
|
33
|
+
"name": "page_process_definition_form",
|
|
34
|
+
"dsType": "api"
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: process_definition_form
|
|
2
|
+
is_active: true
|
|
3
|
+
label: 批准过程表单
|
|
4
|
+
locked: false
|
|
5
|
+
object_name: process_definition
|
|
6
|
+
pageAssignments:
|
|
7
|
+
- type: orgDefault
|
|
8
|
+
page: process_definition_form
|
|
9
|
+
desktop: true
|
|
10
|
+
mobile: true
|
|
11
|
+
render_engine: amis
|
|
12
|
+
type: form
|
|
13
|
+
widgets: []
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "service",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "steedos-object-form",
|
|
6
|
+
"label": "对象表单",
|
|
7
|
+
"objectApiName": "process_node",
|
|
8
|
+
"recordId": "${recordId}",
|
|
9
|
+
"className": "",
|
|
10
|
+
"enableTabs": false,
|
|
11
|
+
"mode": "edit",
|
|
12
|
+
"layout": "normal",
|
|
13
|
+
"tabsMode": "",
|
|
14
|
+
"id": "u:1c918e931a42",
|
|
15
|
+
"onEvent": {
|
|
16
|
+
"inited": {
|
|
17
|
+
"actions": [
|
|
18
|
+
{
|
|
19
|
+
"actionType": "ajax",
|
|
20
|
+
"api": {
|
|
21
|
+
"method": "get",
|
|
22
|
+
"url": "${context.rootUrl}/api/v1/process_definition/${process_definition}?fields=[\"object_name\"]",
|
|
23
|
+
"cache": 30000,
|
|
24
|
+
"adaptor": "return {...payload, data:{processDefinitionObjectName: payload.data.object_name}};",
|
|
25
|
+
"headers": {
|
|
26
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"actionType": "setValue",
|
|
32
|
+
"args": {
|
|
33
|
+
"value": {
|
|
34
|
+
"processDefinitionObjectName": "${event.data.processDefinitionObjectName}"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"componentId": "page_process_node_form"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"fieldsExtend": {
|
|
43
|
+
"entry_criteria": {
|
|
44
|
+
"amis": {
|
|
45
|
+
"type": "service",
|
|
46
|
+
"id": "u:46bf09af8f92",
|
|
47
|
+
"schemaApi": {
|
|
48
|
+
"method": "get",
|
|
49
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${processDefinitionObjectName}/fields/options",
|
|
50
|
+
"cache": 30000,
|
|
51
|
+
"adaptor": "const field = context.uiSchema.fields.entry_criteria; const variables = SteedosUI.getFormulaVariables(payload.data.options); \n var fieldSchema={label: field.label, type:'input-formula', name: 'entry_criteria', 'evalMode': false, variableMode: 'tabs', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return {...payload, data:fieldSchema};",
|
|
52
|
+
"trackExpression": "${processDefinitionObjectName}",
|
|
53
|
+
"sendOn": "${processDefinitionObjectName}"
|
|
54
|
+
},
|
|
55
|
+
"dsType": "api"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"data": {},
|
|
62
|
+
"name": "page_process_node_form",
|
|
63
|
+
"dsType": "api",
|
|
64
|
+
"id": "page_process_node_form"
|
|
65
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "service",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "steedos-object-form",
|
|
6
|
+
"label": "对象表单",
|
|
7
|
+
"objectApiName": "workflow_notifications",
|
|
8
|
+
"recordId": "${recordId}",
|
|
9
|
+
"className": "",
|
|
10
|
+
"id": "u:b3d626885b90",
|
|
11
|
+
"enableTabs": false,
|
|
12
|
+
"mode": "edit",
|
|
13
|
+
"layout": "normal",
|
|
14
|
+
"tabsMode": "",
|
|
15
|
+
"fieldsExtend": {
|
|
16
|
+
"title": {
|
|
17
|
+
"amis": {
|
|
18
|
+
"type": "service",
|
|
19
|
+
"schemaApi": {
|
|
20
|
+
"method": "get",
|
|
21
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
|
|
22
|
+
"cache": 30000,
|
|
23
|
+
"adaptor": "const fields = context.uiSchema.fields;\nconst titleField = fields && fields.title;\nconst bodyField = fields && fields.body;\nconst variables = SteedosUI.getFormulaVariables(payload.data.options);\n var fieldSchema=[{\n label: titleField.label,\n type: 'input-formula',\n name: 'title',\n evalMode: false,\n variableMode: 'tabs',\n variables: variables,\n labelRemark: titleField.inlineHelpText,\n description: titleField.description\n}, {\n label: bodyField.label,\n type: 'input-formula',\n name: 'body',\n evalMode: false,\n variableMode: 'tabs',\n variables: variables,\n labelRemark: bodyField.inlineHelpText,\n description: bodyField.description\n}]\nreturn {...payload, data:fieldSchema};",
|
|
24
|
+
"trackExpression": "${object_name}",
|
|
25
|
+
"sendOn": "${object_name}",
|
|
26
|
+
"requestAdaptor": "",
|
|
27
|
+
"messages": {}
|
|
28
|
+
},
|
|
29
|
+
"dsType": "api",
|
|
30
|
+
"id": "u:508198dbfac7",
|
|
31
|
+
"initFetchSchema": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"body": {
|
|
35
|
+
"amis": {
|
|
36
|
+
"id": "u:18ca55507d93",
|
|
37
|
+
"hidden": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"data": {},
|
|
44
|
+
"name": "page_workflow_notifications_form",
|
|
45
|
+
"id": "u:35c197d6b61a",
|
|
46
|
+
"dsType": "api"
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: workflow_notifications_form
|
|
2
|
+
is_active: true
|
|
3
|
+
label: 消息提醒表单
|
|
4
|
+
locked: false
|
|
5
|
+
object_name: workflow_notifications
|
|
6
|
+
pageAssignments:
|
|
7
|
+
- type: orgDefault
|
|
8
|
+
page: workflow_notifications_form
|
|
9
|
+
desktop: true
|
|
10
|
+
mobile: true
|
|
11
|
+
render_engine: amis
|
|
12
|
+
type: form
|
|
13
|
+
widgets: []
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "service",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "steedos-object-form",
|
|
6
|
+
"label": "对象表单",
|
|
7
|
+
"objectApiName": "workflow_rule",
|
|
8
|
+
"recordId": "${recordId}",
|
|
9
|
+
"className": "",
|
|
10
|
+
"id": "u:b3d626885b90",
|
|
11
|
+
"enableTabs": false,
|
|
12
|
+
"mode": "edit",
|
|
13
|
+
"layout": "normal",
|
|
14
|
+
"tabsMode": "",
|
|
15
|
+
"initApiAdaptor": "if (recordId) {\n var data = payload.data;\n if (data) {\n data.filters = window.amisConvert.filtersToConditions(data.filters || []);\n }\n payload.data = data;\n}\nreturn payload;",
|
|
16
|
+
"apiRequestAdaptor": "if (formData.filters) {\n formData.filters = window.amisConvert.conditionsToFilters(formData.filters);\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n",
|
|
17
|
+
"fieldsExtend": {
|
|
18
|
+
"formula": {
|
|
19
|
+
"amis": {
|
|
20
|
+
"type": "service",
|
|
21
|
+
"schemaApi": {
|
|
22
|
+
"method": "get",
|
|
23
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
|
|
24
|
+
"cache": 30000,
|
|
25
|
+
"adaptor": "const field = context.uiSchema.fields.formula; const variables = SteedosUI.getFormulaVariables(payload.data.options); \n var fieldSchema={label: field.label, type:'input-formula', name: 'formula', 'evalMode': false, variableMode: 'tabs', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return {...payload, data:fieldSchema};",
|
|
26
|
+
"trackExpression": "${object_name}",
|
|
27
|
+
"sendOn": "${object_name}"
|
|
28
|
+
},
|
|
29
|
+
"dsType": "api"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"filters": {
|
|
33
|
+
"amis": {
|
|
34
|
+
"type": "condition-builder",
|
|
35
|
+
"description": "",
|
|
36
|
+
"source": {
|
|
37
|
+
"method": "get",
|
|
38
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${object_name}",
|
|
39
|
+
"dataType": "json",
|
|
40
|
+
"headers": {
|
|
41
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"className": "col-span-2 m-0",
|
|
45
|
+
"visibleOn": "${object_name}"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"data": {},
|
|
52
|
+
"name": "page_workflow_rule_form",
|
|
53
|
+
"id": "u:a4758c8d4978",
|
|
54
|
+
"dsType": "api"
|
|
55
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: workflow_rule_form
|
|
2
|
+
is_active: true
|
|
3
|
+
label: 工作流规则表单
|
|
4
|
+
locked: false
|
|
5
|
+
object_name: workflow_rule
|
|
6
|
+
pageAssignments:
|
|
7
|
+
- type: orgDefault
|
|
8
|
+
page: workflow_rule_form
|
|
9
|
+
desktop: true
|
|
10
|
+
mobile: true
|
|
11
|
+
render_engine: amis
|
|
12
|
+
type: form
|
|
13
|
+
widgets: []
|
|
@@ -177,16 +177,16 @@ module.exports = {
|
|
|
177
177
|
const field = objectConfig.fields[fieldName];
|
|
178
178
|
if (field && field.type != 'boolean') {
|
|
179
179
|
options.push({
|
|
180
|
-
label:
|
|
180
|
+
label: steedosI18n.t("action_field_updates_field_operation_options_null",{},lng),
|
|
181
181
|
value: 'null',
|
|
182
182
|
})
|
|
183
183
|
}
|
|
184
184
|
options.push({
|
|
185
|
-
label:
|
|
185
|
+
label: steedosI18n.t("action_field_updates_field_operation_options_formula",{},lng),
|
|
186
186
|
value: 'formula',
|
|
187
187
|
});
|
|
188
188
|
options.push({
|
|
189
|
-
label:
|
|
189
|
+
label: steedosI18n.t("action_field_updates_field_operation_options_literal",{},lng),
|
|
190
190
|
value: 'literal',
|
|
191
191
|
})
|
|
192
192
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 2022-12-14 10:26:50
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
5
|
+
* @LastEditTime: 2025-05-13 12:14:22
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
const { getObjectProcessDefinition, recordSubmit } = require('@steedos/process')
|
|
9
|
+
const objectql = require('@steedos/objectql');
|
|
9
10
|
"use strict";
|
|
10
11
|
/**
|
|
11
12
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
@@ -89,6 +90,73 @@ module.exports = {
|
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @api {call} copy 复制
|
|
95
|
+
* @apiVersion 0.0.0
|
|
96
|
+
* @apiName copy
|
|
97
|
+
* @apiGroup approval_process.service.js
|
|
98
|
+
* @apiBody {String} recordId 记录ID
|
|
99
|
+
* @apiSuccess {String} state 返回复制结果
|
|
100
|
+
* @apiSuccessExample {json} Success-Response:
|
|
101
|
+
* HTTP/1.1 200 OK
|
|
102
|
+
* {
|
|
103
|
+
* "state": "SUCCESS",
|
|
104
|
+
* _id: newPDID
|
|
105
|
+
* }
|
|
106
|
+
* @apiErrorExample {json} Error-Response:
|
|
107
|
+
* HTTP/1.1 200 OK
|
|
108
|
+
* {
|
|
109
|
+
* "state": "FAILURE",
|
|
110
|
+
* "error": ""
|
|
111
|
+
* }
|
|
112
|
+
*/
|
|
113
|
+
copy: {
|
|
114
|
+
// 访问地址: GET /service/api/approval_process/process_definition/:recordId/copy
|
|
115
|
+
rest: {
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: '/process_definition/:recordId/copy'
|
|
118
|
+
},
|
|
119
|
+
params: {
|
|
120
|
+
recordId: { type: 'string' }
|
|
121
|
+
},
|
|
122
|
+
async handler(ctx) {
|
|
123
|
+
try {
|
|
124
|
+
this.broker.logger.info('[service][approval_process]===>', 'process_definition/:recordId/copy', ctx.params.name, ctx.params.recordId)
|
|
125
|
+
const userSession = ctx.meta.user;
|
|
126
|
+
const params = ctx.params;
|
|
127
|
+
const recordId = params.recordId;
|
|
128
|
+
const pdObj = objectql.getObject('process_definition');
|
|
129
|
+
const pnObj = objectql.getObject('process_node');
|
|
130
|
+
const nowTime = new Date().getTime();
|
|
131
|
+
let pd = await pdObj.findOne(recordId, undefined, userSession);
|
|
132
|
+
delete pd._id;
|
|
133
|
+
pd.name = `pd_${nowTime}`; // 名称长度不能大于20个字符;名称只能包含小写字母、数字,必须以字母开头,不能以下划线字符结尾或包含两个连续的下划线字符
|
|
134
|
+
pd.active = false; // 批准过程已启用或者已提交过审批, 禁止添加、删除批准步骤
|
|
135
|
+
pd.is_system = false;
|
|
136
|
+
delete pd.record_permissions
|
|
137
|
+
let newPD = await pdObj.insert(pd);
|
|
138
|
+
let newPDID = newPD._id;
|
|
139
|
+
let pns = await pnObj.find({ filters: ['process_definition', '=', recordId] }, userSession);
|
|
140
|
+
for (let index = 0; index < pns.length; index++) {
|
|
141
|
+
let pn = pns[index];
|
|
142
|
+
delete pn._id;
|
|
143
|
+
pn.process_definition = newPDID;
|
|
144
|
+
pn.name = `pn_${nowTime}_${index}`;
|
|
145
|
+
const now = new Date();
|
|
146
|
+
pn.created = now;
|
|
147
|
+
pn.created_by = userSession.userId
|
|
148
|
+
pn.modified = now;
|
|
149
|
+
pn.modified_by = userSession.userId
|
|
150
|
+
pn.is_system = false;
|
|
151
|
+
delete pn.record_permissions
|
|
152
|
+
await pnObj.directInsert(pn);
|
|
153
|
+
}
|
|
154
|
+
return { state: 'SUCCESS', _id: newPDID };
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return { state: 'FAILURE', error: error.message };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
92
160
|
},
|
|
93
161
|
|
|
94
162
|
/**
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const _ = require("underscore");
|
|
2
|
-
const util = require('@steedos/standard-objects').util;
|
|
3
2
|
const objectql = require("@steedos/objectql");
|
|
4
|
-
const InternalData = require('@steedos/standard-objects').internalData;
|
|
5
3
|
|
|
6
4
|
const checkReevaluateParent = (doc)=>{
|
|
7
5
|
if(doc.reevaluate_on_change && doc.target_object && doc.object_name && doc.target_object != doc.object_name){
|
|
@@ -26,129 +24,13 @@ const getInternalActionFieldUpdates = function(sourceActionFieldUpdates, filters
|
|
|
26
24
|
|
|
27
25
|
module.exports = {
|
|
28
26
|
beforeInsert: async function () {
|
|
29
|
-
await
|
|
27
|
+
await objectql.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
|
|
30
28
|
checkReevaluateParent(this.doc);
|
|
31
29
|
},
|
|
32
30
|
beforeUpdate: async function () {
|
|
33
31
|
if (_.has(this.doc, 'name')) {
|
|
34
|
-
await
|
|
32
|
+
await objectql.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
|
|
35
33
|
}
|
|
36
34
|
checkReevaluateParent(this.doc);
|
|
37
|
-
}
|
|
38
|
-
afterFind: async function(){
|
|
39
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
40
|
-
let fObjectName = filters.object_name;
|
|
41
|
-
if(fObjectName){
|
|
42
|
-
delete filters.object_name;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if(filters._id && filters._id.$ne){
|
|
46
|
-
if(!_.isArray(filters._id.$ne)){
|
|
47
|
-
filters._id.$ne = [filters._id.$ne]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let dbActionFieldUpdates = Creator.getCollection("action_field_updates").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let actionFieldUpdates = [];
|
|
55
|
-
|
|
56
|
-
if(filters.name && filters.name.$in){
|
|
57
|
-
for(let name of filters.name.$in){
|
|
58
|
-
let actionFieldUpdate = await objectql.getActionFieldUpdate(name);
|
|
59
|
-
if(actionFieldUpdate){
|
|
60
|
-
actionFieldUpdates.push(actionFieldUpdate);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}else if(filters._id && !filters._id.$ne){
|
|
64
|
-
let action = await objectql.getActionFieldUpdate(filters._id);
|
|
65
|
-
if(action){
|
|
66
|
-
actionFieldUpdates.push(action);
|
|
67
|
-
}
|
|
68
|
-
}else if(fObjectName){
|
|
69
|
-
actionFieldUpdates = await objectql.getObjectActionFieldUpdates(fObjectName);
|
|
70
|
-
}else{
|
|
71
|
-
actionFieldUpdates = await objectql.getAllActionFieldUpdates();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if(filters._id && filters._id.$ne){
|
|
75
|
-
for(let neid of filters._id.$ne){
|
|
76
|
-
actionFieldUpdates = _.filter(actionFieldUpdates, function(item){
|
|
77
|
-
return item._id !== neid
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters, dbActionFieldUpdates);
|
|
83
|
-
|
|
84
|
-
if(actionFieldUpdates && actionFieldUpdates.length>0){
|
|
85
|
-
this.data.values = this.data.values.concat(actionFieldUpdates)
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
afterCount: async function(){
|
|
89
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
90
|
-
|
|
91
|
-
let fObjectName = filters.object_name;
|
|
92
|
-
if(fObjectName){
|
|
93
|
-
delete filters.object_name;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if(filters._id && filters._id.$ne){
|
|
97
|
-
if(!_.isArray(filters._id.$ne)){
|
|
98
|
-
filters._id.$ne = [filters._id.$ne]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let dbActionFieldUpdates = Creator.getCollection("action_field_updates").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
103
|
-
|
|
104
|
-
let actionFieldUpdates = [];
|
|
105
|
-
|
|
106
|
-
if(filters.name && filters.name.$in){
|
|
107
|
-
for(let name of filters.name.$in){
|
|
108
|
-
let actionFieldUpdate = await objectql.getActionFieldUpdate(name);
|
|
109
|
-
if(actionFieldUpdate){
|
|
110
|
-
actionFieldUpdates.push(actionFieldUpdate);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}else if(filters._id && !filters._id.$ne){
|
|
114
|
-
let action = await objectql.getActionFieldUpdate(filters._id);
|
|
115
|
-
if(action){
|
|
116
|
-
actionFieldUpdates.push(action);
|
|
117
|
-
}
|
|
118
|
-
}else if(fObjectName){
|
|
119
|
-
actionFieldUpdates = await objectql.getObjectActionFieldUpdates(fObjectName);
|
|
120
|
-
}else{
|
|
121
|
-
actionFieldUpdates = await objectql.getAllActionFieldUpdates();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if(filters._id && filters._id.$ne){
|
|
125
|
-
for(let neid of filters._id.$ne){
|
|
126
|
-
actionFieldUpdates = _.filter(actionFieldUpdates, function(item){
|
|
127
|
-
return item._id !== neid
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters, dbActionFieldUpdates);
|
|
133
|
-
|
|
134
|
-
if(actionFieldUpdates && actionFieldUpdates.length>0){
|
|
135
|
-
this.data.values = this.data.values + actionFieldUpdates.length
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
afterFindOne: async function(){
|
|
139
|
-
if(_.isEmpty(this.data.values)){
|
|
140
|
-
let id = this.id
|
|
141
|
-
|
|
142
|
-
let dbFieldUpdate = Creator.getCollection("action_field_updates").find({name: id}).fetch();
|
|
143
|
-
if(dbFieldUpdate && dbFieldUpdate.length > 0){
|
|
144
|
-
this.data.values = dbFieldUpdate[0];
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let actionFieldUpdate = await objectql.getActionFieldUpdate(id);
|
|
149
|
-
if(actionFieldUpdate){
|
|
150
|
-
this.data.values = actionFieldUpdate;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
35
|
+
}
|
|
154
36
|
}
|
|
@@ -1,17 +1,78 @@
|
|
|
1
1
|
const _ = require("underscore");
|
|
2
|
-
const
|
|
2
|
+
const { checkAPIName } = require('@steedos/objectql')
|
|
3
3
|
const objectql = require('@steedos/objectql');
|
|
4
4
|
const register = require('@steedos/metadata-registrar');
|
|
5
|
-
const
|
|
5
|
+
const odataMongodb = require("@steedos/odata-v4-mongodb");
|
|
6
|
+
|
|
7
|
+
function parserFilters(filters){
|
|
8
|
+
if(_.isString(filters)){
|
|
9
|
+
filters = odataMongodb.createFilter(filters)
|
|
10
|
+
}
|
|
11
|
+
let query = {};
|
|
12
|
+
if(_.isArray(filters) && filters.length > 0 && _.isArray(filters[0])){
|
|
13
|
+
_.each(filters,function(filter){
|
|
14
|
+
Object.assign(query, parserFilters(filter))
|
|
15
|
+
})
|
|
16
|
+
}else if(_.isArray(filters) && filters.length > 0){
|
|
17
|
+
if(filters[1] && filters[1] == '='){
|
|
18
|
+
let key = filters[0]
|
|
19
|
+
let value = filters[2]
|
|
20
|
+
Object.assign(query, {[key]: value})
|
|
21
|
+
}else if(filters[1] && (filters[1] == '!=' || filters[1] == '<>')){
|
|
22
|
+
let key = filters[0]
|
|
23
|
+
let value = filters[2]
|
|
24
|
+
Object.assign(query, {[key]: {$ne: value}})
|
|
25
|
+
}else if(filters[1] && filters[1] == 'in'){
|
|
26
|
+
let key = filters[0]
|
|
27
|
+
let value = filters[2]
|
|
28
|
+
Object.assign(query, {[key]: {$in: value}})
|
|
29
|
+
}else{
|
|
30
|
+
_.each(filters,function(filter){
|
|
31
|
+
let parsedFilters = parserFilters(filter);
|
|
32
|
+
if(query._id && query._id.$ne && parsedFilters._id && parsedFilters._id.$ne){
|
|
33
|
+
parsedFilters._id.$ne = [parsedFilters._id.$ne]
|
|
34
|
+
parsedFilters._id.$ne = parsedFilters._id.$ne.concat(query._id.$ne);
|
|
35
|
+
delete query._id;
|
|
36
|
+
}
|
|
37
|
+
Object.assign(query, parsedFilters)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}else{
|
|
41
|
+
_.each(filters, function (v, k) {
|
|
42
|
+
if(_.isArray(v) && v.length > 0){
|
|
43
|
+
Object.assign(query, parserFilters(v))
|
|
44
|
+
}else{
|
|
45
|
+
if (k === '$and') {
|
|
46
|
+
Object.assign(query, parserFilters(v))
|
|
47
|
+
} else {
|
|
48
|
+
if(_.isArray(filters) && _.isObject(v)){
|
|
49
|
+
Object.assign(query, v)
|
|
50
|
+
}else{
|
|
51
|
+
Object.assign(query, {[k]: v})
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
return query;
|
|
59
|
+
}
|
|
6
60
|
|
|
7
61
|
function setSpaceAndOwner(record, that){
|
|
8
62
|
record['space'] = that.spaceId
|
|
9
63
|
record['owner'] = that.userId
|
|
10
64
|
}
|
|
11
65
|
|
|
12
|
-
const getInternalApprovalProcesses = function(sourceApprovalProcesses, filters){
|
|
66
|
+
const getInternalApprovalProcesses = async function(sourceApprovalProcesses, filters){
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const datasource = objectql.getDataSource('default');
|
|
70
|
+
const adapter = datasource.adapter
|
|
71
|
+
await adapter.connect()
|
|
72
|
+
const collection = adapter.collection('process_definition');
|
|
73
|
+
|
|
13
74
|
delete filters.active;
|
|
14
|
-
let dbApprovalProcesses =
|
|
75
|
+
let dbApprovalProcesses = await collection.find(filters, {fields:{_id:1, name:1}}).toArray();
|
|
15
76
|
let approvalProcesses = [];
|
|
16
77
|
|
|
17
78
|
if(!filters.is_system){
|
|
@@ -28,7 +89,7 @@ const getInternalApprovalProcesses = function(sourceApprovalProcesses, filters){
|
|
|
28
89
|
|
|
29
90
|
module.exports = {
|
|
30
91
|
beforeInsert: async function () {
|
|
31
|
-
await
|
|
92
|
+
await checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
|
|
32
93
|
|
|
33
94
|
objectql.checkFormula(this.doc.entry_criteria, this.doc.object_name)
|
|
34
95
|
|
|
@@ -47,14 +108,14 @@ module.exports = {
|
|
|
47
108
|
}
|
|
48
109
|
};
|
|
49
110
|
if (_.has(this.doc, 'name')) {
|
|
50
|
-
await
|
|
111
|
+
await checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
|
|
51
112
|
}
|
|
52
113
|
|
|
53
114
|
objectql.checkFormula(this.doc.entry_criteria, this.doc.object_name)
|
|
54
115
|
},
|
|
55
116
|
afterFind: async function(){
|
|
56
117
|
let spaceId = this.spaceId;
|
|
57
|
-
let filters =
|
|
118
|
+
let filters = parserFilters(this.query.filters)
|
|
58
119
|
let approvalProcesses = [];
|
|
59
120
|
if(filters.name){
|
|
60
121
|
approvalProcess = register.getSourceApprovalProcess(filters.name);
|
|
@@ -69,7 +130,7 @@ module.exports = {
|
|
|
69
130
|
approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
|
|
70
131
|
}
|
|
71
132
|
|
|
72
|
-
approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
|
|
133
|
+
approvalProcesses = await getInternalApprovalProcesses(approvalProcesses, filters);
|
|
73
134
|
|
|
74
135
|
if(approvalProcesses){
|
|
75
136
|
this.data.values = this.data.values.concat(approvalProcesses)
|
|
@@ -77,7 +138,7 @@ module.exports = {
|
|
|
77
138
|
}
|
|
78
139
|
},
|
|
79
140
|
afterAggregate: async function(){
|
|
80
|
-
let filters =
|
|
141
|
+
let filters = parserFilters(this.query.filters)
|
|
81
142
|
let approvalProcesses = [];
|
|
82
143
|
if(filters.name){
|
|
83
144
|
approvalProcess = register.getSourceApprovalProcess(filters.name);
|
|
@@ -92,14 +153,14 @@ module.exports = {
|
|
|
92
153
|
approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
|
|
93
154
|
}
|
|
94
155
|
|
|
95
|
-
approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
|
|
156
|
+
approvalProcesses = await getInternalApprovalProcesses(approvalProcesses, filters);
|
|
96
157
|
|
|
97
158
|
if(approvalProcesses){
|
|
98
159
|
this.data.values = this.data.values.concat(approvalProcesses)
|
|
99
160
|
}
|
|
100
161
|
},
|
|
101
162
|
afterCount: async function(){
|
|
102
|
-
let filters =
|
|
163
|
+
let filters = parserFilters(this.query.filters)
|
|
103
164
|
let approvalProcesses = [];
|
|
104
165
|
if(filters.name){
|
|
105
166
|
approvalProcess = register.getSourceApprovalProcess(filters.name);
|
|
@@ -114,7 +175,7 @@ module.exports = {
|
|
|
114
175
|
approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
|
|
115
176
|
}
|
|
116
177
|
|
|
117
|
-
approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
|
|
178
|
+
approvalProcesses = await getInternalApprovalProcesses(approvalProcesses, filters);
|
|
118
179
|
|
|
119
180
|
if(approvalProcesses){
|
|
120
181
|
this.data.values = this.data.values + approvalProcesses.length
|