@steedos/standard-process-approval 2.4.0-beta.7 → 2.4.0

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.
@@ -1,63 +1,10 @@
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
- }
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
+ */
61
8
 
62
9
  Steedos.getObjectsOptions = function (filterFunction) {
63
10
  var options = [];
@@ -25,6 +25,13 @@ fields:
25
25
  operation:
26
26
  label: 新字段值类型
27
27
  help:
28
+ options:
29
+ - label: 空值 (null)
30
+ value: 'null'
31
+ - label: 使用公式设置新值
32
+ value: formula
33
+ - label: 特定值
34
+ value: literal
28
35
  description:
29
36
  formula:
30
37
  label: 公式
@@ -56,7 +56,8 @@ module.exports = {
56
56
  }
57
57
  });
58
58
  },
59
- customizeVisible: function (object_name, record_id, record_permissions, record) {
59
+ customizeVisible: function (object_name, record_id, record_permissions, data) {
60
+ var record = data && data.record;
60
61
  if (!record) {
61
62
  record = {}
62
63
  }
@@ -18,12 +18,8 @@ fields:
18
18
  is_wide: true
19
19
  filterable: true
20
20
  create: false
21
- # reference_to: objects
21
+ reference_to: objects
22
22
  reference_to_field: name
23
- optionsFunction: !!js/function |
24
- function(){
25
- return Steedos.getObjectsOptions();
26
- }
27
23
  description:
28
24
  label: Description
29
25
  type: textarea
@@ -6,7 +6,7 @@ fields:
6
6
  name:
7
7
  type: text
8
8
  process_definition:
9
- type: master_detail
9
+ type: lookup
10
10
  is_wide: true
11
11
  reference_to: process_definition
12
12
  target_object:
@@ -24,7 +24,8 @@ module.exports = {
24
24
  }
25
25
  });
26
26
  },
27
- customizeVisible: function(object_name, record_id, record_permissions, record){
27
+ customizeVisible: function(object_name, record_id, record_permissions, data){
28
+ var record = data && data.record;
28
29
  if(!record){
29
30
  record = {}
30
31
  }
@@ -3,7 +3,7 @@ label: Field Updates
3
3
  icon: record
4
4
  hidden: true
5
5
  enable_inline_edit: false
6
- # version: 2
6
+ version: 2
7
7
  enable_enhanced_lookup: true
8
8
  fields:
9
9
  name:
@@ -16,103 +16,38 @@ fields:
16
16
  object_name:
17
17
  label: Object Name
18
18
  type: lookup
19
- optionsFunction: !!js/function |
20
- function () {
21
- return Steedos.getObjectsOptions();
22
- }
19
+ reference_to: objects
20
+ reference_to_field: name
23
21
  target_object:
24
22
  type: lookup
25
23
  label: Object to Update
24
+ reference_to: objects
25
+ reference_to_field: name
26
26
  depend_on:
27
27
  - object_name
28
- optionsFunction: !!js/function |
29
- function (doc) {
30
- var object = Creator.objectsByName[doc.object_name];
31
- if(object){
32
- var _options = [{label: object.label, value: object.name}];
33
- _.forEach(object.fields, function (field, fname) {
34
- if(field && field.type === 'master_detail' && _.isString(field.reference_to)){
35
- var referenceToObject = Creator.objectsByName[field.reference_to];
36
- if(referenceToObject){
37
- _options.push({
38
- label: referenceToObject.label,
39
- value: field.name,
40
- });
41
- }
42
- }
43
- });
44
- return _options;
45
- }
46
- return [];
47
- }
48
28
  field_name:
49
29
  label: Field to Update
50
30
  type: lookup
51
31
  showIcon: false
32
+ reference_to: object_fields
33
+ reference_to_field: name
52
34
  depend_on:
53
35
  - object_name
54
36
  - target_object
55
- optionsFunction: !!js/function |
56
- function (doc) {
57
- var mainObjectName = null;
58
- if(doc.target_object && doc.target_object != doc.object_name){
59
- mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;
60
- }else{
61
- mainObjectName = doc.object_name;
62
- }
63
- var object = Creator.objectsByName[mainObjectName];
64
- if(object){
65
- var _options = [];
66
- _.forEach(object.fields, function (field, fname) {
67
- if(["formula", "summary", "autonumber"].indexOf(field.type) < 0){
68
- /*公式、累计汇总、自动编号三种字段类型是只读的,不允许字段更新来变更其值*/
69
- _options.push({
70
- label: field.label,
71
- value: field.name,
72
- });
73
- }
74
- });
75
- return _options;
76
- }
77
- return [];
78
- }
79
37
  operation:
80
- type: lookup
38
+ type: select
81
39
  showIcon: false
82
40
  depend_on:
83
41
  - field_name
84
42
  - target_object
85
43
  - object_name
86
- optionsFunction: !!js/function |
87
- function (doc) {
88
- var mainObjectName = null;
89
- if(doc.target_object && doc.target_object != doc.object_name){
90
- mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;
91
- }else{
92
- mainObjectName = doc.object_name;
93
- }
94
- var object = Creator.objectsByName[mainObjectName];
95
- if(object && doc.field_name){
96
- var _options = [];
97
- var field = object.fields[doc.field_name];
98
- if(field && field.type != 'boolean'){
99
- _options.push({
100
- label: TAPi18n.__("action_field_updates_field_operation_options_null"),
101
- value: 'null',
102
- })
103
- }
104
- _options.push({
105
- label: TAPi18n.__("action_field_updates_field_operation_options_formula"),
106
- value: 'formula',
107
- });
108
- _options.push({
109
- label: TAPi18n.__("action_field_updates_field_operation_options_literal"),
110
- value: 'literal',
111
- })
112
- return _options;
113
- }
114
- return [];
115
- }
44
+ options:
45
+ - label: 'null'
46
+ value: 'null'
47
+ - label: formula
48
+ value: formula
49
+ - label: literal
50
+ value: literal
116
51
  # options:
117
52
  # - label: 'Null'
118
53
  # value: 'null'
@@ -127,10 +62,12 @@ fields:
127
62
  formula:
128
63
  type: textarea
129
64
  is_wide: true
65
+ visible_on: "{{formData.operation === 'formula' ? true: false}}"
130
66
  literal_value:
131
67
  type: text
132
68
  is_wide: true
133
69
  label: Literal value
70
+ visible_on: "{{formData.operation === 'literal' ? true: false}}"
134
71
  notify_assignee:
135
72
  type: boolean
136
73
  hidden: true
@@ -24,7 +24,8 @@ module.exports = {
24
24
  }
25
25
  });
26
26
  },
27
- customizeVisible: function(object_name, record_id, record_permissions, record){
27
+ customizeVisible: function(object_name, record_id, record_permissions, data){
28
+ var record = data && data.record;
28
29
  if(!record){
29
30
  record = {}
30
31
  }
@@ -21,10 +21,8 @@ fields:
21
21
  type: lookup
22
22
  required: true
23
23
  is_wide: true
24
- optionsFunction: !!js/function |
25
- function () {
26
- return Steedos.getObjectsOptions();
27
- }
24
+ reference_to: objects
25
+ reference_to_field: name
28
26
  title:
29
27
  label: Title
30
28
  type: textarea
@@ -51,7 +49,7 @@ fields:
51
49
  - object_name
52
50
  optionsFunction: !!js/function |
53
51
  function (doc){
54
- var object = Creator.objectsByName[doc.object_name];
52
+ var object = Creator.getObject(doc.object_name);
55
53
  var options = [];
56
54
  if(object){
57
55
  var userFields = _.filter(object.fields, function(field){
@@ -3,16 +3,12 @@ label: 要发送的字段
3
3
  type: lookup
4
4
  multiple: true
5
5
  is_wide: true
6
+ reference_to: object_fields
7
+ reference_to_field: name
6
8
  depend_on:
7
9
  - object_name
8
- optionsFunction: !<tag:yaml.org,2002:js/function> |-
9
- function (values) {
10
- if (!(values != null ? values.object_name : void 0)) {
11
- values.object_name = Session.get("object_name");
12
- }
13
- if(values.object_name && !_.isString(values.object_name)){
14
- values.object_name = values.object_name.name
15
- }
16
- return Creator.getObjectFieldOptions(values != null ? values.object_name : void 0);
17
- }
10
+ filtersFunction: !<tag:yaml.org,2002:js/function> |-
11
+ function(filters, values){
12
+ return ['object', '=', values.object_name]
13
+ }
18
14
  sort_no: 70
@@ -3,9 +3,7 @@ label: 对象
3
3
  type: lookup
4
4
  required: true
5
5
  is_wide: true
6
- optionsFunction: !!js/function |
7
- function () {
8
- return Steedos.getObjectsOptions();
9
- }
6
+ reference_to: objects
7
+ reference_to_field: name
10
8
  index: true
11
9
  sort_no: 10
@@ -24,7 +24,8 @@ module.exports = {
24
24
  }
25
25
  });
26
26
  },
27
- customizeVisible: function(object_name, record_id, record_permissions, record){
27
+ customizeVisible: function(object_name, record_id, record_permissions, data){
28
+ var record = data && data.record;
28
29
  if(!record){
29
30
  record = {}
30
31
  }
@@ -10,10 +10,8 @@ fields:
10
10
  type: lookup
11
11
  required: true
12
12
  is_wide: true
13
- optionsFunction: !!js/function |
14
- function () {
15
- return Steedos.getObjectsOptions();
16
- }
13
+ reference_to: objects
14
+ reference_to_field: name
17
15
  name:
18
16
  type: text
19
17
  required: true
@@ -52,7 +50,7 @@ fields:
52
50
  filtersFunction: !!js/function |
53
51
  function (filters, dependValues) {
54
52
  if(dependValues && dependValues.object_name){
55
- return "object_name eq '" + dependValues.object_name + "'";
53
+ return ['object_name','=',dependValues.object_name];
56
54
  }
57
55
  }
58
56
  workflow_notifications_actions:
@@ -68,7 +66,7 @@ fields:
68
66
  filtersFunction: !!js/function |
69
67
  function (filters, dependValues) {
70
68
  if(dependValues && dependValues.object_name){
71
- return "object_name eq '" + dependValues.object_name + "'";
69
+ return ['object_name','=',dependValues.object_name];
72
70
  }
73
71
  }
74
72
  workflow_outbound_messages_actions:
@@ -84,7 +82,7 @@ fields:
84
82
  filtersFunction: !!js/function |
85
83
  function (filters, dependValues) {
86
84
  if(dependValues && dependValues.object_name){
87
- return "object_name eq '" + dependValues.object_name + "'";
85
+ return ['object_name','=',dependValues.object_name];
88
86
  }
89
87
  }
90
88
  # boolean_filter: # TODO 暂不支持
@@ -136,7 +134,7 @@ fields:
136
134
  required: true
137
135
  time_triggers.$.date_field:
138
136
  label: 日期字段
139
- type: select
137
+ type: lookup
140
138
  depend_on:
141
139
  - object_name
142
140
  optionsFunction: !!js/function |
@@ -174,7 +172,7 @@ fields:
174
172
  filtersFunction: !!js/function |
175
173
  function (filters, dependValues) {
176
174
  if(dependValues && dependValues.object_name){
177
- return "object_name eq '" + dependValues.object_name + "'";
175
+ return ['object_name','=',dependValues.object_name];
178
176
  }
179
177
  }
180
178
  time_triggers.$.workflow_notifications_actions:
@@ -189,7 +187,7 @@ fields:
189
187
  filtersFunction: !!js/function |
190
188
  function (filters, dependValues) {
191
189
  if(dependValues && dependValues.object_name){
192
- return "object_name eq '" + dependValues.object_name + "'";
190
+ return ['object_name','=',dependValues.object_name];
193
191
  }
194
192
  }
195
193
  time_triggers.$.workflow_outbound_messages_actions:
@@ -204,7 +202,7 @@ fields:
204
202
  filtersFunction: !!js/function |
205
203
  function (filters, dependValues) {
206
204
  if(dependValues && dependValues.object_name){
207
- return "object_name eq '" + dependValues.object_name + "'";
205
+ return ['object_name','=',dependValues.object_name];
208
206
  }
209
207
  }
210
208
  description:
@@ -0,0 +1,252 @@
1
+ /*
2
+ * @Description: 提供action_field_updates(字段更新对象)需要的数据接口
3
+ */
4
+
5
+ const objectql = require("@steedos/objectql");
6
+ const steedosI18n = require("@steedos/i18n");
7
+ const _ = require("lodash");
8
+ const clone = require("clone");
9
+
10
+
11
+ module.exports = {
12
+ name: "action_field_updates",
13
+ mixins: [],
14
+ /**
15
+ * Settings
16
+ */
17
+ settings: {
18
+
19
+ },
20
+
21
+ /**
22
+ * Dependencies
23
+ */
24
+ dependencies: [],
25
+
26
+ /**
27
+ * Actions
28
+ */
29
+ actions: {
30
+ getTargetObjectOptions: {
31
+ // 需要传 objectName 参数进来。
32
+ rest: {
33
+ method: "GET",
34
+ path: "/target_object/options"
35
+ },
36
+ async handler(ctx) {
37
+ const options = await this.getTargetObjectOptions(ctx);
38
+ return { status: 0, data: { options } }
39
+ }
40
+ },
41
+ getFieldNameOptions: {
42
+ // 需要传 objectName, targetObject 参数进来。
43
+ rest: {
44
+ method: "GET",
45
+ path: "/field_name/options"
46
+ },
47
+ async handler(ctx) {
48
+ const options = await this.getFieldNameOptions(ctx);
49
+ return { status: 0, data: { options } }
50
+ }
51
+ },
52
+ getOperationOptions: {
53
+ // 需要传 objectName, targetObject(非必填), field_name 参数进来。
54
+ rest: {
55
+ method: "GET",
56
+ path: "/operation/options"
57
+ },
58
+ async handler(ctx) {
59
+ const options = await this.getOperationOptions(ctx);
60
+ return { status: 0, data: { options } }
61
+ }
62
+ },
63
+ getLiteralValueOptions: {
64
+ // 需要传 objectName, targetObject(非必填), field_name 参数进来。
65
+ rest: {
66
+ method: "GET",
67
+ path: "/literal_value/options"
68
+ },
69
+ async handler(ctx) {
70
+ const data = await this.getLiteralValueOptions(ctx);
71
+ return { status: 0, msg: "", data: data }
72
+ }
73
+ }
74
+ },
75
+
76
+ /**
77
+ * Events
78
+ */
79
+ events: {
80
+
81
+ },
82
+
83
+ /**
84
+ * Methods
85
+ */
86
+ methods: {
87
+ /* target_object 字段使用*/
88
+ getTargetObjectOptions: {
89
+ async handler(ctx) {
90
+ const userSession = ctx.meta.user;
91
+ const lng = userSession.language || 'zh-CN';
92
+ const objectName = ctx.params.objectName;
93
+ if(!objectName){
94
+ return []
95
+ }
96
+ const objectConfig = await objectql.getObjectConfig(objectName);
97
+ steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
98
+
99
+ const options = [{ label: objectConfig.label, value: objectConfig.name }];
100
+ for (fieldName in objectConfig.fields) {
101
+ const field = objectConfig.fields[fieldName]
102
+ if (field && field.type === 'master_detail' && _.isString(field.reference_to)) {
103
+ const referenceToObjectConfig = await objectql.getObjectConfig(field.reference_to);
104
+ steedosI18n.translationObject(lng, referenceToObjectConfig.name, referenceToObjectConfig);
105
+ if (referenceToObjectConfig) {
106
+ options.push({
107
+ label: referenceToObjectConfig.label,
108
+ value: field.name,
109
+ });
110
+ }
111
+ }
112
+ }
113
+ return options;
114
+ }
115
+ },
116
+ /* field_name 字段使用*/
117
+ getFieldNameOptions: {
118
+ async handler(ctx) {
119
+ const userSession = ctx.meta.user;
120
+ const lng = userSession.language || 'zh-CN';
121
+ const objectName = ctx.params.objectName;
122
+ const targetObject = ctx.params.targetObject;
123
+ if (!objectName || !targetObject) {
124
+ return []
125
+ }
126
+
127
+ let mainObjectName = null;
128
+ if (targetObject && targetObject != objectName) {
129
+ const targetField = await objectql.getObjectConfig(objectName).fields[targetObject];
130
+ mainObjectName = targetField && targetField.reference_to;
131
+ } else {
132
+ mainObjectName = objectName;
133
+ }
134
+
135
+ const objectConfig = await objectql.getObjectConfig(mainObjectName);
136
+ const options = [];
137
+ if (objectConfig) {
138
+ steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
139
+ _.forEach(objectConfig.fields, function (field, fname) {
140
+ if (["formula", "summary", "autonumber"].indexOf(field.type) < 0 && !field.hidden && !field.omit && !field.readonly && field.visible_on !== '{{false}}') {
141
+ /*公式、累计汇总、自动编号三种字段类型是只读的,不允许字段更新来变更其值*/
142
+ options.push({
143
+ label: field.label,
144
+ value: field.name,
145
+ });
146
+ }
147
+ });
148
+ }
149
+ return options;
150
+ }
151
+ },
152
+ /* operation 字段使用*/
153
+ getOperationOptions: {
154
+ async handler(ctx) {
155
+ const userSession = ctx.meta.user;
156
+ const lng = userSession.language || 'zh-CN';
157
+ const objectName = ctx.params.objectName;
158
+ const targetObject = ctx.params.targetObject;
159
+ const fieldName = ctx.params.fieldName;
160
+
161
+ if (!objectName || !fieldName) {
162
+ return []
163
+ }
164
+
165
+ let mainObjectName = null;
166
+ if (targetObject && targetObject != objectName) {
167
+ const targetField = await objectql.getObjectConfig(objectName).fields[targetObject];
168
+ mainObjectName = targetField && targetField.reference_to;
169
+ } else {
170
+ mainObjectName = objectName;
171
+ }
172
+
173
+ const objectConfig = await objectql.getObjectConfig(mainObjectName);
174
+ const options = [];
175
+ if (objectConfig) {
176
+ steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
177
+ const field = objectConfig.fields[fieldName];
178
+ if (field && field.type != 'boolean') {
179
+ options.push({
180
+ label: TAPi18n.__("action_field_updates_field_operation_options_null",{},lng),
181
+ value: 'null',
182
+ })
183
+ }
184
+ options.push({
185
+ label: TAPi18n.__("action_field_updates_field_operation_options_formula",{},lng),
186
+ value: 'formula',
187
+ });
188
+ options.push({
189
+ label: TAPi18n.__("action_field_updates_field_operation_options_literal",{},lng),
190
+ value: 'literal',
191
+ })
192
+ }
193
+ return options;
194
+ }
195
+ },
196
+ /* literal_value 字段使用*/
197
+ getLiteralValueOptions: {
198
+ async handler(ctx) {
199
+ const userSession = ctx.meta.user;
200
+ const lng = userSession.language || 'zh-CN';
201
+ const objectName = ctx.params.objectName;
202
+ const targetObject = ctx.params.targetObject;
203
+ const fieldName = ctx.params.fieldName;
204
+
205
+ if (!objectName || !fieldName) {
206
+ return []
207
+ }
208
+
209
+ let mainObjectName = null;
210
+ if (targetObject && targetObject != objectName) {
211
+ const targetField = await objectql.getObjectConfig(objectName).fields[targetObject];
212
+ mainObjectName = targetField && targetField.reference_to;
213
+ } else {
214
+ mainObjectName = objectName;
215
+ }
216
+
217
+ const objectConfig = await objectql.getObjectConfig(mainObjectName);
218
+ let literal_value_schema = {
219
+ "type": "text",
220
+ "name": "literal_value",
221
+ "label": "指定新字段值",
222
+ "required": false,
223
+ "is_wide": true,
224
+ "labelClassName": "text-left"
225
+ }
226
+ if (objectConfig) {
227
+ steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
228
+ const field = objectConfig.fields[fieldName];
229
+ literal_value_schema = Object.assign({}, field, {
230
+ name: "literal_value",
231
+ label: "指定新字段值",
232
+ disabled: false,
233
+ readonly: false,
234
+ is_wide: true
235
+ });
236
+ }
237
+ return {
238
+ "body": [
239
+ {
240
+ "type": "steedos-field",
241
+ "field": literal_value_schema,
242
+ "name": "literal_value",
243
+ "clearValueOnHidden": true,
244
+ "fieldName": "literal_value",
245
+ "visibleOn": "this.operation === 'literal'"
246
+ }
247
+ ]
248
+ }
249
+ }
250
+ }
251
+ }
252
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-process-approval",
3
- "version": "2.4.0-beta.7",
3
+ "version": "2.4.0",
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.4.0-beta.7"
13
+ "@steedos/process": "2.4.0"
14
14
  },
15
15
  "description": "steedos package",
16
16
  "repository": {},
17
17
  "license": "MIT",
18
- "gitHead": "581c4cad88be53dbc0c6f4c4f13a3e645702d555"
18
+ "gitHead": "70a4e7417d8d86c47cf5c7e3bbe0e89f2cee4222"
19
19
  }