@steedos/standard-process-approval 2.2.55-beta.16
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/.gitkeep +0 -0
- package/main/default/applications/process_automation.app.yml +49 -0
- package/main/default/client/action_field_updates.client.js +155 -0
- package/main/default/client/core.client.js +134 -0
- package/main/default/client/process.client.js +211 -0
- package/main/default/client/process_node.client.js +36 -0
- package/main/default/client/workflow_notifications.client.js +74 -0
- package/main/default/objectTranslations/action_field_updates.en/action_field_updates.en.objectTranslation.yml +69 -0
- package/main/default/objectTranslations/action_field_updates.zh-CN/action_field_updates.zh-CN.objectTranslation.yml +72 -0
- package/main/default/objectTranslations/process_definition.en/process_definition.en.objectTranslation.yml +150 -0
- package/main/default/objectTranslations/process_definition.zh-CN/process_definition.zh-CN.objectTranslation.yml +145 -0
- package/main/default/objectTranslations/process_flows.en/process_flows.en.objectTranslation.yml +41 -0
- package/main/default/objectTranslations/process_flows.zh-CN/process_flows.zh-CN.objectTranslation.yml +41 -0
- package/main/default/objectTranslations/process_flows_criteria.en/process_flows_criteria.en.objectTranslation.yml +38 -0
- package/main/default/objectTranslations/process_flows_criteria.zh-CN/process_flows_criteria.zh-CN.objectTranslation.yml +38 -0
- package/main/default/objectTranslations/process_flows_criteria_action.en/process_flows_criteria_action.en.objectTranslation.yml +47 -0
- package/main/default/objectTranslations/process_flows_criteria_action.zh-CN/process_flows_criteria_action.zh-CN.objectTranslation.yml +47 -0
- package/main/default/objectTranslations/process_instance.en/process_instance.en.objectTranslation.yml +63 -0
- package/main/default/objectTranslations/process_instance.zh-CN/process_instance.zh-CN.objectTranslation.yml +63 -0
- package/main/default/objectTranslations/process_instance_history.en/process_instance_history.en.objectTranslation.yml +109 -0
- package/main/default/objectTranslations/process_instance_history.zh-CN/process_instance_history.zh-CN.objectTranslation.yml +109 -0
- package/main/default/objectTranslations/process_instance_node.en/process_instance_node.en.objectTranslation.yml +59 -0
- package/main/default/objectTranslations/process_instance_node.zh-CN/process_instance_node.zh-CN.objectTranslation.yml +59 -0
- package/main/default/objectTranslations/process_node.en/process_node.en.objectTranslation.yml +120 -0
- package/main/default/objectTranslations/process_node.zh-CN/process_node.zh-CN.objectTranslation.yml +116 -0
- package/main/default/objectTranslations/workflow_notifications.en/workflow_notifications.en.objectTranslation.yml +41 -0
- package/main/default/objectTranslations/workflow_notifications.zh-CN/workflow_notifications.zh-CN.objectTranslation.yml +44 -0
- package/main/default/objectTranslations/workflow_rule.en/workflow_rule.en.objectTranslation.yml +53 -0
- package/main/default/objectTranslations/workflow_rule.zh-CN/workflow_rule.zh-CN.objectTranslation.yml +60 -0
- package/main/default/objects/process/approval/process_definition.action.js +65 -0
- package/main/default/objects/process/approval/process_definition.function.js +39 -0
- package/main/default/objects/process/approval/process_definition.object.yml +313 -0
- package/main/default/objects/process/approval/process_node.object.yml +267 -0
- package/main/default/objects/process/flows/process_flows.object.yml +48 -0
- package/main/default/objects/process/flows/process_flows_criteria.object.yml +46 -0
- package/main/default/objects/process/flows/process_flows_criteria_action.object.yml +56 -0
- package/main/default/objects/process/process_instance/process_instance.object.yml +65 -0
- package/main/default/objects/process/process_instance/process_instance_history.action.js +26 -0
- package/main/default/objects/process/process_instance/process_instance_history.object.yml +153 -0
- package/main/default/objects/process/process_instance/process_instance_node.object.yml +59 -0
- package/main/default/objects/workflow-actions/action_field_updates.action.js +33 -0
- package/main/default/objects/workflow-actions/action_field_updates.object.yml +197 -0
- package/main/default/objects/workflow-actions/workflow_notifications.action.js +33 -0
- package/main/default/objects/workflow-actions/workflow_notifications.object.yml +107 -0
- package/main/default/objects/workflow-actions/workflow_rule.action.js +33 -0
- package/main/default/objects/workflow-actions/workflow_rule.object.yml +112 -0
- package/main/default/permissionsets/.gitkeep +0 -0
- package/main/default/profiles/.gitkeep +0 -0
- package/main/default/tabs/.gitkeep +0 -0
- package/main/default/triggers/.gitkeep +0 -0
- package/main/default/triggers/action_field_updates.trigger.js +175 -0
- package/main/default/triggers/process_definition.trigger.js +132 -0
- package/main/default/triggers/process_instance_history.trigger.js +42 -0
- package/main/default/triggers/process_node.trigger.js +232 -0
- package/main/default/triggers/workflow_notifications.trigger.js +236 -0
- package/main/default/triggers/workflow_rule.trigger.js +96 -0
- package/package.json +16 -0
- package/package.service.js +75 -0
- package/public/.md +3 -0
- package/src/.md +3 -0
- package/webapp/.md +1 -0
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
_id: process_automation
|
|
2
|
+
name: Process Automation
|
|
3
|
+
icon_slds: approval
|
|
4
|
+
is_creator: false
|
|
5
|
+
admin_menus:
|
|
6
|
+
# 分部管理员可以创建和设置流程及相关参数。
|
|
7
|
+
# - _id: process_automation
|
|
8
|
+
# name: Process Automation
|
|
9
|
+
# permission_sets:
|
|
10
|
+
# - admin
|
|
11
|
+
# expanded: false
|
|
12
|
+
# sort: 500
|
|
13
|
+
- _id: process_definition
|
|
14
|
+
name: Approval Processes
|
|
15
|
+
sort: 400
|
|
16
|
+
permission_sets:
|
|
17
|
+
- admin
|
|
18
|
+
object_name: process_definition
|
|
19
|
+
parent: process_automation
|
|
20
|
+
# - _id: process_actions
|
|
21
|
+
# name: process_actions
|
|
22
|
+
# permission_sets:
|
|
23
|
+
# - admin
|
|
24
|
+
# object_name: process_actions
|
|
25
|
+
# parent: process_automation
|
|
26
|
+
# - _id: process_steps
|
|
27
|
+
# name: process_steps
|
|
28
|
+
# permission_sets:
|
|
29
|
+
# - admin
|
|
30
|
+
# object_name: process_approvals
|
|
31
|
+
# parent: process_automation
|
|
32
|
+
# - _id: process_flows
|
|
33
|
+
# name: process_flows
|
|
34
|
+
# permission_sets:
|
|
35
|
+
# - admin
|
|
36
|
+
# object_name: process_flows
|
|
37
|
+
# parent: process_automation
|
|
38
|
+
# - _id: process_flows_criteria
|
|
39
|
+
# name: process_flows_criteria
|
|
40
|
+
# permission_sets:
|
|
41
|
+
# - admin
|
|
42
|
+
# object_name: process_flows_criteria
|
|
43
|
+
# parent: process_automation
|
|
44
|
+
# - _id: process_flows_criteria_action
|
|
45
|
+
# name: process_flows_criteria_action
|
|
46
|
+
# permission_sets:
|
|
47
|
+
# - admin
|
|
48
|
+
# object_name: process_flows_criteria_action
|
|
49
|
+
# parent: process_automation
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Steedos.ProcessFieldUpdatesManager = {};
|
|
2
|
+
|
|
3
|
+
Steedos.ProcessFieldUpdatesManager.changeSchema = function (doc, schema) {
|
|
4
|
+
var objectSchema = Creator.getObjectSchema(Creator.getObject("action_field_updates"));
|
|
5
|
+
var operation = doc.operation;
|
|
6
|
+
|
|
7
|
+
var hiddenField = function (fieldName) {
|
|
8
|
+
schema._schema[fieldName].autoform.omit = true;
|
|
9
|
+
schema._schema[fieldName].autoform.type = 'hidden';
|
|
10
|
+
}
|
|
11
|
+
// var recordId = Session.get("record_id");
|
|
12
|
+
var objectName = Session.get("object_name");
|
|
13
|
+
var actionObjectName = Session.get("action_object_name");
|
|
14
|
+
var actionOperation = Session.get("cmOperation");
|
|
15
|
+
if (objectName == 'process_node') {
|
|
16
|
+
var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition; //Creator.odata.get("process_node", recordId, "process_definition").process_definition;
|
|
17
|
+
if(processDefinitionId){
|
|
18
|
+
var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
19
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
20
|
+
doc.object_name = object_name;
|
|
21
|
+
}else{
|
|
22
|
+
toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (objectName == 'process_definition') {
|
|
27
|
+
var object_name = null;
|
|
28
|
+
if(actionObjectName == "process_definition"){
|
|
29
|
+
// 当前正在新建或编辑批准过程
|
|
30
|
+
if (actionOperation == 'update') {
|
|
31
|
+
object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name;
|
|
32
|
+
} else {
|
|
33
|
+
object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name;
|
|
34
|
+
}
|
|
35
|
+
if(!object_name){
|
|
36
|
+
toastr.error(t("action_field_updates_field__error_process_definition_object_required"));
|
|
37
|
+
}
|
|
38
|
+
}else{
|
|
39
|
+
// 当前正在新建或编辑批准过程以外其他对象,目前只有批准过程详细界面新建或编辑批准步骤
|
|
40
|
+
if (actionOperation == 'update') {
|
|
41
|
+
var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition;
|
|
42
|
+
if(processDefinitionId){
|
|
43
|
+
object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
44
|
+
}
|
|
45
|
+
else{
|
|
46
|
+
toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
var formValues = AutoForm.getFormValues("creatorAddRelatedForm");
|
|
50
|
+
if(!formValues){
|
|
51
|
+
// 有可能是在批准过程详细界面点击了批准步骤列表顶部的链接进入了“相关批准步骤列表界面”然后点击的右上角的新建按钮触发的
|
|
52
|
+
formValues = AutoForm.getFormValues("creatorAddForm");
|
|
53
|
+
}
|
|
54
|
+
var processDefinitionId = formValues.insertDoc.process_definition;
|
|
55
|
+
if(processDefinitionId){
|
|
56
|
+
object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
57
|
+
}
|
|
58
|
+
else{
|
|
59
|
+
toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
64
|
+
doc.object_name = object_name;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (objectName == 'workflow_rule') {
|
|
68
|
+
var object_name = null;
|
|
69
|
+
if (actionOperation == 'update') {
|
|
70
|
+
object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name //Creator.odata.get("workflow_rule", Session.get("record_id"), "object_name").object_name;
|
|
71
|
+
} else {
|
|
72
|
+
object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name
|
|
73
|
+
}
|
|
74
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
75
|
+
if(object_name){
|
|
76
|
+
doc.object_name = object_name;
|
|
77
|
+
}
|
|
78
|
+
else{
|
|
79
|
+
toastr.error(t("action_field_updates_field__error_workflow_rule_object_required"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// if(doc.process_definition){
|
|
84
|
+
// hiddenField('process_node');
|
|
85
|
+
// schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['final_approval','final_rejection','recall','initial_submission'], option.value)});
|
|
86
|
+
// var pid = doc.process_definition;
|
|
87
|
+
// if(_.isObject(pid)){
|
|
88
|
+
// if(_.has(pid, 'ids') && pid.ids.length > 0){
|
|
89
|
+
// pid = pid.ids[0];
|
|
90
|
+
// }else{
|
|
91
|
+
// pid = pid._id;
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
|
|
95
|
+
// schema._schema.object_name.optionsFunction = function(){var _obj = Creator.getObject(object_name); return [{label: _obj.label, value: _obj.name, icon: _obj.icon}]}
|
|
96
|
+
// doc.object_name = object_name;
|
|
97
|
+
// }else{
|
|
98
|
+
// schema._schema.process_node = objectSchema.process_node;
|
|
99
|
+
// schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['approval','rejection'], option.value)})
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
// if(doc.process_node){
|
|
103
|
+
// hiddenField('process_definition');
|
|
104
|
+
// var pnid = doc.process_node;
|
|
105
|
+
// if(_.isObject(pnid)){
|
|
106
|
+
// if(_.has(pnid, 'ids') && pnid.ids.length > 0){
|
|
107
|
+
// pnid = pnid.ids[0];
|
|
108
|
+
// }else{
|
|
109
|
+
// pnid = pnid._id;
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// var processDefinitionId = Creator.odata.get("process_node", pnid, "process_definition").process_definition;
|
|
113
|
+
// var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
114
|
+
// schema._schema.object_name.optionsFunction = function(){var _obj = Creator.getObject(object_name); return [{label: _obj.label, value: _obj.name, icon: _obj.icon}]}
|
|
115
|
+
// doc.object_name = object_name;
|
|
116
|
+
// schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['approval','rejection'], option.value)})
|
|
117
|
+
// }else{
|
|
118
|
+
// schema._schema.process_definition = objectSchema.process_definition;
|
|
119
|
+
// schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['final_approval','final_rejection','recall','initial_submission'], option.value)})
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
if (operation === 'null') {
|
|
123
|
+
hiddenField('formula');
|
|
124
|
+
hiddenField('literal_value');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (operation === 'formula') {
|
|
128
|
+
schema._schema.formula = objectSchema.formula;
|
|
129
|
+
hiddenField('literal_value');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (operation === 'literal') {
|
|
133
|
+
schema._schema.formula.autoform.type = 'hidden';
|
|
134
|
+
var doc = doc;
|
|
135
|
+
var mainObjectName = null;
|
|
136
|
+
if (doc.target_object && doc.target_object != doc.object_name) {
|
|
137
|
+
var mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;
|
|
138
|
+
} else {
|
|
139
|
+
mainObjectName = doc.object_name;
|
|
140
|
+
}
|
|
141
|
+
var object = Creator.objectsByName[mainObjectName];
|
|
142
|
+
if (object && doc.field_name) {
|
|
143
|
+
schema._schema.literal_value = Object.assign({}, Creator.getObjectSchema(Creator.getObject(mainObjectName))[doc.field_name], { label: schema._schema.literal_value.label });
|
|
144
|
+
schema._schema.literal_value.autoform.disabled = false;
|
|
145
|
+
schema._schema.literal_value.autoform.omit = false;
|
|
146
|
+
schema._schema.literal_value.autoform.readonly = false;
|
|
147
|
+
schema._schema.literal_value.autoform.is_wide = true;
|
|
148
|
+
} else {
|
|
149
|
+
schema._schema.literal_value.autoform.type = 'text';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}else{
|
|
153
|
+
schema._schema.literal_value.optional = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Steedos.authRequest = function (url, options) {
|
|
2
|
+
var userSession = Creator.USER_CONTEXT;
|
|
3
|
+
var spaceId = userSession.spaceId;
|
|
4
|
+
var authToken = userSession.authToken ? userSession.authToken : userSession.user.authToken;
|
|
5
|
+
var result = null;
|
|
6
|
+
url = Steedos.absoluteUrl(url);
|
|
7
|
+
try {
|
|
8
|
+
var authorization = "Bearer " + spaceId + "," + authToken;
|
|
9
|
+
var headers = [{
|
|
10
|
+
name: 'Content-Type',
|
|
11
|
+
value: 'application/json'
|
|
12
|
+
}, {
|
|
13
|
+
name: 'Authorization',
|
|
14
|
+
value: authorization
|
|
15
|
+
}];
|
|
16
|
+
|
|
17
|
+
var defOptions = {
|
|
18
|
+
type: "get",
|
|
19
|
+
url: url,
|
|
20
|
+
dataType: "json",
|
|
21
|
+
contentType: 'application/json',
|
|
22
|
+
beforeSend: function (XHR) {
|
|
23
|
+
if (headers && headers.length) {
|
|
24
|
+
return headers.forEach(function (header) {
|
|
25
|
+
return XHR.setRequestHeader(header.name, header.value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
success: function (data) {
|
|
30
|
+
result = data;
|
|
31
|
+
},
|
|
32
|
+
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
33
|
+
console.error(XMLHttpRequest.responseJSON);
|
|
34
|
+
if (XMLHttpRequest.responseJSON && XMLHttpRequest.responseJSON.error) {
|
|
35
|
+
const errorInfo = XMLHttpRequest.responseJSON.error;
|
|
36
|
+
result = { error: errorInfo }
|
|
37
|
+
let errorMsg;
|
|
38
|
+
if (errorInfo.reason) {
|
|
39
|
+
errorMsg = errorInfo.reason;
|
|
40
|
+
}
|
|
41
|
+
else if (errorInfo.message) {
|
|
42
|
+
errorMsg = errorInfo.message;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
errorMsg = errorInfo;
|
|
46
|
+
}
|
|
47
|
+
toastr.error(t(errorMsg.replace(/:/g, ':')))
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
toastr.error(XMLHttpRequest.responseJSON)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
$.ajax(Object.assign({}, defOptions, options));
|
|
55
|
+
return result;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(err);
|
|
58
|
+
toastr.error(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Steedos.getObjectsOptions = function (filterFunction) {
|
|
63
|
+
var options = [];
|
|
64
|
+
_.each(Steedos.getDisplayObjects(filterFunction), function (v, k) {
|
|
65
|
+
options.push({ label: v.label, value: v.name, icon: v.icon })
|
|
66
|
+
})
|
|
67
|
+
return options;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Steedos.getDisplayObjects = function(filterFunction){
|
|
71
|
+
var objects = [];
|
|
72
|
+
_.each(Creator.objectsByName, function (object, k) {
|
|
73
|
+
var filterReturn = true;
|
|
74
|
+
if (filterFunction && _.isFunction(filterFunction)) {
|
|
75
|
+
filterReturn = filterFunction(object);
|
|
76
|
+
}
|
|
77
|
+
if (filterReturn && !object.hidden && !_.include(['cfs_instances_filerecord'], object.name)) {
|
|
78
|
+
objects.push(object)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
objects.sort(Creator.sortingMethod.bind({key:"label"}))
|
|
82
|
+
return objects;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Steedos.getFieldDataTypes = function (field) {
|
|
86
|
+
if(field.type === "select"){
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
"label": window.t("CustomField.object_fields.data_type.options.boolean"),
|
|
90
|
+
"value": "boolean"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"label": window.t("CustomField.object_fields.data_type.options.number"),
|
|
94
|
+
"value": "number"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"label": window.t("CustomField.object_fields.data_type.options.text"),
|
|
98
|
+
"value": "text"
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
else{
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
"label": window.t("CustomField.object_fields.data_type.options.boolean"),
|
|
106
|
+
"value": "boolean"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"label": window.t("CustomField.object_fields.data_type.options.number"),
|
|
110
|
+
"value": "number"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": window.t("CustomField.object_fields.data_type.options.currency"),
|
|
114
|
+
"value": "currency"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"label": window.t("CustomField.object_fields.data_type.options.percent"),
|
|
118
|
+
"value": "percent"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"label": window.t("CustomField.object_fields.data_type.options.text"),
|
|
122
|
+
"value": "text"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": window.t("CustomField.object_fields.data_type.options.date"),
|
|
126
|
+
"value": "date"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"label": window.t("CustomField.object_fields.data_type.options.datetime"),
|
|
130
|
+
"value": "datetime"
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Steedos.ProcessManager = {};
|
|
2
|
+
|
|
3
|
+
Steedos.ProcessManager.showProcessApprovalForm = function(action, fields, formId, doc, onConfirm, title){
|
|
4
|
+
|
|
5
|
+
var approveSchema = Creator.getObjectSchema({fields: fields})
|
|
6
|
+
|
|
7
|
+
Modal.show("quickFormModal", {formId: formId, title: title || TAPi18n.__(`process_approval_title_${action}`), confirmBtnText: `process_approval_confirmBtnText_${action}`, schema: approveSchema, doc: doc, onConfirm: onConfirm}, {
|
|
8
|
+
backdrop: 'static',
|
|
9
|
+
keyboard: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Steedos.ProcessManager.allowApprover = function(object_name, record_id){
|
|
14
|
+
if(!object_name || !record_id){
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
var result = Steedos.authRequest(`/api/v4/process/permission/approver/${object_name}/${record_id}`, {type: 'get', async: false});
|
|
18
|
+
if(result && result.allowApprover){
|
|
19
|
+
return true;
|
|
20
|
+
}else{
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Steedos.ProcessManager.allowRecall = function(object_name, record_id){
|
|
26
|
+
if(!object_name || !record_id){
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
var result = Steedos.authRequest(`/api/v4/process/permission/recall/${object_name}/${record_id}`, {type: 'get', async: false});
|
|
30
|
+
if(result && result.allowRecall){
|
|
31
|
+
return true;
|
|
32
|
+
}else{
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Steedos.ProcessManager.allowSubmit = function(object_name, record_id){
|
|
38
|
+
if(!object_name || !record_id){
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if(!Creator.getObject(object_name).enable_process){
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
var result = Steedos.authRequest(`/api/v4/process/permission/submit/${object_name}/${record_id}`, {type: 'get', async: false});
|
|
45
|
+
if(result && result.allowSubmit){
|
|
46
|
+
return true;
|
|
47
|
+
}else{
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Steedos.ProcessManager.submit = function(object_name, record_id, options){
|
|
53
|
+
var formId = 'processApprovalForm';
|
|
54
|
+
|
|
55
|
+
var schema = {
|
|
56
|
+
comment: {
|
|
57
|
+
label: TAPi18n.__('process_approval_comment'),
|
|
58
|
+
type: 'textarea',
|
|
59
|
+
rows: 3,
|
|
60
|
+
is_wide: true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if(options && options.showApprover){
|
|
65
|
+
schema.approver = {
|
|
66
|
+
label: TAPi18n.__('process_approval_approver_label'),
|
|
67
|
+
type: 'lookup',
|
|
68
|
+
reference_to: 'users',
|
|
69
|
+
required: true,
|
|
70
|
+
is_wide: true
|
|
71
|
+
}
|
|
72
|
+
schema.comment.hidden = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var formValue = {};
|
|
76
|
+
if(options && options.value){
|
|
77
|
+
formValue = options.value;
|
|
78
|
+
}
|
|
79
|
+
Steedos.ProcessManager.showProcessApprovalForm('submit', schema, formId, formValue, function(formValues, e, t){
|
|
80
|
+
var result = Steedos.authRequest(`/api/v4/process/submit/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
|
|
81
|
+
if(result.state === 'FAILURE'){
|
|
82
|
+
if(result.error === 'process_approval_error_needToChooseApprover'){
|
|
83
|
+
Modal.hide(t);
|
|
84
|
+
Meteor.setTimeout(function(){
|
|
85
|
+
Steedos.ProcessManager.submit(object_name, record_id, {showApprover: true, value: {comment: formValues.insertDoc.comment}});
|
|
86
|
+
}, 800)
|
|
87
|
+
}else{
|
|
88
|
+
toastr.error(TAPi18n.__(result.error));
|
|
89
|
+
Modal.hide(t);
|
|
90
|
+
FlowRouter.reload();
|
|
91
|
+
}
|
|
92
|
+
}else{
|
|
93
|
+
Modal.hide(t);
|
|
94
|
+
FlowRouter.reload();
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Steedos.ProcessManager.recall = function(object_name, record_id){
|
|
101
|
+
var formId = 'processApprovalForm';
|
|
102
|
+
Steedos.ProcessManager.showProcessApprovalForm('recall', {
|
|
103
|
+
comment: {
|
|
104
|
+
label: TAPi18n.__('process_approval_comment'),
|
|
105
|
+
type: 'textarea',
|
|
106
|
+
rows: 3,
|
|
107
|
+
is_wide: true
|
|
108
|
+
}
|
|
109
|
+
}, formId, {}, function(formValues, e, t){
|
|
110
|
+
var result = Steedos.authRequest(`/api/v4/process/recall/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
|
|
111
|
+
if(result.state === 'FAILURE'){
|
|
112
|
+
toastr.error(TAPi18n.__(result.error));
|
|
113
|
+
}
|
|
114
|
+
FlowRouter.reload();
|
|
115
|
+
Modal.hide(t);
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Steedos.ProcessManager.approve = function(object_name, record_id, options){
|
|
120
|
+
var formId = 'processApprovalForm';
|
|
121
|
+
var title = `${TAPi18n.__('process_instance_history_action_approve')}` //TODO approval record name
|
|
122
|
+
var schema = {
|
|
123
|
+
comment: {
|
|
124
|
+
label: TAPi18n.__('process_approval_comment'),
|
|
125
|
+
type: 'textarea',
|
|
126
|
+
rows: 3,
|
|
127
|
+
is_wide: true
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if(options && options.showApprover){
|
|
132
|
+
schema.approver = {
|
|
133
|
+
label: TAPi18n.__('process_approval_approver_label'),
|
|
134
|
+
type: 'lookup',
|
|
135
|
+
reference_to: 'users',
|
|
136
|
+
required: true,
|
|
137
|
+
is_wide: true
|
|
138
|
+
}
|
|
139
|
+
schema.comment.hidden = true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var formValue = {};
|
|
143
|
+
if(options && options.value){
|
|
144
|
+
formValue = options.value;
|
|
145
|
+
}
|
|
146
|
+
Steedos.ProcessManager.showProcessApprovalForm('approve', schema, formId, formValue, function(formValues, e, t){
|
|
147
|
+
var result = Steedos.authRequest(`/api/v4/process/approve/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
|
|
148
|
+
if(result.state === 'FAILURE'){
|
|
149
|
+
if(result.error === 'process_approval_error_needToChooseApprover'){
|
|
150
|
+
Modal.hide(t);
|
|
151
|
+
Meteor.setTimeout(function(){
|
|
152
|
+
Steedos.ProcessManager.approve(object_name, record_id, {showApprover: true, value: {comment: formValues.insertDoc.comment}});
|
|
153
|
+
}, 800)
|
|
154
|
+
}else{
|
|
155
|
+
toastr.error(TAPi18n.__(result.error));
|
|
156
|
+
Modal.hide(t);
|
|
157
|
+
FlowRouter.reload();
|
|
158
|
+
}
|
|
159
|
+
}else{
|
|
160
|
+
Modal.hide(t);
|
|
161
|
+
FlowRouter.reload();
|
|
162
|
+
}
|
|
163
|
+
}, title)
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Steedos.ProcessManager.reject = function(object_name, record_id){
|
|
168
|
+
var formId = 'processApprovalForm';
|
|
169
|
+
var title = `${TAPi18n.__('process_instance_history_action_reject')}` //TODO approval record name
|
|
170
|
+
Steedos.ProcessManager.showProcessApprovalForm('reject', {
|
|
171
|
+
comment: {
|
|
172
|
+
label: TAPi18n.__('process_approval_comment'),
|
|
173
|
+
type: 'textarea',
|
|
174
|
+
rows: 3,
|
|
175
|
+
is_wide: true
|
|
176
|
+
}
|
|
177
|
+
}, formId, {}, function(formValues, e, t){
|
|
178
|
+
var result = Steedos.authRequest(`/api/v4/process/reject/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
|
|
179
|
+
if(result.state === 'FAILURE'){
|
|
180
|
+
toastr.error(TAPi18n.__(result.error));
|
|
181
|
+
}
|
|
182
|
+
FlowRouter.reload();
|
|
183
|
+
Modal.hide(t);
|
|
184
|
+
}, title)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
Steedos.ProcessManager.reassign = function(object_name, record_id){
|
|
188
|
+
var formId = 'processApprovalForm';
|
|
189
|
+
Steedos.ProcessManager.showProcessApprovalForm('reassign', {
|
|
190
|
+
approver: {
|
|
191
|
+
label: TAPi18n.__('process_approval_approver_label_reassign'),
|
|
192
|
+
type: 'lookup',
|
|
193
|
+
reference_to: 'users',
|
|
194
|
+
required: true,
|
|
195
|
+
is_wide: true
|
|
196
|
+
},
|
|
197
|
+
comment: {
|
|
198
|
+
label: TAPi18n.__('process_approval_comment'),
|
|
199
|
+
type: 'textarea',
|
|
200
|
+
rows: 3,
|
|
201
|
+
is_wide: true
|
|
202
|
+
}
|
|
203
|
+
}, formId, {}, function(formValues, e, t){
|
|
204
|
+
var result = Steedos.authRequest(`/api/v4/process/reassign/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
|
|
205
|
+
if(result.state === 'FAILURE'){
|
|
206
|
+
toastr.error(TAPi18n.__(result.error));
|
|
207
|
+
}
|
|
208
|
+
FlowRouter.reload();
|
|
209
|
+
Modal.hide(t);
|
|
210
|
+
})
|
|
211
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Steedos.ProcessNodeManager = {};
|
|
2
|
+
|
|
3
|
+
Steedos.ProcessNodeManager.changeSchema = function(doc, schema){
|
|
4
|
+
var objectSchema = Creator.getObjectSchema(Creator.getObject("process_node"));
|
|
5
|
+
|
|
6
|
+
var hiddenField = function(fieldName){
|
|
7
|
+
schema._schema[fieldName].autoform.omit = true;
|
|
8
|
+
schema._schema[fieldName].autoform.type = 'hidden';
|
|
9
|
+
schema._schema[fieldName].optional = true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if(doc.filtrad){
|
|
13
|
+
hiddenField('entry_criteria');
|
|
14
|
+
hiddenField('if_criteria_not_met');
|
|
15
|
+
}else{
|
|
16
|
+
schema._schema.entry_criteria = objectSchema.entry_criteria;
|
|
17
|
+
schema._schema.if_criteria_not_met = objectSchema.if_criteria_not_met;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if(doc.approver === 'submitter_choose'){
|
|
21
|
+
hiddenField('assigned_approver_users');
|
|
22
|
+
hiddenField('assigned_approver_roles');
|
|
23
|
+
hiddenField('assigned_approver_flow_roles');
|
|
24
|
+
hiddenField('assigned_approver_user_field');
|
|
25
|
+
hiddenField('when_multiple_approvers');
|
|
26
|
+
|
|
27
|
+
schema._schema.when_multiple_approvers.optional = true;
|
|
28
|
+
}else{
|
|
29
|
+
schema._schema.assigned_approver_users = objectSchema.assigned_approver_users;
|
|
30
|
+
schema._schema.assigned_approver_roles = objectSchema.assigned_approver_roles;
|
|
31
|
+
schema._schema.assigned_approver_flow_roles = objectSchema.assigned_approver_flow_roles;
|
|
32
|
+
schema._schema.assigned_approver_user_field = objectSchema.assigned_approver_user_field;
|
|
33
|
+
schema._schema.when_multiple_approvers = objectSchema.when_multiple_approvers;
|
|
34
|
+
schema._schema.when_multiple_approvers.optional = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Steedos.WorkflowNotificationsManager = {};
|
|
2
|
+
|
|
3
|
+
Steedos.WorkflowNotificationsManager.changeSchema = function (doc, schema) {
|
|
4
|
+
var objectName = Session.get("object_name");
|
|
5
|
+
var actionObjectName = Session.get("action_object_name");
|
|
6
|
+
var actionOperation = Session.get("cmOperation");
|
|
7
|
+
if (objectName == 'process_node') {
|
|
8
|
+
var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition; //Creator.odata.get("process_node", recordId, "process_definition").process_definition;
|
|
9
|
+
if(processDefinitionId){
|
|
10
|
+
var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
11
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
12
|
+
doc.object_name = object_name;
|
|
13
|
+
}else{
|
|
14
|
+
toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (objectName == 'process_definition') {
|
|
19
|
+
var object_name = null;
|
|
20
|
+
if(actionObjectName == "process_definition"){
|
|
21
|
+
// 当前正在新建或编辑批准过程
|
|
22
|
+
if (actionOperation == 'update') {
|
|
23
|
+
object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name;
|
|
24
|
+
} else {
|
|
25
|
+
object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name;
|
|
26
|
+
}
|
|
27
|
+
if(!object_name){
|
|
28
|
+
toastr.error(t("workflow_notifications_field__error_process_definition_object_required"));
|
|
29
|
+
}
|
|
30
|
+
}else{
|
|
31
|
+
// 当前正在新建或编辑批准过程以外其他对象,目前只有批准过程详细界面新建或编辑批准步骤
|
|
32
|
+
if (actionOperation == 'update') {
|
|
33
|
+
var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition;
|
|
34
|
+
if(processDefinitionId){
|
|
35
|
+
object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
36
|
+
}
|
|
37
|
+
else{
|
|
38
|
+
toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
var formValues = AutoForm.getFormValues("creatorAddRelatedForm");
|
|
42
|
+
if(!formValues){
|
|
43
|
+
// 有可能是在批准过程详细界面点击了批准步骤列表顶部的链接进入了“相关批准步骤列表界面”然后点击的右上角的新建按钮触发的
|
|
44
|
+
formValues = AutoForm.getFormValues("creatorAddForm");
|
|
45
|
+
}
|
|
46
|
+
var processDefinitionId = formValues.insertDoc.process_definition;
|
|
47
|
+
if(processDefinitionId){
|
|
48
|
+
object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
|
|
49
|
+
}
|
|
50
|
+
else{
|
|
51
|
+
toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
56
|
+
doc.object_name = object_name;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (objectName == 'workflow_rule') {
|
|
60
|
+
var object_name = null;
|
|
61
|
+
if (actionOperation == 'update') {
|
|
62
|
+
object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name //Creator.odata.get("workflow_rule", Session.get("record_id"), "object_name").object_name;
|
|
63
|
+
} else {
|
|
64
|
+
object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name
|
|
65
|
+
}
|
|
66
|
+
schema._schema.object_name.autoform.readonly = true;
|
|
67
|
+
if(object_name){
|
|
68
|
+
doc.object_name = object_name;
|
|
69
|
+
}
|
|
70
|
+
else{
|
|
71
|
+
toastr.error(t("workflow_notifications_field__error_workflow_rule_object_required"));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|