@steedos/standard-process-approval 3.0.0-beta.2 → 3.0.0-beta.8

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.
@@ -3,47 +3,10 @@ name: Process Automation
3
3
  icon_slds: approval
4
4
  is_creator: false
5
5
  admin_menus:
6
- # 分部管理员可以创建和设置流程及相关参数。
7
- # - _id: process_automation
8
- # name: Process Automation
9
- # permission_sets:
10
- # - admin
11
- # expanded: false
12
- # sort: 500
13
6
  - _id: process_definition
14
7
  name: Approval Processes
15
8
  sort: 400
16
9
  permission_sets:
17
10
  - admin
18
11
  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
12
+ parent: process_automation
@@ -1,34 +1,3 @@
1
- /*
2
- * @Author: baozhoutao@steedos.com
3
- * @Date: 2022-12-13 10:41:08
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-02-26 16:30:11
6
- * @Description:
7
- */
8
-
9
- Steedos.getObjectsOptions = function (filterFunction) {
10
- var options = [];
11
- _.each(Steedos.getDisplayObjects(filterFunction), function (v, k) {
12
- options.push({ label: v.label, value: v.name, icon: v.icon })
13
- })
14
- return options;
15
- }
16
-
17
- Steedos.getDisplayObjects = function(filterFunction){
18
- var objects = [];
19
- _.each(Creator.objectsByName, function (object, k) {
20
- var filterReturn = true;
21
- if (filterFunction && _.isFunction(filterFunction)) {
22
- filterReturn = filterFunction(object);
23
- }
24
- if (filterReturn && !object.hidden && !_.includes(['cfs_instances_filerecord'], object.name)) {
25
- objects.push(object)
26
- }
27
- })
28
- objects.sort(Creator.sortingMethod.bind({key:"label"}))
29
- return objects;
30
- }
31
-
32
1
  Steedos.getFieldDataTypes = function (field) {
33
2
  if(field.type === "select"){
34
3
  return [
@@ -4,7 +4,7 @@ Steedos.ProcessManager.showProcessApprovalForm = function(action, fields, formId
4
4
 
5
5
  var approveSchema = Creator.getObjectSchema({fields: fields})
6
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}, {
7
+ Modal.show("quickFormModal", {formId: formId, title: title || t(`process_approval_title_${action}`), confirmBtnText: `process_approval_confirmBtnText_${action}`, schema: approveSchema, doc: doc, onConfirm: onConfirm}, {
8
8
  backdrop: 'static',
9
9
  keyboard: true
10
10
  });
@@ -56,7 +56,7 @@ Steedos.ProcessManager.submit = function(object_name, record_id, options){
56
56
 
57
57
  var schema = {
58
58
  comment: {
59
- label: TAPi18n.__('process_approval_comment'),
59
+ label: t('process_approval_comment'),
60
60
  type: 'textarea',
61
61
  rows: 3,
62
62
  is_wide: true
@@ -65,7 +65,7 @@ Steedos.ProcessManager.submit = function(object_name, record_id, options){
65
65
 
66
66
  if(options && options.showApprover){
67
67
  schema.approver = {
68
- label: TAPi18n.__('process_approval_approver_label'),
68
+ label: t('process_approval_approver_label'),
69
69
  type: 'lookup',
70
70
  reference_to: 'users',
71
71
  required: true,
@@ -87,7 +87,7 @@ Steedos.ProcessManager.submit = function(object_name, record_id, options){
87
87
  Steedos.ProcessManager.submit(object_name, record_id, {showApprover: true, value: {comment: formValues.insertDoc.comment}});
88
88
  }, 800)
89
89
  }else{
90
- toastr.error(TAPi18n.__(result.error));
90
+ toastr.error(t(result.error));
91
91
  Modal.hide(t);
92
92
  FlowRouter.reload();
93
93
  }
@@ -103,7 +103,7 @@ Steedos.ProcessManager.recall = function(object_name, record_id){
103
103
  var formId = 'processApprovalForm';
104
104
  Steedos.ProcessManager.showProcessApprovalForm('recall', {
105
105
  comment: {
106
- label: TAPi18n.__('process_approval_comment'),
106
+ label: t('process_approval_comment'),
107
107
  type: 'textarea',
108
108
  rows: 3,
109
109
  is_wide: true
@@ -111,7 +111,7 @@ Steedos.ProcessManager.recall = function(object_name, record_id){
111
111
  }, formId, {}, function(formValues, e, t){
112
112
  var result = Steedos.authRequest(`/api/v4/process/recall/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
113
113
  if(result.state === 'FAILURE'){
114
- toastr.error(TAPi18n.__(result.error));
114
+ toastr.error(t(result.error));
115
115
  }
116
116
  FlowRouter.reload();
117
117
  Modal.hide(t);
@@ -120,10 +120,10 @@ Steedos.ProcessManager.recall = function(object_name, record_id){
120
120
 
121
121
  Steedos.ProcessManager.approve = function(object_name, record_id, options){
122
122
  var formId = 'processApprovalForm';
123
- var title = `${TAPi18n.__('process_instance_history_action_approve')}` //TODO approval record name
123
+ var title = `${t('process_instance_history_action_approve')}` //TODO approval record name
124
124
  var schema = {
125
125
  comment: {
126
- label: TAPi18n.__('process_approval_comment'),
126
+ label: t('process_approval_comment'),
127
127
  type: 'textarea',
128
128
  rows: 3,
129
129
  is_wide: true
@@ -132,7 +132,7 @@ Steedos.ProcessManager.approve = function(object_name, record_id, options){
132
132
 
133
133
  if(options && options.showApprover){
134
134
  schema.approver = {
135
- label: TAPi18n.__('process_approval_approver_label'),
135
+ label: t('process_approval_approver_label'),
136
136
  type: 'lookup',
137
137
  reference_to: 'users',
138
138
  required: true,
@@ -154,7 +154,7 @@ Steedos.ProcessManager.approve = function(object_name, record_id, options){
154
154
  Steedos.ProcessManager.approve(object_name, record_id, {showApprover: true, value: {comment: formValues.insertDoc.comment}});
155
155
  }, 800)
156
156
  }else{
157
- toastr.error(TAPi18n.__(result.error));
157
+ toastr.error(t(result.error));
158
158
  Modal.hide(t);
159
159
  FlowRouter.reload();
160
160
  }
@@ -168,10 +168,10 @@ Steedos.ProcessManager.approve = function(object_name, record_id, options){
168
168
 
169
169
  Steedos.ProcessManager.reject = function(object_name, record_id){
170
170
  var formId = 'processApprovalForm';
171
- var title = `${TAPi18n.__('process_instance_history_action_reject')}` //TODO approval record name
171
+ var title = `${t('process_instance_history_action_reject')}` //TODO approval record name
172
172
  Steedos.ProcessManager.showProcessApprovalForm('reject', {
173
173
  comment: {
174
- label: TAPi18n.__('process_approval_comment'),
174
+ label: t('process_approval_comment'),
175
175
  type: 'textarea',
176
176
  rows: 3,
177
177
  is_wide: true
@@ -179,7 +179,7 @@ Steedos.ProcessManager.reject = function(object_name, record_id){
179
179
  }, formId, {}, function(formValues, e, t){
180
180
  var result = Steedos.authRequest(`/api/v4/process/reject/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
181
181
  if(result.state === 'FAILURE'){
182
- toastr.error(TAPi18n.__(result.error));
182
+ toastr.error(t(result.error));
183
183
  }
184
184
  FlowRouter.reload();
185
185
  Modal.hide(t);
@@ -190,14 +190,14 @@ Steedos.ProcessManager.reassign = function(object_name, record_id){
190
190
  var formId = 'processApprovalForm';
191
191
  Steedos.ProcessManager.showProcessApprovalForm('reassign', {
192
192
  approver: {
193
- label: TAPi18n.__('process_approval_approver_label_reassign'),
193
+ label: t('process_approval_approver_label_reassign'),
194
194
  type: 'lookup',
195
195
  reference_to: 'users',
196
196
  required: true,
197
197
  is_wide: true
198
198
  },
199
199
  comment: {
200
- label: TAPi18n.__('process_approval_comment'),
200
+ label: t('process_approval_comment'),
201
201
  type: 'textarea',
202
202
  rows: 3,
203
203
  is_wide: true
@@ -205,7 +205,7 @@ Steedos.ProcessManager.reassign = function(object_name, record_id){
205
205
  }, formId, {}, function(formValues, e, t){
206
206
  var result = Steedos.authRequest(`/api/v4/process/reassign/${object_name}/${record_id}`, {type: 'post', async: false, data: JSON.stringify(formValues.insertDoc)});
207
207
  if(result.state === 'FAILURE'){
208
- toastr.error(TAPi18n.__(result.error));
208
+ toastr.error(t(result.error));
209
209
  }
210
210
  FlowRouter.reload();
211
211
  Modal.hide(t);
@@ -61,6 +61,6 @@ module.exports = {
61
61
  if (!record) {
62
62
  record = {}
63
63
  }
64
- return Creator.baseObject.actions.standard_new.visible() && record.is_system;
64
+ return Steedos.Object.base.actions.standard_new.visible() && record.is_system;
65
65
  }
66
66
  }
@@ -29,6 +29,6 @@ module.exports = {
29
29
  if(!record){
30
30
  record = {}
31
31
  }
32
- return Creator.baseObject.actions.standard_new.visible() && record.is_system;
32
+ return Steedos.Object.base.actions.standard_new.visible() && record.is_system;
33
33
  }
34
34
  }
@@ -29,6 +29,6 @@ module.exports = {
29
29
  if(!record){
30
30
  record = {}
31
31
  }
32
- return Creator.baseObject.actions.standard_new.visible() && record.is_system;
32
+ return Steedos.Object.base.actions.standard_new.visible() && record.is_system;
33
33
  }
34
34
  }
@@ -29,6 +29,6 @@ module.exports = {
29
29
  if(!record){
30
30
  record = {}
31
31
  }
32
- return Creator.baseObject.actions.standard_new.visible() && record.is_system;
32
+ return Steedos.Object.base.actions.standard_new.visible() && record.is_system;
33
33
  }
34
34
  }
@@ -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: TAPi18n.__("action_field_updates_field_operation_options_null",{},lng),
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: TAPi18n.__("action_field_updates_field_operation_options_formula",{},lng),
185
+ label: steedosI18n.t("action_field_updates_field_operation_options_formula",{},lng),
186
186
  value: 'formula',
187
187
  });
188
188
  options.push({
189
- label: TAPi18n.__("action_field_updates_field_operation_options_literal",{},lng),
189
+ label: steedosI18n.t("action_field_updates_field_operation_options_literal",{},lng),
190
190
  value: 'literal',
191
191
  })
192
192
  }
@@ -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 util.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
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 util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
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,8 +1,12 @@
1
+ /*
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2025-01-13 11:05:56
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2025-03-05 16:40:58
6
+ * @Description:
7
+ */
1
8
  const _ = require("underscore");
2
- const util = require('@steedos/standard-objects').util;
3
9
  const objectql = require('@steedos/objectql');
4
- const register = require('@steedos/metadata-registrar');
5
- const InternalData = require('@steedos/standard-objects').internalData;
6
10
 
7
11
  function setSpaceAndOwner(record, that){
8
12
  record['space'] = that.spaceId
@@ -28,7 +32,7 @@ const getInternalApprovalProcesses = function(sourceApprovalProcesses, filters){
28
32
 
29
33
  module.exports = {
30
34
  beforeInsert: async function () {
31
- await util.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
35
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
32
36
 
33
37
  objectql.checkFormula(this.doc.entry_criteria, this.doc.object_name)
34
38
 
@@ -38,98 +42,5 @@ module.exports = {
38
42
  if(!this.doc.recall_record_lock){
39
43
  this.doc.recall_record_lock = 'unlock';
40
44
  }
41
- },
42
- beforeUpdate: async function () {
43
- if(_.has(this.doc, 'object_name')){
44
- var process = await objectql.getObject("process_definition").findOne(this.id);
45
- if(process.object_name != this.doc.object_name){
46
- throw new Error('禁止修改对象名称');
47
- }
48
- };
49
- if (_.has(this.doc, 'name')) {
50
- await util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
51
- }
52
-
53
- objectql.checkFormula(this.doc.entry_criteria, this.doc.object_name)
54
- },
55
- afterFind: async function(){
56
- let spaceId = this.spaceId;
57
- let filters = InternalData.parserFilters(this.query.filters)
58
- let approvalProcesses = [];
59
- if(filters.name){
60
- approvalProcess = register.getSourceApprovalProcess(filters.name);
61
- if(approvalProcess){
62
- approvalProcesses.push(approvalProcess);
63
- }
64
- }else{
65
- approvalProcesses = register.getSourceApprovalProcesses();
66
- }
67
-
68
- if (filters.object_name){
69
- approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
70
- }
71
-
72
- approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
73
-
74
- if(approvalProcesses){
75
- this.data.values = this.data.values.concat(approvalProcesses)
76
- this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
77
- }
78
- },
79
- afterAggregate: async function(){
80
- let filters = InternalData.parserFilters(this.query.filters)
81
- let approvalProcesses = [];
82
- if(filters.name){
83
- approvalProcess = register.getSourceApprovalProcess(filters.name);
84
- if(approvalProcess){
85
- approvalProcesses.push(approvalProcess);
86
- }
87
- }else{
88
- approvalProcesses = register.getSourceApprovalProcesses();
89
- }
90
-
91
- if (filters.object_name){
92
- approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
93
- }
94
-
95
- approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
96
-
97
- if(approvalProcesses){
98
- this.data.values = this.data.values.concat(approvalProcesses)
99
- }
100
- },
101
- afterCount: async function(){
102
- let filters = InternalData.parserFilters(this.query.filters)
103
- let approvalProcesses = [];
104
- if(filters.name){
105
- approvalProcess = register.getSourceApprovalProcess(filters.name);
106
- if(approvalProcess){
107
- approvalProcesses.push(approvalProcess);
108
- }
109
- }else{
110
- approvalProcesses = register.getSourceApprovalProcesses();
111
- }
112
-
113
- if (filters.object_name){
114
- approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
115
- }
116
-
117
- approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
118
-
119
- if(approvalProcesses){
120
- this.data.values = this.data.values + approvalProcesses.length
121
- }
122
- },
123
- afterFindOne: async function(){
124
- if(_.isEmpty(this.data.values)){
125
- let id = this.id
126
- if(id){
127
- let approvalProcess = objectql.getSourceApprovalProcess(id);
128
- if(approvalProcess){
129
- setSpaceAndOwner(approvalProcess, this);
130
- this.data.values = approvalProcess;
131
- }
132
- }
133
- }
134
45
  }
135
46
  }
@@ -8,7 +8,7 @@ const getLng = async function(userId){
8
8
 
9
9
  const getEmptyNodeTitle = async function(userId){
10
10
  let lng = await getLng(userId);
11
- return TAPi18n.__('process_approval_empty_node_title', {}, lng);
11
+ return t('process_approval_empty_node_title', {}, lng);
12
12
  }
13
13
 
14
14
  module.exports = {
@@ -1,7 +1,5 @@
1
1
  const _ = require("underscore");
2
2
  const objectql = require('@steedos/objectql');
3
- const util = require('@steedos/standard-objects').util;
4
- const InternalData = require('@steedos/standard-objects').internalData;
5
3
 
6
4
  function setSpaceAndOwner(record, that){
7
5
  record['space'] = that.spaceId
@@ -131,7 +129,7 @@ module.exports = {
131
129
  if (this.doc.order === 1) {
132
130
  this.doc.reject_behavior = 'reject_request';
133
131
  }
134
- await util.checkAPIName(this.object_name, 'name', this.doc.name, null, [['process_definition', '=', this.doc.process_definition]]);
132
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, null, [['process_definition', '=', this.doc.process_definition]]);
135
133
  if(!this.doc.filtrad){
136
134
  const objectName = await getProcessNodeObjectName(this.doc.process_definition);
137
135
  if(objectName){
@@ -157,7 +155,7 @@ module.exports = {
157
155
  }
158
156
  }
159
157
  if (_.has(this.doc, 'name')) {
160
- await util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['process_definition', '=', this.doc.process_definition]]);
158
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['process_definition', '=', this.doc.process_definition]]);
161
159
  }
162
160
 
163
161
  if(!this.doc.filtrad && this.doc.process_definition){
@@ -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 getInternalWorkflowNotifications = function(sourceWorkflowNotifications, filters, dbWorkflowNotifications){
7
5
  let workflowNotifications = [];
@@ -20,121 +18,11 @@ const getInternalWorkflowNotifications = function(sourceWorkflowNotifications, f
20
18
 
21
19
  module.exports = {
22
20
  beforeInsert: async function () {
23
- await util.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
21
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
24
22
  },
25
23
  beforeUpdate: async function () {
26
24
  if (_.has(this.doc, 'name')) {
27
- await util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
25
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
28
26
  }
29
- },
30
- afterFind: async function(){
31
- let filters = InternalData.parserFilters(this.query.filters)
32
- let fObjectName = filters.object_name;
33
- if(fObjectName){
34
- delete filters.object_name;
35
- }
36
-
37
- if(filters._id && filters._id.$ne){
38
- if(!_.isArray(filters._id.$ne)){
39
- filters._id.$ne = [filters._id.$ne]
40
- }
41
- }
42
- let dbWorkflowNotifications = Creator.getCollection("workflow_notifications").find(filters, {fields:{_id:1, name:1}}).fetch();
43
-
44
- let workflowNotifications = [];
45
- if(filters.name && filters.name.$in){
46
- for(let _name of filters.name.$in){
47
- let workflowNotification = await objectql.getWorkflowNotification(_name);
48
- if(workflowNotification){
49
- workflowNotifications.push(workflowNotification);
50
- }
51
- }
52
- }else if(filters._id && !filters._id.$ne){
53
- let notification = await objectql.getWorkflowNotification(filters._id);
54
- if(notification){
55
- workflowNotifications.push(notification);
56
- }
57
- }else if(fObjectName){
58
- workflowNotifications = await objectql.getObjectWorkflowNotifications(fObjectName);
59
- }else{
60
- workflowNotifications = await objectql.getAllWorkflowNotifications();
61
- }
62
-
63
- if(filters._id && filters._id.$ne){
64
- for(let neid of filters._id.$ne){
65
- workflowNotifications = _.filter(workflowNotifications, function(item){
66
- return item._id !== neid
67
- })
68
- }
69
- }
70
-
71
- workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters, dbWorkflowNotifications);
72
-
73
- if(workflowNotifications && workflowNotifications.length>0){
74
- this.data.values = this.data.values.concat(workflowNotifications)
75
- }
76
- },
77
- afterCount: async function(){
78
- let filters = InternalData.parserFilters(this.query.filters)
79
- let fObjectName = filters.object_name;
80
- if(fObjectName){
81
- delete filters.object_name;
82
- }
83
-
84
- if(filters._id && filters._id.$ne){
85
- if(!_.isArray(filters._id.$ne)){
86
- filters._id.$ne = [filters._id.$ne]
87
- }
88
- }
89
- let dbWorkflowNotifications = Creator.getCollection("workflow_notifications").find(filters, {fields:{_id:1, name:1}}).fetch();
90
-
91
- let workflowNotifications = [];
92
- if(filters._id && filters._id.$in){
93
- for(let id of filters._id.$in){
94
- let workflowNotification = await objectql.getWorkflowNotification(id);
95
- if(workflowNotification){
96
- workflowNotifications.push(workflowNotification);
97
- }
98
- }
99
- }else if(filters._id && !filters._id.$ne){
100
- let notification = await objectql.getWorkflowNotification(filters._id);
101
- if(notification){
102
- workflowNotifications.push(notification);
103
- }
104
- }else if(fObjectName){
105
- workflowNotifications = await objectql.getObjectWorkflowNotifications(fObjectName);
106
- }else{
107
- workflowNotifications = await objectql.getAllWorkflowNotifications();
108
- }
109
-
110
- if(filters._id && filters._id.$ne){
111
- for(let neid of filters._id.$ne){
112
- workflowNotifications = _.filter(workflowNotifications, function(item){
113
- return item._id !== neid
114
- })
115
- }
116
- }
117
-
118
- workflowNotifications = getInternalWorkflowNotifications(workflowNotifications, filters, dbWorkflowNotifications);
119
-
120
- if(workflowNotifications && workflowNotifications.length>0){
121
- this.data.values = this.data.values + workflowNotifications.length
122
- }
123
- },
124
- afterFindOne: async function(){
125
- if(_.isEmpty(this.data.values)){
126
- let id = this.id
127
-
128
- let dbNotification = Creator.getCollection("workflow_notifications").find({name: id}).fetch();
129
- if(dbNotification && dbNotification.length > 0){
130
- this.data.values = dbNotification[0];
131
- return;
132
- }
133
-
134
- let workflowNotification = await objectql.getWorkflowNotification(id);
135
- if(workflowNotification){
136
- this.data.values = workflowNotification;
137
- }
138
- }
139
- },
27
+ }
140
28
  }
@@ -1,143 +1,13 @@
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
-
6
- const getInternalOutboundMessages = function(sourceOutboundMessages, filters, dbOutboundMessages){
7
- let messages = [];
8
-
9
- if(!filters.is_system){
10
- _.forEach(sourceOutboundMessages, function(doc){
11
- if(!_.find(dbOutboundMessages, function(p){
12
- return p.name === doc.name
13
- })){
14
- messages.push(doc);
15
- }
16
- })
17
- }
18
- return messages;
19
- }
20
3
 
21
4
  module.exports = {
22
5
  beforeInsert: async function () {
23
- await util.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
6
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
24
7
  },
25
8
  beforeUpdate: async function () {
26
9
  if (_.has(this.doc, 'name')) {
27
- await util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
28
- }
29
- },
30
- afterFind: async function(){
31
- let filters = InternalData.parserFilters(this.query.filters)
32
- let fObjectName = filters.object_name;
33
-
34
- if(fObjectName){
35
- delete filters.object_name;
36
- }
37
-
38
- if(filters._id && filters._id.$ne){
39
- if(!_.isArray(filters._id.$ne)){
40
- filters._id.$ne = [filters._id.$ne]
41
- }
10
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
42
11
  }
43
-
44
- let dbOutboundMessages = Creator.getCollection("workflow_outbound_messages").find(filters, {fields:{_id:1, name:1}}).fetch();
45
-
46
- let messages = [];
47
- if(filters.name && filters.name.$in){
48
- for(let _name of filters.name.$in){
49
- let message = await objectql.getWorkflowOutboundMessage(_name);
50
- if(message){
51
- messages.push(message);
52
- }
53
- }
54
- }else if(filters._id && !filters._id.$ne){
55
- let message = await objectql.getWorkflowOutboundMessage(filters._id);
56
- if(message){
57
- messages.push(message);
58
- }
59
- }else if(fObjectName){
60
- messages = await objectql.getObjectWorkflowOutboundMessages(fObjectName);
61
- }else{
62
- messages = await objectql.getAllWorkflowOutboundMessages();
63
- }
64
-
65
- if(filters._id && filters._id.$ne){
66
- for(let neid of filters._id.$ne){
67
- messages = _.filter(messages, function(item){
68
- return item._id !== neid
69
- })
70
- }
71
- }
72
-
73
- messages = getInternalOutboundMessages(messages, filters, dbOutboundMessages);
74
-
75
- if(messages && messages.length>0){
76
- this.data.values = this.data.values.concat(messages)
77
- }
78
- },
79
- afterCount: async function(){
80
- let filters = InternalData.parserFilters(this.query.filters)
81
- let fObjectName = filters.object_name;
82
-
83
- if(fObjectName){
84
- delete filters.object_name;
85
- }
86
-
87
- if(filters._id && filters._id.$ne){
88
- if(!_.isArray(filters._id.$ne)){
89
- filters._id.$ne = [filters._id.$ne]
90
- }
91
- }
92
-
93
- let dbOutboundMessages = Creator.getCollection("workflow_outbound_messages").find(filters, {fields:{_id:1, name:1}}).fetch();
94
- let messages = [];
95
- if(filters._id && filters._id.$in){
96
- for(let id of filters._id.$in){
97
- let message = await objectql.getWorkflowOutboundMessage(id);
98
- if(message){
99
- messages.push(message);
100
- }
101
- }
102
- }else if(filters._id && !filters._id.$ne){
103
- let message = await objectql.getWorkflowOutboundMessage(filters._id);
104
- if(message){
105
- messages.push(message);
106
- }
107
- }else if(fObjectName){
108
- messages = await objectql.getObjectWorkflowOutboundMessages(fObjectName);
109
- }else{
110
- messages = await objectql.getAllWorkflowOutboundMessages();
111
- }
112
-
113
- if(filters._id && filters._id.$ne){
114
- for(let neid of filters._id.$ne){
115
- messages = _.filter(messages, function(item){
116
- return item._id !== neid
117
- })
118
- }
119
- }
120
-
121
- messages = getInternalOutboundMessages(messages, filters, dbOutboundMessages);
122
-
123
- if(messages && messages.length>0){
124
- this.data.values = this.data.values + messages.length
125
- }
126
- },
127
- afterFindOne: async function(){
128
- if(_.isEmpty(this.data.values)){
129
- let id = this.id
130
-
131
- let dbNotification = Creator.getCollection("workflow_outbound_messages").find({name: id}).fetch();
132
- if(dbNotification && dbNotification.length > 0){
133
- this.data.values = dbNotification[0];
134
- return;
135
- }
136
-
137
- let message = await objectql.getWorkflowOutboundMessage(id);
138
- if(message){
139
- this.data.values = message;
140
- }
141
- }
142
- },
12
+ }
143
13
  }
@@ -2,93 +2,20 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2021-08-30 12:06:41
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-03-13 14:57:01
5
+ * @LastEditTime: 2025-03-05 16:42:15
6
6
  * @Description:
7
7
  */
8
8
  const _ = require("underscore");
9
- const util = require('@steedos/standard-objects').util;
10
9
  const objectql = require("@steedos/objectql");
11
- const register = require("@steedos/metadata-registrar")
12
- const InternalData = require('@steedos/standard-objects').internalData;
13
-
14
- const getInternalWorkflowRules = function(sourceWorkflowRules, filters, dbWorkflowRules){
15
- let workflowRules = [];
16
-
17
- if(!filters.is_system){
18
- _.forEach(sourceWorkflowRules, function(doc){
19
- if(!_.find(dbWorkflowRules, function(p){
20
- return p.name === doc.name
21
- })){
22
- workflowRules.push(doc);
23
- }
24
- })
25
- }
26
- return workflowRules;
27
- }
28
10
 
29
11
  module.exports = {
30
12
  beforeInsert: async function () {
31
- await util.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
13
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, undefined, [['is_system','!=', true]]);
32
14
 
33
15
  },
34
16
  beforeUpdate: async function () {
35
17
  if (_.has(this.doc, 'name')) {
36
- await util.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
37
- }
38
- },
39
- afterFind: async function(){
40
- let filters = InternalData.parserFilters(this.query.filters)
41
- let workflowRules = [];
42
-
43
- let fObjectName = filters.object_name;
44
-
45
- if(fObjectName){
46
- delete filters.object_name;
47
- }
48
-
49
- let dbWorkflowRules = Creator.getCollection("workflow_rule").find(filters, {fields:{_id:1, name:1}}).fetch()
50
-
51
- if(fObjectName){
52
- workflowRules = await register.getObjectWorkflowRules(fObjectName);
53
- }else{
54
- workflowRules = await register.getAllWorkflowRules();
55
- }
56
-
57
- workflowRules = getInternalWorkflowRules(workflowRules, filters, dbWorkflowRules);
58
-
59
- if(workflowRules && workflowRules.length>0){
60
- this.data.values = this.data.values.concat(workflowRules)
61
- }
62
- },
63
- afterCount: async function(){
64
- let filters = InternalData.parserFilters(this.query.filters)
65
- let workflowRules = [];
66
- let fObjectName = filters.object_name;
67
-
68
- if(fObjectName){
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);
75
- }else{
76
- workflowRules = await register.getAllWorkflowRules();
18
+ await objectql.checkAPIName(this.object_name, 'name', this.doc.name, this.id, [['is_system','!=', true]]);
77
19
  }
78
-
79
- workflowRules = getInternalWorkflowRules(workflowRules, filters, dbWorkflowRules);
80
-
81
- if(workflowRules && workflowRules.length>0){
82
- this.data.values = this.data.values + workflowRules.length
83
- }
84
- },
85
- afterFindOne: async function(){
86
- if(_.isEmpty(this.data.values)){
87
- let id = this.id
88
- let workflowRule = await register.getWorkflowRule(id);
89
- if(workflowRule){
90
- this.data.values = workflowRule;
91
- }
92
- }
93
- },
20
+ }
94
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-process-approval",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.8",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -10,11 +10,11 @@
10
10
  "steedos"
11
11
  ],
12
12
  "dependencies": {
13
- "@steedos/process": "3.0.0-beta.2",
13
+ "@steedos/process": "3.0.0-beta.8",
14
14
  "nanoid": "^3.3.4"
15
15
  },
16
16
  "description": "steedos package",
17
17
  "repository": {},
18
18
  "license": "MIT",
19
- "gitHead": "72fa51bda8ff714d5fdb933bf0a45ea4cb82df74"
19
+ "gitHead": "723d92765db5342a374c7aacb5b835e69f77ca4b"
20
20
  }
@@ -8,7 +8,7 @@
8
8
  "use strict";
9
9
  const project = require('./package.json');
10
10
  const packageName = project.name;
11
- const packageLoader = require('@steedos/service-meteor-package-loader');
11
+ const packageLoader = require('@steedos/service-package-loader');
12
12
  /**
13
13
  * @typedef {import('moleculer').Context} Context Moleculer's Context
14
14
  */
package/public/.md DELETED
@@ -1,3 +0,0 @@
1
- ### 静态公开资源文件
2
-
3
- - 此文件夹中的文件自动添加到根路由
package/src/.md DELETED
@@ -1,3 +0,0 @@
1
- ### src
2
-
3
- - 软件包不会加载此文件夹下的文件, 可用于存放ts文件等
package/webapp/.md DELETED
@@ -1 +0,0 @@
1
- - 存放web项目