@steedos/standard-process-approval 2.7.0-beta.2 → 2.7.0-beta.20
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/workflow-actions/action_field_updates.object.yml +3 -0
- package/main/default/triggers/action_field_updates.trigger.js +32 -53
- package/main/default/triggers/workflow_notifications.trigger.js +23 -119
- package/main/default/triggers/workflow_outbound_messages.trigger.js +25 -118
- package/main/default/triggers/workflow_rule.trigger.js +23 -26
- package/package.json +3 -3
|
@@ -18,7 +18,9 @@ fields:
|
|
|
18
18
|
type: lookup
|
|
19
19
|
reference_to: objects
|
|
20
20
|
reference_to_field: name
|
|
21
|
+
required: true
|
|
21
22
|
target_object:
|
|
23
|
+
required: true
|
|
22
24
|
type: lookup
|
|
23
25
|
label: Object to Update
|
|
24
26
|
reference_to: objects
|
|
@@ -31,6 +33,7 @@ fields:
|
|
|
31
33
|
showIcon: false
|
|
32
34
|
reference_to: object_fields
|
|
33
35
|
reference_to_field: name
|
|
36
|
+
required: true
|
|
34
37
|
depend_on:
|
|
35
38
|
- object_name
|
|
36
39
|
- target_object
|
|
@@ -9,8 +9,7 @@ const checkReevaluateParent = (doc)=>{
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const getInternalActionFieldUpdates = function(sourceActionFieldUpdates, filters){
|
|
13
|
-
let dbActionFieldUpdates = Creator.getCollection("action_field_updates").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
12
|
+
const getInternalActionFieldUpdates = function(sourceActionFieldUpdates, filters, dbActionFieldUpdates){
|
|
14
13
|
let actionFieldUpdates = [];
|
|
15
14
|
|
|
16
15
|
if(!filters.is_system){
|
|
@@ -38,71 +37,41 @@ module.exports = {
|
|
|
38
37
|
},
|
|
39
38
|
afterFind: async function(){
|
|
40
39
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
if(filters.name && filters.name.$in){
|
|
44
|
-
for(let name of filters.name.$in){
|
|
45
|
-
let actionFieldUpdate = objectql.getActionFieldUpdate(name);
|
|
46
|
-
if(actionFieldUpdate){
|
|
47
|
-
actionFieldUpdates.push(actionFieldUpdate);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}else if(filters._id && !filters._id.$ne){
|
|
51
|
-
let action = objectql.getActionFieldUpdate(filters._id);
|
|
52
|
-
if(action){
|
|
53
|
-
actionFieldUpdates.push(action);
|
|
54
|
-
}
|
|
55
|
-
}else if(filters.object_name){
|
|
56
|
-
actionFieldUpdates = objectql.getObjectActionFieldUpdates(filters.object_name);
|
|
40
|
+
let fObjectName = filters.object_name;
|
|
41
|
+
if(fObjectName){
|
|
57
42
|
delete filters.object_name;
|
|
58
|
-
}else{
|
|
59
|
-
actionFieldUpdates = objectql.getAllActionFieldUpdates();
|
|
60
43
|
}
|
|
61
44
|
|
|
62
45
|
if(filters._id && filters._id.$ne){
|
|
63
46
|
if(!_.isArray(filters._id.$ne)){
|
|
64
47
|
filters._id.$ne = [filters._id.$ne]
|
|
65
48
|
}
|
|
66
|
-
for(let neid of filters._id.$ne){
|
|
67
|
-
actionFieldUpdates = _.filter(actionFieldUpdates, function(item){
|
|
68
|
-
return item._id !== neid
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
49
|
}
|
|
72
50
|
|
|
73
|
-
|
|
51
|
+
let dbActionFieldUpdates = Creator.getCollection("action_field_updates").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
52
|
+
|
|
74
53
|
|
|
75
|
-
if(actionFieldUpdates && actionFieldUpdates.length>0){
|
|
76
|
-
this.data.values = this.data.values.concat(actionFieldUpdates)
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
afterAggregate: async function(){
|
|
80
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
81
54
|
let actionFieldUpdates = [];
|
|
82
55
|
|
|
83
56
|
if(filters.name && filters.name.$in){
|
|
84
57
|
for(let name of filters.name.$in){
|
|
85
|
-
let actionFieldUpdate = objectql.getActionFieldUpdate(name);
|
|
58
|
+
let actionFieldUpdate = await objectql.getActionFieldUpdate(name);
|
|
86
59
|
if(actionFieldUpdate){
|
|
87
60
|
actionFieldUpdates.push(actionFieldUpdate);
|
|
88
61
|
}
|
|
89
62
|
}
|
|
90
63
|
}else if(filters._id && !filters._id.$ne){
|
|
91
|
-
let action = objectql.getActionFieldUpdate(filters._id);
|
|
64
|
+
let action = await objectql.getActionFieldUpdate(filters._id);
|
|
92
65
|
if(action){
|
|
93
66
|
actionFieldUpdates.push(action);
|
|
94
67
|
}
|
|
95
|
-
}else if(
|
|
96
|
-
actionFieldUpdates = objectql.getObjectActionFieldUpdates(
|
|
97
|
-
delete filters.object_name;
|
|
68
|
+
}else if(fObjectName){
|
|
69
|
+
actionFieldUpdates = await objectql.getObjectActionFieldUpdates(fObjectName);
|
|
98
70
|
}else{
|
|
99
|
-
actionFieldUpdates = objectql.getAllActionFieldUpdates();
|
|
71
|
+
actionFieldUpdates = await objectql.getAllActionFieldUpdates();
|
|
100
72
|
}
|
|
101
73
|
|
|
102
74
|
if(filters._id && filters._id.$ne){
|
|
103
|
-
if(!_.isArray(filters._id.$ne)){
|
|
104
|
-
filters._id.$ne = [filters._id.$ne]
|
|
105
|
-
}
|
|
106
75
|
for(let neid of filters._id.$ne){
|
|
107
76
|
actionFieldUpdates = _.filter(actionFieldUpdates, function(item){
|
|
108
77
|
return item._id !== neid
|
|
@@ -110,7 +79,7 @@ module.exports = {
|
|
|
110
79
|
}
|
|
111
80
|
}
|
|
112
81
|
|
|
113
|
-
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters);
|
|
82
|
+
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters, dbActionFieldUpdates);
|
|
114
83
|
|
|
115
84
|
if(actionFieldUpdates && actionFieldUpdates.length>0){
|
|
116
85
|
this.data.values = this.data.values.concat(actionFieldUpdates)
|
|
@@ -118,31 +87,41 @@ module.exports = {
|
|
|
118
87
|
},
|
|
119
88
|
afterCount: async function(){
|
|
120
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
|
+
|
|
121
104
|
let actionFieldUpdates = [];
|
|
122
105
|
|
|
123
106
|
if(filters.name && filters.name.$in){
|
|
124
107
|
for(let name of filters.name.$in){
|
|
125
|
-
let actionFieldUpdate = objectql.getActionFieldUpdate(name);
|
|
108
|
+
let actionFieldUpdate = await objectql.getActionFieldUpdate(name);
|
|
126
109
|
if(actionFieldUpdate){
|
|
127
110
|
actionFieldUpdates.push(actionFieldUpdate);
|
|
128
111
|
}
|
|
129
112
|
}
|
|
130
113
|
}else if(filters._id && !filters._id.$ne){
|
|
131
|
-
let action = objectql.getActionFieldUpdate(filters._id);
|
|
114
|
+
let action = await objectql.getActionFieldUpdate(filters._id);
|
|
132
115
|
if(action){
|
|
133
116
|
actionFieldUpdates.push(action);
|
|
134
117
|
}
|
|
135
|
-
}else if(
|
|
136
|
-
actionFieldUpdates = objectql.getObjectActionFieldUpdates(
|
|
137
|
-
delete filters.object_name;
|
|
118
|
+
}else if(fObjectName){
|
|
119
|
+
actionFieldUpdates = await objectql.getObjectActionFieldUpdates(fObjectName);
|
|
138
120
|
}else{
|
|
139
|
-
actionFieldUpdates = objectql.getAllActionFieldUpdates();
|
|
121
|
+
actionFieldUpdates = await objectql.getAllActionFieldUpdates();
|
|
140
122
|
}
|
|
141
123
|
|
|
142
124
|
if(filters._id && filters._id.$ne){
|
|
143
|
-
if(!_.isArray(filters._id.$ne)){
|
|
144
|
-
filters._id.$ne = [filters._id.$ne]
|
|
145
|
-
}
|
|
146
125
|
for(let neid of filters._id.$ne){
|
|
147
126
|
actionFieldUpdates = _.filter(actionFieldUpdates, function(item){
|
|
148
127
|
return item._id !== neid
|
|
@@ -150,7 +129,7 @@ module.exports = {
|
|
|
150
129
|
}
|
|
151
130
|
}
|
|
152
131
|
|
|
153
|
-
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters);
|
|
132
|
+
actionFieldUpdates = getInternalActionFieldUpdates(actionFieldUpdates, filters, dbActionFieldUpdates);
|
|
154
133
|
|
|
155
134
|
if(actionFieldUpdates && actionFieldUpdates.length>0){
|
|
156
135
|
this.data.values = this.data.values + actionFieldUpdates.length
|
|
@@ -166,7 +145,7 @@ module.exports = {
|
|
|
166
145
|
return;
|
|
167
146
|
}
|
|
168
147
|
|
|
169
|
-
let actionFieldUpdate = objectql.getActionFieldUpdate(id);
|
|
148
|
+
let actionFieldUpdate = await objectql.getActionFieldUpdate(id);
|
|
170
149
|
if(actionFieldUpdate){
|
|
171
150
|
this.data.values = actionFieldUpdate;
|
|
172
151
|
}
|
|
@@ -3,8 +3,7 @@ const util = require('@steedos/standard-objects').util;
|
|
|
3
3
|
const objectql = require("@steedos/objectql");
|
|
4
4
|
const InternalData = require('@steedos/standard-objects').internalData;
|
|
5
5
|
|
|
6
|
-
const getInternalWorkflowNotifications = function(sourceWorkflowNotifications, filters){
|
|
7
|
-
let dbWorkflowNotifications = Creator.getCollection("workflow_notifications").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
6
|
+
const getInternalWorkflowNotifications = function(sourceWorkflowNotifications, filters, dbWorkflowNotifications){
|
|
8
7
|
let workflowNotifications = [];
|
|
9
8
|
|
|
10
9
|
if(!filters.is_system){
|
|
@@ -30,102 +29,38 @@ module.exports = {
|
|
|
30
29
|
},
|
|
31
30
|
afterFind: async function(){
|
|
32
31
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
33
|
-
let
|
|
34
|
-
if(
|
|
35
|
-
for(let _name of filters.name.$in){
|
|
36
|
-
let workflowNotification = objectql.getWorkflowNotification(_name);
|
|
37
|
-
if(workflowNotification){
|
|
38
|
-
workflowNotifications.push(workflowNotification);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}else if(filters._id && !filters._id.$ne){
|
|
42
|
-
let notification = objectql.getWorkflowNotification(filters._id);
|
|
43
|
-
if(notification){
|
|
44
|
-
workflowNotifications.push(notification);
|
|
45
|
-
}
|
|
46
|
-
}else if(filters.object_name){
|
|
47
|
-
workflowNotifications = objectql.getObjectWorkflowNotifications(filters.object_name);
|
|
32
|
+
let fObjectName = filters.object_name;
|
|
33
|
+
if(fObjectName){
|
|
48
34
|
delete filters.object_name;
|
|
49
|
-
}else{
|
|
50
|
-
workflowNotifications = objectql.getAllWorkflowNotifications();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if(filters._id && filters._id.$ne){
|
|
54
|
-
if(!_.isArray(filters._id.$ne)){
|
|
55
|
-
filters._id.$ne = [filters._id.$ne]
|
|
56
|
-
}
|
|
57
|
-
for(let neid of filters._id.$ne){
|
|
58
|
-
workflowNotifications = _.filter(workflowNotifications, function(item){
|
|
59
|
-
return item._id !== neid
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
35
|
}
|
|
63
36
|
|
|
64
|
-
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters);
|
|
65
|
-
|
|
66
|
-
if(workflowNotifications && workflowNotifications.length>0){
|
|
67
|
-
this.data.values = this.data.values.concat(workflowNotifications)
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
afterAggregate: async function(){
|
|
71
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
72
|
-
let workflowNotifications = [];
|
|
73
|
-
if(filters._id && filters._id.$in){
|
|
74
|
-
for(let id of filters._id.$in){
|
|
75
|
-
let workflowNotification = objectql.getWorkflowNotification(id);
|
|
76
|
-
if(workflowNotification){
|
|
77
|
-
workflowNotifications.push(workflowNotification);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}else if(filters._id && !filters._id.$ne){
|
|
81
|
-
let notification = objectql.getWorkflowNotification(filters._id);
|
|
82
|
-
if(notification){
|
|
83
|
-
workflowNotifications.push(notification);
|
|
84
|
-
}
|
|
85
|
-
}else if(filters.object_name){
|
|
86
|
-
workflowNotifications = objectql.getObjectWorkflowNotifications(filters.object_name);
|
|
87
|
-
delete filters.object_name;
|
|
88
|
-
}else{
|
|
89
|
-
workflowNotifications = objectql.getAllWorkflowNotifications();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
37
|
if(filters._id && filters._id.$ne){
|
|
93
38
|
if(!_.isArray(filters._id.$ne)){
|
|
94
39
|
filters._id.$ne = [filters._id.$ne]
|
|
95
40
|
}
|
|
96
|
-
for(let neid of filters._id.$ne){
|
|
97
|
-
workflowNotifications = _.filter(workflowNotifications, function(item){
|
|
98
|
-
return item._id !== neid
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
41
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
42
|
+
let dbWorkflowNotifications = Creator.getCollection("workflow_notifications").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
43
|
+
|
|
105
44
|
let workflowNotifications = [];
|
|
106
45
|
if(filters.name && filters.name.$in){
|
|
107
46
|
for(let _name of filters.name.$in){
|
|
108
|
-
let workflowNotification = objectql.getWorkflowNotification(_name);
|
|
47
|
+
let workflowNotification = await objectql.getWorkflowNotification(_name);
|
|
109
48
|
if(workflowNotification){
|
|
110
49
|
workflowNotifications.push(workflowNotification);
|
|
111
50
|
}
|
|
112
51
|
}
|
|
113
52
|
}else if(filters._id && !filters._id.$ne){
|
|
114
|
-
let notification = objectql.getWorkflowNotification(filters._id);
|
|
53
|
+
let notification = await objectql.getWorkflowNotification(filters._id);
|
|
115
54
|
if(notification){
|
|
116
55
|
workflowNotifications.push(notification);
|
|
117
56
|
}
|
|
118
|
-
}else if(
|
|
119
|
-
workflowNotifications = objectql.getObjectWorkflowNotifications(
|
|
120
|
-
delete filters.object_name;
|
|
57
|
+
}else if(fObjectName){
|
|
58
|
+
workflowNotifications = await objectql.getObjectWorkflowNotifications(fObjectName);
|
|
121
59
|
}else{
|
|
122
|
-
workflowNotifications = objectql.getAllWorkflowNotifications();
|
|
60
|
+
workflowNotifications = await objectql.getAllWorkflowNotifications();
|
|
123
61
|
}
|
|
124
62
|
|
|
125
63
|
if(filters._id && filters._id.$ne){
|
|
126
|
-
if(!_.isArray(filters._id.$ne)){
|
|
127
|
-
filters._id.$ne = [filters._id.$ne]
|
|
128
|
-
}
|
|
129
64
|
for(let neid of filters._id.$ne){
|
|
130
65
|
workflowNotifications = _.filter(workflowNotifications, function(item){
|
|
131
66
|
return item._id !== neid
|
|
@@ -133,77 +68,46 @@ module.exports = {
|
|
|
133
68
|
}
|
|
134
69
|
}
|
|
135
70
|
|
|
136
|
-
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters);
|
|
71
|
+
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters, dbWorkflowNotifications);
|
|
137
72
|
|
|
138
73
|
if(workflowNotifications && workflowNotifications.length>0){
|
|
139
74
|
this.data.values = this.data.values.concat(workflowNotifications)
|
|
140
75
|
}
|
|
141
76
|
},
|
|
142
|
-
|
|
77
|
+
afterCount: async function(){
|
|
143
78
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
144
|
-
let
|
|
145
|
-
if(
|
|
146
|
-
for(let id of filters._id.$in){
|
|
147
|
-
let workflowNotification = objectql.getWorkflowNotification(id);
|
|
148
|
-
if(workflowNotification){
|
|
149
|
-
workflowNotifications.push(workflowNotification);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}else if(filters._id && !filters._id.$ne){
|
|
153
|
-
let notification = objectql.getWorkflowNotification(filters._id);
|
|
154
|
-
if(notification){
|
|
155
|
-
workflowNotifications.push(notification);
|
|
156
|
-
}
|
|
157
|
-
}else if(filters.object_name){
|
|
158
|
-
workflowNotifications = objectql.getObjectWorkflowNotifications(filters.object_name);
|
|
79
|
+
let fObjectName = filters.object_name;
|
|
80
|
+
if(fObjectName){
|
|
159
81
|
delete filters.object_name;
|
|
160
|
-
}else{
|
|
161
|
-
workflowNotifications = objectql.getAllWorkflowNotifications();
|
|
162
82
|
}
|
|
163
|
-
|
|
83
|
+
|
|
164
84
|
if(filters._id && filters._id.$ne){
|
|
165
85
|
if(!_.isArray(filters._id.$ne)){
|
|
166
86
|
filters._id.$ne = [filters._id.$ne]
|
|
167
87
|
}
|
|
168
|
-
for(let neid of filters._id.$ne){
|
|
169
|
-
workflowNotifications = _.filter(workflowNotifications, function(item){
|
|
170
|
-
return item._id !== neid
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
88
|
}
|
|
89
|
+
let dbWorkflowNotifications = Creator.getCollection("workflow_notifications").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
174
90
|
|
|
175
|
-
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters);
|
|
176
|
-
|
|
177
|
-
if(workflowNotifications && workflowNotifications.length>0){
|
|
178
|
-
this.data.values = this.data.values.concat(workflowNotifications)
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
afterCount: async function(){
|
|
182
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
183
91
|
let workflowNotifications = [];
|
|
184
92
|
if(filters._id && filters._id.$in){
|
|
185
93
|
for(let id of filters._id.$in){
|
|
186
|
-
let workflowNotification = objectql.getWorkflowNotification(id);
|
|
94
|
+
let workflowNotification = await objectql.getWorkflowNotification(id);
|
|
187
95
|
if(workflowNotification){
|
|
188
96
|
workflowNotifications.push(workflowNotification);
|
|
189
97
|
}
|
|
190
98
|
}
|
|
191
99
|
}else if(filters._id && !filters._id.$ne){
|
|
192
|
-
let notification = objectql.getWorkflowNotification(filters._id);
|
|
100
|
+
let notification = await objectql.getWorkflowNotification(filters._id);
|
|
193
101
|
if(notification){
|
|
194
102
|
workflowNotifications.push(notification);
|
|
195
103
|
}
|
|
196
|
-
}else if(
|
|
197
|
-
workflowNotifications = objectql.getObjectWorkflowNotifications(
|
|
198
|
-
delete filters.object_name;
|
|
104
|
+
}else if(fObjectName){
|
|
105
|
+
workflowNotifications = await objectql.getObjectWorkflowNotifications(fObjectName);
|
|
199
106
|
}else{
|
|
200
|
-
workflowNotifications = objectql.getAllWorkflowNotifications();
|
|
107
|
+
workflowNotifications = await objectql.getAllWorkflowNotifications();
|
|
201
108
|
}
|
|
202
109
|
|
|
203
110
|
if(filters._id && filters._id.$ne){
|
|
204
|
-
if(!_.isArray(filters._id.$ne)){
|
|
205
|
-
filters._id.$ne = [filters._id.$ne]
|
|
206
|
-
}
|
|
207
111
|
for(let neid of filters._id.$ne){
|
|
208
112
|
workflowNotifications = _.filter(workflowNotifications, function(item){
|
|
209
113
|
return item._id !== neid
|
|
@@ -211,7 +115,7 @@ module.exports = {
|
|
|
211
115
|
}
|
|
212
116
|
}
|
|
213
117
|
|
|
214
|
-
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters);
|
|
118
|
+
workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters, dbWorkflowNotifications);
|
|
215
119
|
|
|
216
120
|
if(workflowNotifications && workflowNotifications.length>0){
|
|
217
121
|
this.data.values = this.data.values + workflowNotifications.length
|
|
@@ -227,7 +131,7 @@ module.exports = {
|
|
|
227
131
|
return;
|
|
228
132
|
}
|
|
229
133
|
|
|
230
|
-
let workflowNotification = objectql.getWorkflowNotification(id);
|
|
134
|
+
let workflowNotification = await objectql.getWorkflowNotification(id);
|
|
231
135
|
if(workflowNotification){
|
|
232
136
|
this.data.values = workflowNotification;
|
|
233
137
|
}
|
|
@@ -3,8 +3,7 @@ const util = require('@steedos/standard-objects').util;
|
|
|
3
3
|
const objectql = require("@steedos/objectql");
|
|
4
4
|
const InternalData = require('@steedos/standard-objects').internalData;
|
|
5
5
|
|
|
6
|
-
const getInternalOutboundMessages = function(sourceOutboundMessages, filters){
|
|
7
|
-
let dbOutboundMessages = Creator.getCollection("workflow_outbound_messages").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
6
|
+
const getInternalOutboundMessages = function(sourceOutboundMessages, filters, dbOutboundMessages){
|
|
8
7
|
let messages = [];
|
|
9
8
|
|
|
10
9
|
if(!filters.is_system){
|
|
@@ -30,102 +29,40 @@ module.exports = {
|
|
|
30
29
|
},
|
|
31
30
|
afterFind: async function(){
|
|
32
31
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let message = objectql.getWorkflowOutboundMessage(_name);
|
|
37
|
-
if(message){
|
|
38
|
-
messages.push(message);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}else if(filters._id && !filters._id.$ne){
|
|
42
|
-
let message = objectql.getWorkflowOutboundMessage(filters._id);
|
|
43
|
-
if(message){
|
|
44
|
-
messages.push(message);
|
|
45
|
-
}
|
|
46
|
-
}else if(filters.object_name){
|
|
47
|
-
messages = objectql.getObjectOutboundMessages(filters.object_name);
|
|
32
|
+
let fObjectName = filters.object_name;
|
|
33
|
+
|
|
34
|
+
if(fObjectName){
|
|
48
35
|
delete filters.object_name;
|
|
49
|
-
}else{
|
|
50
|
-
messages = objectql.getAllWorkflowOutboundMessages();
|
|
51
36
|
}
|
|
52
|
-
|
|
37
|
+
|
|
53
38
|
if(filters._id && filters._id.$ne){
|
|
54
39
|
if(!_.isArray(filters._id.$ne)){
|
|
55
40
|
filters._id.$ne = [filters._id.$ne]
|
|
56
41
|
}
|
|
57
|
-
for(let neid of filters._id.$ne){
|
|
58
|
-
messages = _.filter(messages, function(item){
|
|
59
|
-
return item._id !== neid
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
42
|
}
|
|
63
43
|
|
|
64
|
-
|
|
44
|
+
let dbOutboundMessages = Creator.getCollection("workflow_outbound_messages").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
65
45
|
|
|
66
|
-
if(messages && messages.length>0){
|
|
67
|
-
this.data.values = this.data.values.concat(messages)
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
afterAggregate: async function(){
|
|
71
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
72
|
-
let messages = [];
|
|
73
|
-
if(filters._id && filters._id.$in){
|
|
74
|
-
for(let id of filters._id.$in){
|
|
75
|
-
let message = objectql.getWorkflowOutboundMessage(id);
|
|
76
|
-
if(message){
|
|
77
|
-
messages.push(message);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}else if(filters._id && !filters._id.$ne){
|
|
81
|
-
let message = objectql.getWorkflowOutboundMessage(filters._id);
|
|
82
|
-
if(message){
|
|
83
|
-
messages.push(message);
|
|
84
|
-
}
|
|
85
|
-
}else if(filters.object_name){
|
|
86
|
-
messages = objectql.getObjectOutboundMessages(filters.object_name);
|
|
87
|
-
delete filters.object_name;
|
|
88
|
-
}else{
|
|
89
|
-
messages = objectql.getAllWorkflowOutboundMessages();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if(filters._id && filters._id.$ne){
|
|
93
|
-
if(!_.isArray(filters._id.$ne)){
|
|
94
|
-
filters._id.$ne = [filters._id.$ne]
|
|
95
|
-
}
|
|
96
|
-
for(let neid of filters._id.$ne){
|
|
97
|
-
messages = _.filter(messages, function(item){
|
|
98
|
-
return item._id !== neid
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
afterFind: async function(){
|
|
104
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
105
46
|
let messages = [];
|
|
106
47
|
if(filters.name && filters.name.$in){
|
|
107
48
|
for(let _name of filters.name.$in){
|
|
108
|
-
let message = objectql.getWorkflowOutboundMessage(_name);
|
|
49
|
+
let message = await objectql.getWorkflowOutboundMessage(_name);
|
|
109
50
|
if(message){
|
|
110
51
|
messages.push(message);
|
|
111
52
|
}
|
|
112
53
|
}
|
|
113
54
|
}else if(filters._id && !filters._id.$ne){
|
|
114
|
-
let message = objectql.getWorkflowOutboundMessage(filters._id);
|
|
55
|
+
let message = await objectql.getWorkflowOutboundMessage(filters._id);
|
|
115
56
|
if(message){
|
|
116
57
|
messages.push(message);
|
|
117
58
|
}
|
|
118
|
-
}else if(
|
|
119
|
-
messages = objectql.getObjectWorkflowOutboundMessages(
|
|
120
|
-
delete filters.object_name;
|
|
59
|
+
}else if(fObjectName){
|
|
60
|
+
messages = await objectql.getObjectWorkflowOutboundMessages(fObjectName);
|
|
121
61
|
}else{
|
|
122
|
-
messages = objectql.getAllWorkflowOutboundMessages();
|
|
62
|
+
messages = await objectql.getAllWorkflowOutboundMessages();
|
|
123
63
|
}
|
|
124
64
|
|
|
125
65
|
if(filters._id && filters._id.$ne){
|
|
126
|
-
if(!_.isArray(filters._id.$ne)){
|
|
127
|
-
filters._id.$ne = [filters._id.$ne]
|
|
128
|
-
}
|
|
129
66
|
for(let neid of filters._id.$ne){
|
|
130
67
|
messages = _.filter(messages, function(item){
|
|
131
68
|
return item._id !== neid
|
|
@@ -133,77 +70,47 @@ module.exports = {
|
|
|
133
70
|
}
|
|
134
71
|
}
|
|
135
72
|
|
|
136
|
-
messages = getInternalOutboundMessages(messages, filters);
|
|
73
|
+
messages = getInternalOutboundMessages(messages, filters, dbOutboundMessages);
|
|
137
74
|
|
|
138
75
|
if(messages && messages.length>0){
|
|
139
76
|
this.data.values = this.data.values.concat(messages)
|
|
140
77
|
}
|
|
141
78
|
},
|
|
142
|
-
|
|
79
|
+
afterCount: async function(){
|
|
143
80
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
let message = objectql.getWorkflowOutboundMessage(id);
|
|
148
|
-
if(message){
|
|
149
|
-
messages.push(message);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}else if(filters._id && !filters._id.$ne){
|
|
153
|
-
let message = objectql.getWorkflowOutboundMessage(filters._id);
|
|
154
|
-
if(message){
|
|
155
|
-
messages.push(message);
|
|
156
|
-
}
|
|
157
|
-
}else if(filters.object_name){
|
|
158
|
-
messages = objectql.getObjectOutboundMessages(filters.object_name);
|
|
81
|
+
let fObjectName = filters.object_name;
|
|
82
|
+
|
|
83
|
+
if(fObjectName){
|
|
159
84
|
delete filters.object_name;
|
|
160
|
-
}else{
|
|
161
|
-
messages = objectql.getAllWorkflowOutboundMessages();
|
|
162
85
|
}
|
|
163
|
-
|
|
86
|
+
|
|
164
87
|
if(filters._id && filters._id.$ne){
|
|
165
88
|
if(!_.isArray(filters._id.$ne)){
|
|
166
89
|
filters._id.$ne = [filters._id.$ne]
|
|
167
90
|
}
|
|
168
|
-
for(let neid of filters._id.$ne){
|
|
169
|
-
messages = _.filter(messages, function(item){
|
|
170
|
-
return item._id !== neid
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
91
|
}
|
|
174
92
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if(messages && messages.length>0){
|
|
178
|
-
this.data.values = this.data.values.concat(messages)
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
afterCount: async function(){
|
|
182
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
93
|
+
let dbOutboundMessages = Creator.getCollection("workflow_outbound_messages").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
183
94
|
let messages = [];
|
|
184
95
|
if(filters._id && filters._id.$in){
|
|
185
96
|
for(let id of filters._id.$in){
|
|
186
|
-
let message = objectql.getWorkflowOutboundMessage(id);
|
|
97
|
+
let message = await objectql.getWorkflowOutboundMessage(id);
|
|
187
98
|
if(message){
|
|
188
99
|
messages.push(message);
|
|
189
100
|
}
|
|
190
101
|
}
|
|
191
102
|
}else if(filters._id && !filters._id.$ne){
|
|
192
|
-
let message = objectql.getWorkflowOutboundMessage(filters._id);
|
|
103
|
+
let message = await objectql.getWorkflowOutboundMessage(filters._id);
|
|
193
104
|
if(message){
|
|
194
105
|
messages.push(message);
|
|
195
106
|
}
|
|
196
|
-
}else if(
|
|
197
|
-
messages = objectql.getObjectWorkflowOutboundMessages(
|
|
198
|
-
delete filters.object_name;
|
|
107
|
+
}else if(fObjectName){
|
|
108
|
+
messages = await objectql.getObjectWorkflowOutboundMessages(fObjectName);
|
|
199
109
|
}else{
|
|
200
|
-
messages = objectql.getAllWorkflowOutboundMessages();
|
|
110
|
+
messages = await objectql.getAllWorkflowOutboundMessages();
|
|
201
111
|
}
|
|
202
112
|
|
|
203
113
|
if(filters._id && filters._id.$ne){
|
|
204
|
-
if(!_.isArray(filters._id.$ne)){
|
|
205
|
-
filters._id.$ne = [filters._id.$ne]
|
|
206
|
-
}
|
|
207
114
|
for(let neid of filters._id.$ne){
|
|
208
115
|
messages = _.filter(messages, function(item){
|
|
209
116
|
return item._id !== neid
|
|
@@ -211,7 +118,7 @@ module.exports = {
|
|
|
211
118
|
}
|
|
212
119
|
}
|
|
213
120
|
|
|
214
|
-
messages = getInternalOutboundMessages(messages, filters);
|
|
121
|
+
messages = getInternalOutboundMessages(messages, filters, dbOutboundMessages);
|
|
215
122
|
|
|
216
123
|
if(messages && messages.length>0){
|
|
217
124
|
this.data.values = this.data.values + messages.length
|
|
@@ -227,7 +134,7 @@ module.exports = {
|
|
|
227
134
|
return;
|
|
228
135
|
}
|
|
229
136
|
|
|
230
|
-
let message = objectql.getWorkflowOutboundMessage(id);
|
|
137
|
+
let message = await objectql.getWorkflowOutboundMessage(id);
|
|
231
138
|
if(message){
|
|
232
139
|
this.data.values = message;
|
|
233
140
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 2021-08-30 12:06:41
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
-
* @LastEditTime:
|
|
5
|
+
* @LastEditTime: 2024-03-13 14:57:01
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
const _ = require("underscore");
|
|
@@ -11,8 +11,7 @@ const objectql = require("@steedos/objectql");
|
|
|
11
11
|
const register = require("@steedos/metadata-registrar")
|
|
12
12
|
const InternalData = require('@steedos/standard-objects').internalData;
|
|
13
13
|
|
|
14
|
-
const getInternalWorkflowRules = function(sourceWorkflowRules, filters){
|
|
15
|
-
let dbWorkflowRules = Creator.getCollection("workflow_rule").find(filters, {fields:{_id:1, name:1}}).fetch();
|
|
14
|
+
const getInternalWorkflowRules = function(sourceWorkflowRules, filters, dbWorkflowRules){
|
|
16
15
|
let workflowRules = [];
|
|
17
16
|
|
|
18
17
|
if(!filters.is_system){
|
|
@@ -40,30 +39,22 @@ module.exports = {
|
|
|
40
39
|
afterFind: async function(){
|
|
41
40
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
42
41
|
let workflowRules = [];
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
|
|
43
|
+
let fObjectName = filters.object_name;
|
|
44
|
+
|
|
45
|
+
if(fObjectName){
|
|
45
46
|
delete filters.object_name;
|
|
46
|
-
}else{
|
|
47
|
-
workflowRules = register.getAllWorkflowRules();
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
let dbWorkflowRules = Creator.getCollection("workflow_rule").find(filters, {fields:{_id:1, name:1}}).fetch()
|
|
51
50
|
|
|
52
|
-
if(
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
afterAggregate: async function(){
|
|
57
|
-
let filters = InternalData.parserFilters(this.query.filters)
|
|
58
|
-
let workflowRules = [];
|
|
59
|
-
if(filters.object_name){
|
|
60
|
-
workflowRules = register.getObjectWorkflowRules(filters.object_name);
|
|
61
|
-
delete filters.object_name;
|
|
51
|
+
if(fObjectName){
|
|
52
|
+
workflowRules = await register.getObjectWorkflowRules(fObjectName);
|
|
62
53
|
}else{
|
|
63
|
-
workflowRules = register.getAllWorkflowRules();
|
|
54
|
+
workflowRules = await register.getAllWorkflowRules();
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
workflowRules = getInternalWorkflowRules(workflowRules, filters);
|
|
56
|
+
|
|
57
|
+
workflowRules = getInternalWorkflowRules(workflowRules, filters, dbWorkflowRules);
|
|
67
58
|
|
|
68
59
|
if(workflowRules && workflowRules.length>0){
|
|
69
60
|
this.data.values = this.data.values.concat(workflowRules)
|
|
@@ -72,14 +63,20 @@ module.exports = {
|
|
|
72
63
|
afterCount: async function(){
|
|
73
64
|
let filters = InternalData.parserFilters(this.query.filters)
|
|
74
65
|
let workflowRules = [];
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
let fObjectName = filters.object_name;
|
|
67
|
+
|
|
68
|
+
if(fObjectName){
|
|
77
69
|
delete filters.object_name;
|
|
70
|
+
}
|
|
71
|
+
let dbWorkflowRules = Creator.getCollection("workflow_rule").find(filters, {fields:{_id:1, name:1}}).fetch()
|
|
72
|
+
|
|
73
|
+
if(fObjectName){
|
|
74
|
+
workflowRules = await register.getObjectWorkflowRules(fObjectName);
|
|
78
75
|
}else{
|
|
79
|
-
workflowRules = register.getAllWorkflowRules();
|
|
76
|
+
workflowRules = await register.getAllWorkflowRules();
|
|
80
77
|
}
|
|
81
78
|
|
|
82
|
-
workflowRules = getInternalWorkflowRules(workflowRules, filters);
|
|
79
|
+
workflowRules = getInternalWorkflowRules(workflowRules, filters, dbWorkflowRules);
|
|
83
80
|
|
|
84
81
|
if(workflowRules && workflowRules.length>0){
|
|
85
82
|
this.data.values = this.data.values + workflowRules.length
|
|
@@ -88,7 +85,7 @@ module.exports = {
|
|
|
88
85
|
afterFindOne: async function(){
|
|
89
86
|
if(_.isEmpty(this.data.values)){
|
|
90
87
|
let id = this.id
|
|
91
|
-
let workflowRule = register.getWorkflowRule(id);
|
|
88
|
+
let workflowRule = await register.getWorkflowRule(id);
|
|
92
89
|
if(workflowRule){
|
|
93
90
|
this.data.values = workflowRule;
|
|
94
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-process-approval",
|
|
3
|
-
"version": "2.7.0-beta.
|
|
3
|
+
"version": "2.7.0-beta.20",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"steedos"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/process": "2.7.0-beta.
|
|
13
|
+
"@steedos/process": "2.7.0-beta.20"
|
|
14
14
|
},
|
|
15
15
|
"description": "steedos package",
|
|
16
16
|
"repository": {},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "170a907e1f08f90c3c0969320922eb431ed06ed7"
|
|
19
19
|
}
|