@steedos/standard-object-database 2.7.0-beta.1 → 2.7.0-beta.11

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.
Files changed (25) hide show
  1. package/main/default/objectTranslations/_object_reload_logs.en/_object_reload_logs.en.objectTranslation.yml +1 -1
  2. package/main/default/objectTranslations/_object_reload_logs.zh-CN/_object_reload_logs.zh-CN.objectTranslation.yml +1 -1
  3. package/main/default/objectTranslations/object_actions.en/object_actions.en.objectTranslation.yml +4 -0
  4. package/main/default/objectTranslations/object_actions.zh-CN/object_actions.zh-CN.objectTranslation.yml +4 -0
  5. package/main/default/objectTranslations/object_fields.en/object_fields.en.objectTranslation.yml +7 -1
  6. package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +7 -1
  7. package/main/default/objectTranslations/objects.en/objects.en.objectTranslation.yml +2 -0
  8. package/main/default/objectTranslations/objects.zh-CN/objects.zh-CN.objectTranslation.yml +2 -0
  9. package/main/default/objects/0.objects_reload.object.js +7 -0
  10. package/main/default/objects/_object_reload_logs.object.yml +1 -1
  11. package/main/default/objects/object_actions.object.yml +7 -0
  12. package/main/default/objects/object_fields.object.yml +19 -5
  13. package/main/default/objects/objects/buttons/reset.button.js +16 -0
  14. package/main/default/objects/objects/buttons/reset.button.yml +79 -0
  15. package/main/default/objects/objects.core.js +4 -4
  16. package/main/default/objects/objects.object.yml +7 -1
  17. package/main/default/pages/design_field_layout.page.amis.json +18 -9
  18. package/main/default/pages/object_fields_form.page.amis.json +24 -3
  19. package/main/default/services/database-objects.service.js +19 -2
  20. package/main/default/triggers/object_actions.trigger.js +24 -28
  21. package/main/default/triggers/object_fields.trigger.js +25 -1
  22. package/main/default/triggers/object_validation_rules.trigger.js +2 -21
  23. package/main/default/triggers/objects.trigger.js +12 -5
  24. package/package.json +4 -4
  25. package/package.service.js +2 -3
@@ -6,7 +6,7 @@ fields:
6
6
  label:
7
7
  help:
8
8
  description:
9
- change_date:
9
+ change_data:
10
10
  label:
11
11
  help:
12
12
  description:
@@ -6,7 +6,7 @@ fields:
6
6
  label:
7
7
  help:
8
8
  description:
9
- change_date:
9
+ change_data:
10
10
  label:
11
11
  help:
12
12
  description:
@@ -2,6 +2,10 @@ name: object_actions
2
2
  label: Object Action
3
3
  description:
4
4
  fields:
5
+ description:
6
+ label: Description
7
+ help:
8
+ description:
5
9
  object:
6
10
  label: Object
7
11
  help:
@@ -2,6 +2,10 @@ name: object_actions
2
2
  label: 操作按钮
3
3
  description:
4
4
  fields:
5
+ description:
6
+ label: 备注
7
+ help:
8
+ description:
5
9
  object:
6
10
  label: 所属对象
7
11
  help:
@@ -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:
@@ -383,6 +387,8 @@ fields:
383
387
  label: Enable Enhanced Lookup
384
388
  help:
385
389
  description:
390
+ is_customize:
391
+ label: Customize
386
392
  groups:
387
393
  external_data_source: External data source
388
394
  advanced: Advanced
@@ -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:
@@ -359,6 +363,8 @@ fields:
359
363
  label: 启用弹出窗口查找模式
360
364
  help:
361
365
  description:
366
+ is_customize:
367
+ label: 自定义
362
368
  groups:
363
369
  external_data_source: 外部数据源
364
370
  advanced: 高级
@@ -202,6 +202,8 @@ fields:
202
202
  label: After Edit
203
203
  compactLayouts:
204
204
  label: Highlight Fields
205
+ is_customize:
206
+ label: Customize
205
207
  groups:
206
208
  external_data_source: External data source
207
209
  switch: Switch
@@ -201,6 +201,8 @@ fields:
201
201
  label: 编辑页面显示之后
202
202
  compactLayouts:
203
203
  label: 高亮字段
204
+ is_customize:
205
+ label: 自定义
204
206
  groups:
205
207
  external_data_source: 外部数据源
206
208
  switch: 功能开关
@@ -1,3 +1,10 @@
1
+ /*
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2022-08-05 14:17:44
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2024-03-20 13:34:23
6
+ * @Description:
7
+ */
1
8
  var objectql = require('@steedos/objectql');
2
9
  var objectCore = require('./objects.core.js');
3
10
 
@@ -3,7 +3,7 @@ hidden: true
3
3
  fields:
4
4
  object_name:
5
5
  type: text
6
- change_date:
6
+ change_data:
7
7
  type: object
8
8
  blackbox: true
9
9
  change_time:
@@ -38,7 +38,9 @@ fields:
38
38
  # omit: true
39
39
  # hidden: true
40
40
  label: Visible
41
+ is_wide: false
41
42
  sort_no: 150
43
+ defaultValue: true
42
44
  'on':
43
45
  type: lookup
44
46
  label: 'On'
@@ -137,6 +139,11 @@ fields:
137
139
  visible_on: "{{global.mode ==='read' ? true : false}}"
138
140
  disabled: true
139
141
  sort_no: 500
142
+ description:
143
+ label: Description
144
+ type: textarea
145
+ is_wide: true
146
+ sort_no: 450
140
147
  form:
141
148
  initialValues: !!js/function |
142
149
  function(){
@@ -25,8 +25,6 @@ fields:
25
25
  label: Label
26
26
  is_name: true
27
27
  sort_no: 120
28
- amis:
29
- disabledOn: "${is_system == true}"
30
28
  _name:
31
29
  type: text
32
30
  label: Field Name
@@ -364,8 +362,20 @@ fields:
364
362
  sort_no: 220
365
363
  amis:
366
364
  disabledOn: "${is_system == true}"
365
+ filters:
366
+ label: Lookup Relationship Filters Condition
367
+ type: code
368
+ is_wide: true
369
+ hidden: false
370
+ readonly: false
371
+ sort_no: 447
372
+ group: Advanced
373
+ visible_on: "{{(['lookup', 'master_detail'].indexOf(formData.type) > -1 ? true: false) && !!formData.reference_to}}"
374
+ 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
375
+ amis:
376
+ disabledOn: "${is_system == true}"
367
377
  filtersFunction:
368
- label: filters Function
378
+ label: Lookup Relationship Filters Function
369
379
  type: code
370
380
  language: javascript
371
381
  is_wide: true
@@ -525,7 +535,6 @@ fields:
525
535
  sort_no: 280
526
536
  amis:
527
537
  enableDialog: false
528
- disabledOn: "${is_system == true}"
529
538
  auto_fill_mapping.$:
530
539
  label: Auto Fill Mapping
531
540
  blackbox: true
@@ -571,7 +580,7 @@ fields:
571
580
  };
572
581
  var currentFilter = [];
573
582
  var referenceObject = BuilderAmisObject && BuilderAmisObject.AmisLib && BuilderAmisObject.AmisLib.getUISchemaSync(values.reference_to);
574
- var fromField = referenceObject && referenceObject.fields[values.auto_fill_mapping__from];
583
+ var fromField = referenceObject && referenceObject.fields[values.from];
575
584
 
576
585
  if (fromField && fromField.data_type) {
577
586
  currentFilter.push(['type', 'in', fieldFilters[fromField.data_type] || fromField.data_type.split()]);
@@ -936,6 +945,9 @@ fields:
936
945
  type: boolean
937
946
  label: Enable Enhanced Lookup
938
947
  hidden: true # 这里不可以用 visible_on: "{{false}}",否则在界面上新建字段时会被默认设置为false
948
+ is_customize:
949
+ type: boolean
950
+ readonly: true
939
951
  paging:
940
952
  enabled: false
941
953
  list_views:
@@ -951,6 +963,7 @@ list_views:
951
963
  - hidden
952
964
  - readonly
953
965
  - is_system
966
+ - is_customize
954
967
  sort:
955
968
  - field_name: sort_no
956
969
  order: asc
@@ -968,6 +981,7 @@ list_views:
968
981
  - hidden
969
982
  - readonly
970
983
  - is_system
984
+ - is_customize
971
985
  label: 自定义
972
986
  filters:
973
987
  - ["is_system","<>",true]
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Author: baozhoutaon@hotoa.com
3
+ * @Date: 2022-03-29 20:33:44
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2024-03-21 10:45:57
6
+ * @Description:
7
+ */
8
+ module.exports = {
9
+ resetVisible: function (object_name, record_id, permission, data) {
10
+ if(Meteor.settings.public.enable_saas){
11
+ return false;
12
+ }
13
+ var record = data && data.record;
14
+ return record && record.is_system && record.is_customize && record.created;
15
+ }
16
+ }
@@ -0,0 +1,79 @@
1
+ name: reset
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "重置",
9
+ "id": "u:delete_object",
10
+ "onEvent": {
11
+ "click": {
12
+ "actions": [
13
+ {
14
+ "actionType": "dialog",
15
+ "dialog": {
16
+ "type": "dialog",
17
+ "title": "重置对象: ${record.label}",
18
+ "body": [
19
+ {
20
+ "type": "tpl",
21
+ "tpl": "<div>\n<div style=\"text-align: left;\">重置一个自定义对象进行以下操作:</div>\n<ul>\n<li style=\"text-align: left;\">删除自定义的对象</li>\n<li style=\"text-align: left;\">删除自定义对象的字段</li>\n</ul>\n</div>",
22
+ "inline": true,
23
+ "id": "u:6d0819fc0bda"
24
+ }
25
+ ],
26
+ "id": "u:b5c0f98dc113",
27
+ "closeOnEsc": false,
28
+ "closeOnOutside": false,
29
+ "showCloseButton": true,
30
+ "data": {
31
+ "&": "$$",
32
+ "recordId": "${recordId}"
33
+ },
34
+ "onEvent": {
35
+ "confirm": {
36
+ "weight": 0,
37
+ "actions": [
38
+ {
39
+ "componentId": "",
40
+ "args": {
41
+ "api": {
42
+ "url": "/service/api/~database-objects/reset",
43
+ "method": "post",
44
+ "data": {
45
+ "objectName": "${record.name}"
46
+ }
47
+ },
48
+ "messages": {}
49
+ },
50
+ "actionType": "ajax"
51
+ },
52
+ {
53
+ "actionType": "custom",
54
+ "script": "window.location.reload();"
55
+ }
56
+ ]
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ],
62
+ "weight": 0
63
+ }
64
+ }
65
+ }
66
+ ],
67
+ "regions": [
68
+ "body"
69
+ ],
70
+ "data": {
71
+ },
72
+ "bodyClassName": "p-0",
73
+ "id": "u:46d1821365fc"
74
+ }
75
+ is_enable: true
76
+ label: 重置
77
+ 'on': record_only_more
78
+ type: amis_button
79
+ visible: true
@@ -284,7 +284,7 @@ function getObjectFromDB(objectName) {
284
284
 
285
285
  function reloadObject(changeLog){
286
286
  var objectName = changeLog.object_name;
287
- var data = changeLog.change_date;
287
+ var data = changeLog.change_data;
288
288
  const objectRecord = Creator.getCollection("objects").findOne({
289
289
  name: objectName
290
290
  })
@@ -298,7 +298,7 @@ function reloadObject(changeLog){
298
298
  fields: [],
299
299
  actions: []
300
300
  }
301
- if(!objectRecord && objectDataSourceName){
301
+ if((!objectRecord || objectRecord.is_system == true) && objectDataSourceName){
302
302
 
303
303
  switch (data.type) {
304
304
  case 'field':
@@ -383,14 +383,14 @@ function triggerReloadObject(objectName, type, value, event){
383
383
  const objectRecord = Creator.getCollection("objects").findOne({
384
384
  name: objectName
385
385
  })
386
- if(objectRecord){
386
+ if(objectRecord && objectRecord.is_system != true){
387
387
  //TODO 待支持动态加载related_list后, 删除此行代码
388
388
  // console.log(`triggerReloadObject===>`, objectName)
389
389
  Creator.getCollection("objects").update({name: objectName}, {$set: {reload_time: new Date()}})
390
390
  }else{
391
391
  Creator.getCollection("_object_reload_logs").insert({
392
392
  object_name: objectName,
393
- change_date: {
393
+ change_data: {
394
394
  type: type,
395
395
  event: event,
396
396
  value: value
@@ -443,6 +443,9 @@ fields:
443
443
  extend:
444
444
  type: text
445
445
  hidden: true
446
+ is_customize:
447
+ type: boolean
448
+ readonly: true
446
449
  paging:
447
450
  enabled: false
448
451
  relatedList:
@@ -490,6 +493,7 @@ list_views:
490
493
  - in_development
491
494
  - is_enable
492
495
  - is_system
496
+ - is_customize
493
497
  label: All
494
498
  filter_scope: space
495
499
  extra_columns:
@@ -505,9 +509,10 @@ list_views:
505
509
  - in_development
506
510
  - is_enable
507
511
  - is_system
512
+ - is_customize
508
513
  label: Customize
509
514
  filters:
510
- - ["is_system","<>",true]
515
+ - ["is_customize","<>",true]
511
516
  filter_scope: space
512
517
  extra_columns:
513
518
  - datasource
@@ -522,6 +527,7 @@ list_views:
522
527
  - in_development
523
528
  - is_enable
524
529
  - is_system
530
+ - is_customize
525
531
  label: System
526
532
  filters:
527
533
  - ["is_system","=",true]
@@ -39,33 +39,43 @@
39
39
  "body": [
40
40
  {
41
41
  "type": "steedos-input-table",
42
- "inlineEditMode": true,
42
+ "enableDialog": false,
43
43
  "fields": [
44
44
  {
45
45
  "name": "group_name",
46
46
  "label": "名称",
47
47
  "type": "text",
48
+ "amis": {
49
+ "disabledOn": "${is_default || is_hidden}"
50
+ },
48
51
  "id": "u:31952daa443c"
49
52
  },
50
53
  {
51
54
  "name": "visible_on",
52
55
  "label": "显示条件",
53
56
  "type": "text",
57
+ "amis": {
58
+ "disabledOn": "${is_default || is_hidden}"
59
+ },
54
60
  "id": "u:8d7551abcd28",
55
61
  "value": null
56
62
  },
57
63
  {
58
64
  "name": "collapsed",
59
65
  "label": "默认折叠",
66
+ "amis": {
67
+ "disabledOn": "${is_default || is_hidden}"
68
+ },
60
69
  "type": "boolean"
61
70
  }
62
71
  ],
63
72
  "columns": [
64
73
  {
65
- "name": "group_name",
66
- "inlineEditMode": false
74
+ "name": "group_name"
75
+ },
76
+ {
77
+ "name": "visible_on"
67
78
  },
68
- "visible_on",
69
79
  {
70
80
  "name": "collapsed",
71
81
  "width": 50
@@ -76,7 +86,6 @@
76
86
  "editable": true,
77
87
  "removable": true,
78
88
  "draggable": false,
79
- "showIndex": false,
80
89
  "id": "u:776ec89804c0",
81
90
  "label": ""
82
91
  }
@@ -88,7 +97,7 @@
88
97
  "actions": [
89
98
  {
90
99
  "actionType": "custom",
91
- "script": "//整理分组数据\nlet setting_groups = _.cloneDeep(event.data.groups);\nif (!_.find(setting_groups, { is_default: true })) {\n setting_groups.unshift({\n \"id\": \"未分组\",\n \"group_name\": \"未分组\",\n \"visible_on\": \"\",\n \"is_default\": true\n })\n}\nif (!_.find(setting_groups, { is_hidden: true })) {\n setting_groups.push({\n id: \"隐藏\",\n group_name: \"隐藏\",\n visible_on: \"\",\n is_hidden: true\n });\n}\nsetting_groups.forEach(function (group) {\n if (group.is_hidden) {\n group.group_name = \"隐藏\";\n group.visible_on = \"\";\n }\n if (group.is_default) {\n group.group_name = \"未分组\";\n group.visible_on = \"\";\n }\n if (!group.id) {\n group.id = group.group_name;\n }\n if (!group.visible_on) {\n group.visible_on = \"\"\n }\n})\n\n//整理字段与分组关系的数据\nlet fieldForGroup = {};\nlet oldGroup = _.cloneDeep(event.data.fieldForGroup);\nsetting_groups.forEach(function (group) {\n if (_.has(oldGroup, group.id)) {\n fieldForGroup[group.id] = oldGroup[group.id];\n oldGroup = _.omit(oldGroup, group.id);\n } else {\n fieldForGroup[group.id] = [];\n }\n})\nif (oldGroup && !_.isEmpty(oldGroup)) {\n _.forEach(oldGroup, function (value, key) {\n fieldForGroup[\"未分组\"] = _.unionBy(fieldForGroup[\"未分组\"], value);\n });\n}\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroup = fieldForGroup[\"未分组\"];\nconst hiddenGroup = fieldForGroup[\"隐藏\"];\ndelete fieldForGroup[\"未分组\"];\ndelete fieldForGroup[\"隐藏\"];\nfieldForGroup = _.merge({ \"未分组\": defaultGroup }, fieldForGroup, { \"隐藏\": hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\nsetting_groups = _.sortBy(setting_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\n\ndoAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n groups: setting_groups\n }\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field: fieldForGroup }\n }\n});"
100
+ "script": "///整理分组数据\nconst defaultGroupName = \"未分组\";\nconst hiddenGroupName = \"隐藏\";\nlet setting_groups = _.cloneDeep(event.data.groups);\nif (!_.find(setting_groups, { is_default: true })) {\n setting_groups.unshift({\n \"id\": defaultGroupName,\n \"group_name\": defaultGroupName,\n \"visible_on\": \"\",\n \"is_default\": true\n })\n}\nif (!_.find(setting_groups, { is_hidden: true })) {\n setting_groups.push({\n id: hiddenGroupName,\n group_name: hiddenGroupName,\n visible_on: \"\",\n is_hidden: true\n });\n}\nsetting_groups.forEach(function (group) {\n if (group.is_hidden) {\n group.group_name = hiddenGroupName;\n group.visible_on = \"\";\n }\n if (group.is_default) {\n group.group_name = defaultGroupName;\n group.visible_on = \"\";\n }\n if (!group.id) {\n group.id = group.group_name;\n }\n if (!group.visible_on) {\n group.visible_on = \"\"\n }\n})\n\n//整理字段与分组关系的数据\nlet fieldForGroup = {};\nlet oldGroup = _.cloneDeep(event.data.fieldForGroup);\nsetting_groups.forEach(function (group) {\n if (_.has(oldGroup, group.id)) {\n fieldForGroup[group.id] = oldGroup[group.id];\n oldGroup = _.omit(oldGroup, group.id);\n } else {\n fieldForGroup[group.id] = [];\n }\n})\nif (oldGroup && !_.isEmpty(oldGroup)) {\n _.forEach(oldGroup, function (value, key) {\n fieldForGroup[defaultGroupName] = _.unionBy(fieldForGroup[defaultGroupName], value);\n });\n}\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroup = fieldForGroup[defaultGroupName];\nconst hiddenGroup = fieldForGroup[hiddenGroupName];\ndelete fieldForGroup[defaultGroupName];\ndelete fieldForGroup[hiddenGroupName];\nfieldForGroup = _.merge({ [defaultGroupName]: defaultGroup }, fieldForGroup, { [hiddenGroupName]: hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\nsetting_groups = _.sortBy(setting_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\n\ndoAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n groups: setting_groups\n }\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field: fieldForGroup }\n }\n});"
92
101
  }
93
102
  ]
94
103
  }
@@ -312,7 +321,7 @@
312
321
  "headers": {
313
322
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
314
323
  },
315
- "requestAdaptor": "var graphqlOrder = \"\";\n//先修改字段,使系统对象自行自定义\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\n_.forEach(api.data.design_field, function (items, key) {\n let group = key;\n if (key == \"未分组\" || key == \"隐藏\") {\n group = null;\n }\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n //如果是在隐藏分组里的字段,就给visible_on属性赋予{{false}};如果不在隐藏分组里,就判断来自数据库内的visible_on属性是不是{{false}},是就清除,不是就保持不变\n const visible_on = key == \"隐藏\" ? \"{{false}}\" : (field.attr_visible_on == \"{{false}}\" ? \"{{true}}\" : field.attr_visible_on);\n let docJson = {\n sort_no: index * 10,\n group, visible_on\n }\n if (field.id == field._id && field.is_system) {\n docJson = {\n object: api.data.$self.designObjectName,\n type: field.type,\n _name: field._name,\n label: field.label,\n sort_no: index * 10,\n group,\n visible_on,\n is_system: field.is_system\n }\n }\n if (key != \"隐藏\") {\n docJson.hidden = false;\n }\n let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify(docJson)) + '){_id}\\n';\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\n//根据groups,修改对象的字段分组field_groups\nvar field_groups = _.cloneDeep(api.data.groups);\n_.remove(field_groups, { is_default: true });\n_.remove(field_groups, { is_hidden: true });\nfield_groups = field_groups.map(function (group) {\n return _.omit(group, 'id');\n})\nconst keys = _.keys(api.data.design_field);\nfield_groups = _.sortBy(field_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\nconst groupOrder = 'upsert0:objects__upsert(id:\"' + api.data.$self.designObjectId + '\" , doc:' + JSON.stringify(JSON.stringify({ field_groups, name: api.data.$self.designObjectName })) + ') {_id}';\ngraphqlOrder += groupOrder;\n\n\ngraphqlOrder = 'mutation {' + graphqlOrder + '}';\nreturn {\n ...api,\n data: {\n query: graphqlOrder\n }\n}",
324
+ "requestAdaptor": "var graphqlOrder = \"\";\nvar field_groups = _.cloneDeep(api.data.groups);\n//先修改字段,使系统对象自行自定义\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\nconst defaultGroupName = _.find(field_groups, { 'is_default': true })?.name || \"未分组\";\nconst hiddenGroupName = _.find(field_groups, { 'is_hidden': true })?.name || \"隐藏\";\n_.forEach(api.data.design_field, function (items, key) {\n let group = key;\n if (key == defaultGroupName || key == hiddenGroupName) {\n group = null;\n }\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n //如果是在隐藏分组里的字段,就给visible_on属性赋予{{false}};如果不在隐藏分组里,就判断来自数据库内的visible_on属性是不是{{false}},是就清除,不是就保持不变\n const visible_on = key == hiddenGroupName ? \"{{false}}\" : (field.attr_visible_on == \"{{false}}\" ? \"{{true}}\" : field.attr_visible_on);\n let docJson = {\n sort_no: index * 10,\n group, visible_on\n }\n if (field.id == field._id && field.is_system) {\n docJson = {\n object: api.data.$self.designObjectName,\n type: field.type,\n _name: field._name,\n label: field.label,\n sort_no: index * 10,\n group,\n visible_on,\n is_system: field.is_system\n }\n }\n if (key != hiddenGroupName) {\n docJson.hidden = false;\n }\n let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify(docJson)) + '){_id}\\n';\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\n//根据groups,修改对象的字段分组field_groups\n_.remove(field_groups, { is_default: true });\n_.remove(field_groups, { is_hidden: true });\nfield_groups = field_groups.map(function (group) {\n return _.omit(group, 'id');\n})\nconst keys = _.keys(api.data.design_field);\nfield_groups = _.sortBy(field_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\nconst groupOrder = 'upsert0:objects__upsert(id:\"' + api.data.$self.designObjectId + '\" , doc:' + JSON.stringify(JSON.stringify({ field_groups, name: api.data.$self.designObjectName })) + ') {_id}';\ngraphqlOrder += groupOrder;\n\n\ngraphqlOrder = 'mutation {' + graphqlOrder + '}';\nreturn {\n ...api,\n data: {\n query: graphqlOrder\n }\n}",
316
325
  "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[\n 0\n ].message) : payload.errors[\n 0\n ].message;\n}\nreturn payload;",
317
326
  "messages": {},
318
327
  "data": {
@@ -358,7 +367,7 @@
358
367
  },
359
368
  "messages": {},
360
369
  "requestAdaptor": "",
361
- "adaptor": "//筛选出可编辑的字段\r\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\r\n//将group为空的字段分为未分组的组中,将系统字段的_id改为对象名.字段名\r\noldFields = _.map(oldFields, function (obj) {\r\n obj.originId = obj._id;\r\n if (obj.hidden || obj.visible_on == \"{{false}}\") {\r\n obj.group = \"隐藏\";\r\n }else if (obj.group === null) {\r\n obj.group = \"未分组\";\r\n }\r\n if (obj.is_system) {\r\n obj._id = api.data.designObjectName + \".\" + obj._name;\r\n }\r\n return obj;\r\n});\r\n\r\n//整合出字段的属性集合\r\nconst fields = oldFields.map((field) => {\r\n return {\r\n \"id\": field._id,//用与steedos-board组件的关系分辨\r\n \"_name\": field._name,\r\n \"label\": field.label,\r\n \"_id\": field.originId,//用于打开steedos-objectform\r\n \"columnSpan\": field.is_wide ? 2 : 1,\r\n \"is_system\": field.is_system,\r\n \"type\": field.type,\r\n \"attr_visible_on\": field.visible_on\r\n }\r\n})\r\n\r\n//从字段的group属性中,整合出字段分组的属性集合\r\nlet field_groups = _.map(_.uniqBy(oldFields, \"group\"), function (obj) {\r\n return {\r\n \"id\": obj.group,\r\n \"group_name\": obj.group,\r\n \"visible_on\": \"\"\r\n };\r\n});\r\n\r\n//合并对象上的field_groups与字段上的group\r\nlet groups = _.unionBy(api.data.field_groups, field_groups, 'id');\r\n\r\n//判断是否第一次调用接口,不是的话(说明是触发了datachange事件),返回fields与fieldUpdateData\r\nif (api.data.dataInitialed) {\r\n const eventData = api.data.eventData;\r\n let fieldUpdateData = \"\";\r\n const fieldForGroup = api.data.fieldForGroup;\r\n let fieldForGroupLength = 0;\r\n _.forIn(fieldForGroup, function (value, key) {\r\n fieldForGroupLength += value.length;\r\n });\r\n if (fieldForGroupLength < fields.length) {\r\n fieldUpdateData = {\r\n type: \"insert\",\r\n id: eventData.result.data.recordId\r\n }\r\n } else if (fieldForGroupLength > fields.length) {\r\n fieldUpdateData = {\r\n type: \"delete\",\r\n id: eventData._id\r\n }\r\n }\r\n return payload = {\r\n data: {\r\n fields,\r\n fieldUpdateData\r\n }\r\n }\r\n}\r\n\r\n//整合字段与分组的关系\r\nconst oldFieldsInGroups = _.groupBy(oldFields, \"group\");\r\nlet fieldForGroup = _.mapValues(_.groupBy(groups, \"id\"), function (group,key) {\r\n if (oldFieldsInGroups[key]) {\r\n return _.map(oldFieldsInGroups[key], function (obj) {\r\n return obj._id;\r\n });\r\n } else {\r\n return [];\r\n }\r\n});\r\n\r\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\r\nconst defaultGroup = fieldForGroup[\"未分组\"];\r\nconst hiddenGroup = fieldForGroup[\"隐藏\"];\r\ndelete fieldForGroup[\"未分组\"];\r\ndelete fieldForGroup[\"隐藏\"];\r\nfieldForGroup = _.merge({ \"未分组\": defaultGroup }, fieldForGroup, { \"隐藏\": hiddenGroup });\r\n\r\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\r\nconst keys = _.keys(fieldForGroup);\r\ngroups = _.sortBy(groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\r\n\r\nreturn payload = {\r\n data: {\r\n fields,\r\n groups,\r\n fieldForGroup,\r\n dataInitialed: true\r\n }\r\n};",
370
+ "adaptor": "//筛选出可编辑的字段\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\n//将group为空的字段分为未分组的组中,将系统字段的_id改为对象名.字段名\noldFields = _.map(oldFields, function (obj) {\n obj.originId = obj._id;\n if (obj.hidden || obj.visible_on == \"{{false}}\") {\n obj.group = \"隐藏\";\n }else if (obj.group === null) {\n obj.group = \"未分组\";\n }\n if (obj.is_system) {\n obj._id = api.data.designObjectName + \".\" + obj._name;\n }\n return obj;\n});\n\n//整合出字段的属性集合\nconst fields = oldFields.map((field) => {\n return {\n \"id\": field._id,//用与steedos-board组件的关系分辨\n \"_name\": field._name,\n \"label\": field.label,\n \"_id\": field.originId,//用于打开steedos-objectform\n \"columnSpan\": field.is_wide ? 2 : 1,\n \"is_system\": field.is_system,\n \"type\": field.type,\n \"attr_visible_on\": field.visible_on\n }\n})\n\n//从字段的group属性中,整合出字段分组的属性集合\nlet field_groups = _.map(_.uniqBy(oldFields, \"group\"), function (obj) {\n return {\n \"id\": obj.group,\n \"group_name\": obj.group,\n \"visible_on\": \"\"\n };\n});\n\n//合并对象上的field_groups与字段上的group\nlet groups = _.unionBy(api.data.field_groups, field_groups, 'id');\n\n//判断是否第一次调用接口,不是的话(说明是触发了datachange事件),返回fields与fieldUpdateData;目前新增与删除都不支持\nif (api.data.dataInitialed) {\n const eventData = api.data.eventData;\n let fieldUpdateData = \"\";\n const fieldForGroup = api.data.fieldForGroup;\n let fieldForGroupLength = 0;\n _.forIn(fieldForGroup, function (value, key) {\n fieldForGroupLength += value.length;\n });\n if (fieldForGroupLength < fields.length) {\n fieldUpdateData = {\n type: \"insert\",\n id: eventData.result.data.recordId\n }\n } else if (fieldForGroupLength > fields.length) {\n fieldUpdateData = {\n type: \"delete\",\n id: eventData._id\n }\n }\n return payload = {\n data: {\n fields,\n fieldUpdateData,\n \n }\n }\n}\n\n//整合字段与分组的关系\nconst oldFieldsInGroups = _.groupBy(oldFields, \"group\");\nlet fieldForGroup = _.mapValues(_.groupBy(groups, \"id\"), function (group,key) {\n if (oldFieldsInGroups[key]) {\n return _.map(oldFieldsInGroups[key], function (obj) {\n return obj._id;\n });\n } else {\n return [];\n }\n});\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroupName = _.find(groups, { 'is_default': true })?.name || \"未分组\";\nconst hiddenGroupName = _.find(groups, { 'is_hidden': true })?.name || \"隐藏\";\nconst defaultGroup = fieldForGroup[defaultGroupName];\nconst hiddenGroup = fieldForGroup[hiddenGroupName];\ndelete fieldForGroup[defaultGroupName];\ndelete fieldForGroup[hiddenGroupName];\nfieldForGroup = _.merge({ [defaultGroupName]: defaultGroup }, fieldForGroup, { [hiddenGroupName]: hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\ngroups = _.sortBy(groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\n\nreturn payload = {\n data: {\n fields,\n groups,\n fieldForGroup,\n dataInitialed: true\n }\n};",
362
371
  "sendOn": "!!this.designObjectId"
363
372
  },
364
373
  "messages": {},
@@ -367,7 +376,7 @@
367
376
  "actions": [
368
377
  {
369
378
  "actionType": "custom",
370
- "script": "\nconst fieldForGroup = context.props.data.fieldForGroup;\nconst fieldUpdateData = event.data.fieldUpdateData;\nif (fieldUpdateData && fieldUpdateData.type == \"delete\") {\n _.forIn(fieldForGroup, function (group, group_name) {\n _.remove(group, function (field) {\n return field === fieldUpdateData.id;\n })\n });\n} else if (fieldUpdateData && fieldUpdateData.type == \"insert\") {\n fieldForGroup[\"未分组\"].push(fieldUpdateData.id);\n}\n// doAction({\n// actionType: 'setValue',\n// componentId: \"service_field_design\",\n// args: {\n// value: { fieldForGroup }\n// }\n// });\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field:fieldForGroup }\n }\n});\n\n",
379
+ "script": "//新增或删除时才会触发,目前暂不支持\nconst fieldForGroup = context.props.data.fieldForGroup;\nconst fieldUpdateData = event.data.fieldUpdateData;\nif (fieldUpdateData && fieldUpdateData.type == \"delete\") {\n _.forIn(fieldForGroup, function (group, group_name) {\n _.remove(group, function (field) {\n return field === fieldUpdateData.id;\n })\n });\n} else if (fieldUpdateData && fieldUpdateData.type == \"insert\") {\n fieldForGroup[\"未分组\"].push(fieldUpdateData.id);\n}\n// doAction({\n// actionType: 'setValue',\n// componentId: \"service_field_design\",\n// args: {\n// value: { fieldForGroup }\n// }\n// });\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field:fieldForGroup }\n }\n});\n\n",
371
380
  "expression": "${event.data.fieldUpdateData}"
372
381
  }
373
382
  ]
@@ -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,10 +2,15 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2023-04-21 16:25:07
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-05-18 09:26:18
5
+ * @LastEditTime: 2024-03-21 11:58:43
6
6
  * @Description:
7
7
  */
8
8
  var packageServiceName = '~database-objects'
9
+
10
+ const { getObject } = require('@steedos/objectql');
11
+
12
+ const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
13
+
9
14
  function isPatternTrigger(data){
10
15
  const {listenTo} = data;
11
16
  if(listenTo === '*'){
@@ -36,7 +41,19 @@ module.exports = {
36
41
  * Actions
37
42
  */
38
43
  actions: {
39
-
44
+ resetObject: {
45
+ rest: {
46
+ method: "POST",
47
+ path: "/reset"
48
+ },
49
+ async handler(ctx) {
50
+ const { objectName } = ctx.params;
51
+ await getObject('objects').directDelete({filters: ['name','=', objectName]});
52
+ await getObject('object_fields').directDelete({filters: ['object','=', objectName]});
53
+ await sleep(2 * 1000)
54
+ return true;
55
+ }
56
+ }
40
57
  },
41
58
 
42
59
  /**
@@ -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-20 16:00:17
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,21 @@ 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
53
 
60
- let objectName = filters.object;
61
- if(!objectName && filters._id && filters._id.indexOf(".") > -1){
62
- objectName = filters._id.split('.')[0];
63
- }
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"
59
+ // }
60
+ // })
64
61
 
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;
62
+ _.each(this.data.values, (item)=>{
63
+ if(item.visible != false){
64
+ item.visible = true
79
65
  }
80
- }
66
+ })
67
+
81
68
  },
82
69
  afterCount: async function(){
83
70
  delete this.query.fields;
@@ -95,6 +82,15 @@ module.exports = {
95
82
  }
96
83
  }
97
84
  }
85
+
86
+ if(this.data.values){
87
+ if(this.data.values.visibleOn){
88
+ this.data.values.visible_type = "expression"
89
+ }else if(this.data.values.visible === true){
90
+ this.data.values.visible_type = "static"
91
+ }
92
+ }
93
+
98
94
  },
99
95
  afterDelete: async function(){
100
96
  await sleep(1000 * 2);
@@ -217,6 +217,12 @@ const initSummaryDoc = async (doc) => {
217
217
 
218
218
  module.exports = {
219
219
  afterFind: async function(){
220
+
221
+
222
+ _.each(this.data.values, (item)=>{
223
+ item.is_customize = true
224
+ })
225
+
220
226
  let filters = InternalData.parserFilters(this.query.filters);
221
227
  let objectName = filters.object;
222
228
  if(!objectName && filters._id && filters._id.indexOf(".") > -1){
@@ -243,7 +249,12 @@ module.exports = {
243
249
  if(obj){
244
250
  this.data.values = _.map(this.data.values, (item)=>{
245
251
  if(item.is_system){
246
- return Object.assign(item, _.find(obj.fields, (field)=>{return field.name === item.name}))
252
+ const mField = _.find(obj.fields, (field)=>{return field.name === item.name})
253
+ if(mField){
254
+ return Object.assign(item, mField, mField?.override || {})
255
+ }else{
256
+ return item;
257
+ }
247
258
  }else{
248
259
  return item;
249
260
  }
@@ -262,6 +273,15 @@ module.exports = {
262
273
  if(query.fields && _.isArray(query.fields) && !_.include(query.fields, 'type')){
263
274
  query.fields.push('type')
264
275
  }
276
+
277
+
278
+ let filters = InternalData.parserFilters(this.query.filters);
279
+ if(filters._id && _.isString(filters._id) && filters._id.indexOf(".") > -1){
280
+ const [objectName, fieldName] = filters._id.split('.');
281
+ query.filters = [['object', '=', objectName], ['name', '=', fieldName]]
282
+ }
283
+
284
+
265
285
  },
266
286
  beforeAggregate: async function(){
267
287
  const { query } = this;
@@ -300,10 +320,13 @@ module.exports = {
300
320
  this.data.values = field;
301
321
  }
302
322
  }
323
+ }else{
324
+ this.data.values.is_customize = true
303
325
  }
304
326
  },
305
327
  beforeInsert: async function () {
306
328
  let doc = this.doc;
329
+ delete doc.is_customize
307
330
  validateDoc(doc);
308
331
  await checkFormulaInfiniteLoop(doc);
309
332
  await checkMasterDetailTypeField(doc);
@@ -328,6 +351,7 @@ module.exports = {
328
351
  },
329
352
  beforeUpdate: async function () {
330
353
  let { doc, object_name, id} = this;
354
+ delete doc.is_customize
331
355
  validateDoc(doc);
332
356
  // const dbDoc = await objectql.getObject(object_name).findOne(id)
333
357
  const dbDoc = objectql.wrapAsync(async function(){
@@ -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
@@ -17,15 +17,15 @@ module.exports = {
17
17
  afterFind: async function(){
18
18
  let userId = this.userId
19
19
  let spaceId = this.spaceId;
20
- for (const doc of this.data.values) {
21
- doc.fields = Object.assign({}, doc.fields, await InternalData.getDefaultSysFields(doc.name, userId)) ;
22
- }
23
- // this.data.values = this.data.values.concat(await InternalData.findObjects(userId, this.query.filters));
20
+
21
+ _.each(this.data.values, (item)=>{
22
+ item.is_customize = true
23
+ })
24
24
 
25
25
  this.data.values = this.data.values.concat(await InternalData.getObjects(userId));
26
26
 
27
27
  this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
28
-
28
+
29
29
  _.each(this.data.values, function(value){
30
30
  if(value){
31
31
  delete value.actions;
@@ -44,6 +44,8 @@ module.exports = {
44
44
  afterFindOne: async function(){
45
45
  if(_.isEmpty(this.data.values)){
46
46
  this.data.values = await InternalData.getObject(this.id, this.userId);
47
+ }else{
48
+ this.data.values.is_customize = true
47
49
  }
48
50
  if(this.data.values){
49
51
  delete this.data.values.actions;
@@ -104,8 +106,13 @@ module.exports = {
104
106
  // })
105
107
  await sleep(1000 * 2)
106
108
  },
109
+ beforeInsert: async function () {
110
+ let doc = this.doc;
111
+ delete doc.is_customize
112
+ },
107
113
  beforeUpdate: async function () {
108
114
  const { doc, id, object_name } = this;
115
+ delete doc.is_customize
109
116
  // 如果用户修改了apiname,则校验 数据源必须一致为default数据源;且数据库中不能有新的apiname对应的表
110
117
  if (_.has(doc, 'name')) {
111
118
  const obj = this.getObject(object_name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.7.0-beta.1",
3
+ "version": "2.7.0-beta.11",
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.1",
16
- "@steedos/standard-objects": "2.7.0-beta.1"
15
+ "@steedos/metadata-core": "2.7.0-beta.11",
16
+ "@steedos/standard-objects": "2.7.0-beta.11"
17
17
  },
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "529efb7f06c4454d4351500c6e47bd7b7602f64d"
20
+ "gitHead": "3a99b902d0e03a0aa4cd169a77fc482795c01137"
21
21
  }
@@ -2,7 +2,7 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 1985-10-26 16:15:00
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-02-29 10:24:41
5
+ * @LastEditTime: 2024-03-20 14:30:13
6
6
  * @Description:
7
7
  */
8
8
  "use strict";
@@ -115,8 +115,7 @@ module.exports = {
115
115
  }
116
116
  }
117
117
  if(data.is_system){
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']);
118
+ data = _.pick(data, ['label', '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
119
  }
121
120
  return object.update(id, data, userSession)
122
121
  },