@steedos/standard-object-database 2.7.0-beta.4 → 2.7.0-beta.6

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.
@@ -110,8 +110,12 @@ fields:
110
110
  label: Reference to field
111
111
  help: The value of the associated object saved to the current object field; For example, after object A is associated with object B, when A1 record is associated with B1 record, B1 record will be stored by default_ Save the ID in the A1 record. If the foreign key field is modified, the 'foreign key field' will be replaced_ Store the ID in the A1 record.
112
112
  description: The default is the primary key, and the default value is _id.
113
+ filters:
114
+ label: Lookup Relationship Filters Condition
115
+ help: When the field type is Lookup Relationship or Master Detail Relationship, filtering conditions can be configured for the field, filtering option list; The field values can be configured as formulas, and the fields referenced in the formulas need to be configured in Dependent Fields at the same time
116
+ description:
113
117
  filtersFunction:
114
- label: filters Function
118
+ label: Lookup Relationship Filters Function
115
119
  help:
116
120
  description:
117
121
  optionsFunction:
@@ -107,8 +107,12 @@ fields:
107
107
  label: 外键字段
108
108
  help: 关联的对象保存到当前对象字段的值;例如:A对象关联B对象后,当A1记录关联了B1记录,默认会存B1记录的_id存到A1记录中。如果修改了外键字段后,会将“外键字段”替换_id存储到A1记录中。
109
109
  description: '默认为主键,默认值是_id'
110
+ filters:
111
+ label: 相关表过滤条件
112
+ help: 当字段类型为相关表关系或主/子表关系时,可以为该字段配置过滤条件,过滤选项列表;其中字段值可以配置为公式,公式中引用的字段需要同时配置在依赖的字段中
113
+ description:
110
114
  filtersFunction:
111
- label: 过滤器函数
115
+ label: 相关表过滤器函数
112
116
  help:
113
117
  description:
114
118
  optionsFunction:
@@ -38,7 +38,58 @@ fields:
38
38
  # omit: true
39
39
  # hidden: true
40
40
  label: Visible
41
- sort_no: 150
41
+ is_wide: true
42
+ sort_no: 200
43
+ defaultValue: true
44
+ amis:
45
+ type: fieldSet
46
+ title: 状态
47
+ body:
48
+ - name: visible
49
+ label: 显示
50
+ type: switch
51
+ staticOn: ${global.mode==='edit'?false:true}
52
+ - name: visible_type
53
+ label: 条件
54
+ type: select
55
+ value: static
56
+ visibleOn: "${visible === true}"
57
+ clearable: false
58
+ staticOn: ${global.mode==='edit'?false:true}
59
+ options:
60
+ - label: 静态值
61
+ value: static
62
+ - label: 表达式
63
+ value: expression
64
+ visible_type:
65
+ name: visible_type
66
+ type: select
67
+ readonly: true
68
+ visible_on: "{{false}}"
69
+ visibleOn:
70
+ type: text
71
+ label: 表达式
72
+ is_wide: true
73
+ sort_no: 210
74
+ amis:
75
+ type: wrapper
76
+ body:
77
+ - type: input-text
78
+ name: visibleOn
79
+ static: true
80
+ label: 表达式
81
+ visibleOn: "${global.mode != 'edit'}"
82
+ - type: input-formula
83
+ name: visibleOn
84
+ mixedMode: true
85
+ label: 表达式
86
+ visibleOn: "${global.mode==='edit' && visible_type == 'expression'}"
87
+ variables:
88
+ - label: 当前记录
89
+ value: record
90
+ children:
91
+ - label: 名称
92
+ value: name
42
93
  'on':
43
94
  type: lookup
44
95
  label: 'On'
@@ -364,8 +364,20 @@ fields:
364
364
  sort_no: 220
365
365
  amis:
366
366
  disabledOn: "${is_system == true}"
367
+ filters:
368
+ label: Lookup Relationship Filters Condition
369
+ type: code
370
+ is_wide: true
371
+ hidden: false
372
+ readonly: false
373
+ sort_no: 447
374
+ group: Advanced
375
+ visible_on: "{{(['lookup', 'master_detail'].indexOf(formData.type) > -1 ? true: false) && !!formData.reference_to}}"
376
+ inlineHelpText: vWhen the field type is Lookup Relationship or Master Detail Relationship, filtering conditions can be configured for the field, filtering option list; The field values can be configured as formulas, and the fields referenced in the formulas need to be configured in Dependent Fields at the same time
377
+ amis:
378
+ disabledOn: "${is_system == true}"
367
379
  filtersFunction:
368
- label: filters Function
380
+ label: Lookup Relationship Filters Function
369
381
  type: code
370
382
  language: javascript
371
383
  is_wide: true
@@ -525,7 +537,6 @@ fields:
525
537
  sort_no: 280
526
538
  amis:
527
539
  enableDialog: false
528
- disabledOn: "${is_system == true}"
529
540
  auto_fill_mapping.$:
530
541
  label: Auto Fill Mapping
531
542
  blackbox: true
@@ -571,7 +582,7 @@ fields:
571
582
  };
572
583
  var currentFilter = [];
573
584
  var referenceObject = BuilderAmisObject && BuilderAmisObject.AmisLib && BuilderAmisObject.AmisLib.getUISchemaSync(values.reference_to);
574
- var fromField = referenceObject && referenceObject.fields[values.auto_fill_mapping__from];
585
+ var fromField = referenceObject && referenceObject.fields[values.from || values.auto_fill_mapping__from];
575
586
 
576
587
  if (fromField && fromField.data_type) {
577
588
  currentFilter.push(['type', 'in', fieldFilters[fromField.data_type] || fromField.data_type.split()]);
@@ -25,8 +25,8 @@
25
25
  ]
26
26
  }
27
27
  },
28
- "initApiAdaptor": "const defaultValue_field_value = payload.data.defaultValue; if(defaultValue_field_value && _.isString(defaultValue_field_value) && defaultValue_field_value.indexOf('{')>-1 ){ payload.data.defaultValue_formula = defaultValue_field_value; delete payload.data.defaultValue; } return payload;",
29
- "apiRequestAdaptor": "if(formData.defaultValue_formula){ formData.defaultValue = formData.defaultValue_formula } __saveData = JSON.stringify(JSON.stringify(formData)); api.data = {query: query.replace('{__saveData}', __saveData)}; api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
28
+ "initApiAdaptor": "const defaultValue_field_value = payload.data.defaultValue;\nif (defaultValue_field_value && _.isString(defaultValue_field_value) && defaultValue_field_value.indexOf('{') > -1) {\n payload.data.defaultValue_formula = defaultValue_field_value;\n delete payload.data.defaultValue;\n}\n\nif (recordId) {\n var data = payload.data;\n if (data) {\n data.filters = window.amisConvert.filtersToConditions(data.filters || []);\n }\n payload.data = data;\n}\nreturn payload;",
29
+ "apiRequestAdaptor": "if (formData.defaultValue_formula) {\n formData.defaultValue = formData.defaultValue_formula\n}\nif (formData.filters) {\n formData.filters = window.amisConvert.conditionsToFilters(formData.filters);\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\napi.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert');",
30
30
  "submitSuccActions": [
31
31
  {
32
32
  "actionType": "custom",
@@ -142,8 +142,29 @@
142
142
  }
143
143
  ]
144
144
  }
145
- }
145
+ },
146
+ "disabledOn": "${is_system == true}",
147
+ "searchable": true
148
+ }
149
+ },
150
+ "filters": {
151
+ "amis": {
152
+ "type": "condition-builder",
153
+ "description": "",
154
+ "id": "u:a9f2232e30d7",
155
+ "source": {
156
+ "method": "get",
157
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${reference_to}",
158
+ "dataType": "json",
159
+ "headers": {
160
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
161
+ }
162
+ },
163
+ "className": "col-span-2 m-0"
146
164
  }
165
+ },
166
+ "filtersFunction": {
167
+ "hidden": true
147
168
  }
148
169
  },
149
170
  "form": {
@@ -2,7 +2,7 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2022-05-28 11:07:57
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-10-16 13:58:22
5
+ * @LastEditTime: 2024-03-14 10:29:44
6
6
  * @Description:
7
7
  */
8
8
  const InternalData = require('@steedos/standard-objects').internalData;
@@ -12,20 +12,18 @@ const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
12
12
  module.exports = {
13
13
  beforeInsert: async function(){
14
14
  const { doc } = this;
15
+ delete doc.visible_type
15
16
  doc.visible;
16
17
  },
17
18
  beforeUpdate: async function(){
18
19
  const { doc } = this;
20
+ delete doc.visible_type
19
21
  doc.visible;
20
22
  },
21
23
  beforeFind: async function () {
22
24
  delete this.query.fields;
23
25
  },
24
26
 
25
- beforeAggregate: async function () {
26
- delete this.query.fields;
27
- },
28
-
29
27
  afterFind: async function(){
30
28
  let filters = InternalData.parserFilters(this.query.filters)
31
29
  const { spaceId } = this;
@@ -52,32 +50,15 @@ module.exports = {
52
50
  }
53
51
  }
54
52
  }
55
- },
56
- afterAggregate: async function(){
57
- let filters = InternalData.parserFilters(this.query.filters)
58
- const { spaceId } = this;
59
-
60
- let objectName = filters.object;
61
- if(!objectName && filters._id && filters._id.indexOf(".") > -1){
62
- objectName = filters._id.split('.')[0];
63
- }
64
53
 
65
- let dataList = await InternalData.getObjectActions(objectName, this.userId);
66
- if (!_.isEmpty(dataList)) {
67
- dataList.forEach((doc) => {
68
- if (!_.find(this.data.values, (value) => {
69
- return value.name === doc.name
70
- })) {
71
- this.data.values.push(Object.assign({_id: `${objectName}.${doc.name}`}, doc));
72
- }
73
- })
74
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
75
- if (records.length > 0) {
76
- this.data.values = records;
77
- } else {
78
- this.data.values.length = 0;
54
+ _.each(this.data.values, (item)=>{
55
+ if(item.visibleOn){
56
+ item.visible_type = "expression"
57
+ }else if(item.visible === true){
58
+ item.visible_type = "static"
79
59
  }
80
- }
60
+ })
61
+
81
62
  },
82
63
  afterCount: async function(){
83
64
  delete this.query.fields;
@@ -95,6 +76,15 @@ module.exports = {
95
76
  }
96
77
  }
97
78
  }
79
+
80
+ if(this.data.values){
81
+ if(this.data.values.visibleOn){
82
+ this.data.values.visible_type = "expression"
83
+ }else if(this.data.values.visible === true){
84
+ this.data.values.visible_type = "static"
85
+ }
86
+ }
87
+
98
88
  },
99
89
  afterDelete: async function(){
100
90
  await sleep(1000 * 2);
@@ -18,7 +18,7 @@ module.exports = {
18
18
  },
19
19
  afterFind: async function(){
20
20
  const { spaceId } = this;
21
- let dataList = register.getAllObjectValidationRules();
21
+ let dataList = await register.getAllObjectValidationRules();
22
22
  if (!_.isEmpty(dataList)) {
23
23
  dataList.forEach((doc) => {
24
24
  if (!_.find(this.data.values, (value) => {
@@ -36,25 +36,6 @@ module.exports = {
36
36
  }
37
37
 
38
38
  },
39
- afterAggregate: async function(){
40
- const { spaceId } = this;
41
- let dataList = register.getAllObjectValidationRules();
42
- if (!_.isEmpty(dataList)) {
43
- dataList.forEach((doc) => {
44
- if (!_.find(this.data.values, (value) => {
45
- return value.name === doc.name
46
- })) {
47
- this.data.values.push(doc);
48
- }
49
- })
50
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
51
- if (records.length > 0) {
52
- this.data.values = records;
53
- } else {
54
- this.data.values.length = 0;
55
- }
56
- }
57
- },
58
39
  afterCount: async function(){
59
40
  delete this.query.fields;
60
41
  let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId))
@@ -62,7 +43,7 @@ module.exports = {
62
43
  },
63
44
  afterFindOne: async function(){
64
45
  if (_.isEmpty(this.data.values)) {
65
- const all = register.getAllObjectValidationRules();
46
+ const all = await register.getAllObjectValidationRules();
66
47
  const id = this.id;
67
48
  this.data.values = _.find(all, function (item) {
68
49
  return item._id === id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.7.0-beta.4",
3
+ "version": "2.7.0-beta.6",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,10 +12,10 @@
12
12
  "description": "steedos package",
13
13
  "dependencies": {
14
14
  "@steedos-widgets/amis-lib": "^1.0.22",
15
- "@steedos/metadata-core": "2.7.0-beta.4",
16
- "@steedos/standard-objects": "2.7.0-beta.4"
15
+ "@steedos/metadata-core": "2.7.0-beta.6",
16
+ "@steedos/standard-objects": "2.7.0-beta.6"
17
17
  },
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "01af290340359e2ea4d2d9a0ae5e56196020c952"
20
+ "gitHead": "375ec701f921e76a94071d0c4004727d8dc6a8a4"
21
21
  }
@@ -116,7 +116,7 @@ module.exports = {
116
116
  }
117
117
  if(data.is_system){
118
118
  // 'label' 先禁止编辑label , 目前由于i18n的问题导致 label无效.
119
- data = _.pick(data, ['defaultValue', 'group', 'rows', 'sort_no', 'is_wide', 'index', 'sortable', 'searchable', 'filterable', 'visible_on', 'inlineHelpText', 'description', 'amis', 'required', 'unique', 'readonly', 'hidden', 'deleted_lookup_record_behavior', 'enable_thousands', 'autonumber_enable_modify']);
119
+ data = _.pick(data, ['defaultValue', 'group', 'rows', 'sort_no', 'is_wide', 'index', 'sortable', 'searchable', 'filterable', 'visible_on', 'inlineHelpText', 'description', 'amis', 'required', 'unique', 'readonly', 'hidden', 'deleted_lookup_record_behavior', 'enable_thousands', 'autonumber_enable_modify', 'auto_fill_mapping']);
120
120
  }
121
121
  return object.update(id, data, userSession)
122
122
  },