@steedos/standard-object-database 2.6.1-beta.6 → 2.6.1-beta.7

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 (26) hide show
  1. package/main/default/client/object_fields.client.js +39 -3
  2. package/main/default/objectTranslations/object_actions.en/object_actions.en.objectTranslation.yml +19 -0
  3. package/main/default/objectTranslations/object_actions.zh-CN/object_actions.zh-CN.objectTranslation.yml +19 -0
  4. package/main/default/objectTranslations/object_fields.en/object_fields.en.objectTranslation.yml +6 -0
  5. package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +6 -0
  6. package/main/default/objectTranslations/object_layouts.en/object_layouts.en.objectTranslation.yml +7 -0
  7. package/main/default/objectTranslations/object_layouts.zh-CN/object_layouts.zh-CN.objectTranslation.yml +7 -0
  8. package/main/default/objectTranslations/object_triggers.en/object_triggers.en.objectTranslation.yml +15 -0
  9. package/main/default/objectTranslations/object_triggers.zh-CN/object_triggers.zh-CN.objectTranslation.yml +15 -0
  10. package/main/default/objectTranslations/objects.en/objects.en.objectTranslation.yml +2 -0
  11. package/main/default/objectTranslations/objects.zh-CN/objects.zh-CN.objectTranslation.yml +2 -0
  12. package/main/default/objects/16.permission_tabs.observe.object.js +44 -0
  13. package/main/default/objects/object_actions.action.js +1 -1
  14. package/main/default/objects/object_actions.object.yml +47 -28
  15. package/main/default/objects/object_fields.object.yml +29 -1
  16. package/main/default/objects/object_layouts.object.yml +12 -0
  17. package/main/default/objects/object_listviews.action.js +1 -1
  18. package/main/default/objects/object_listviews.object.js +3 -3
  19. package/main/default/pages/object_fields.page.amis.json +42 -0
  20. package/main/default/pages/object_fields.page.yml +12 -0
  21. package/main/default/routes/amis_button_design.router.js +8 -1
  22. package/main/default/routes/amis_listview_design.router.js +7 -2
  23. package/main/default/services/object_fields.service.js +242 -0
  24. package/main/default/triggers/object_listviews.trigger.js +16 -1
  25. package/main/default/triggers/objects.trigger.js +36 -3
  26. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-08-05 14:17:44
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-06-09 14:42:12
4
+ * @LastEditors: liaodaxue
5
+ * @LastEditTime: 2023-07-24 13:57:51
6
6
  * @Description:
7
7
  */
8
8
  Steedos.ObjectFieldManager = {};
@@ -67,4 +67,40 @@ Steedos.ObjectFieldManager.getSummaryFiltersOperation = function(field_type) {
67
67
  operations.push(optionals.equal, optionals.unequal);
68
68
  }
69
69
  return operations;
70
- };
70
+ };
71
+
72
+ (function () {
73
+ try {
74
+ var styleCss = $(`<style>
75
+ .defaultValue_field div:first-child{
76
+ flex-grow: 1;
77
+ }
78
+ .defaultValue_field .defaultValue_field_formula{
79
+ // margin: 4px;
80
+ }
81
+ .defaultValue_field .defaultValue_field_formula .antd-Form-label{
82
+ visibility: hidden;
83
+ }
84
+
85
+ .defaultValue_field .defaultValue_field_formula_visible{
86
+ flex-grow: 1;
87
+ }
88
+ .defaultValue_field .defaultValue_field_formula_visible .antd-Form-label .antd-TplField{
89
+ visibility: visible;
90
+ }
91
+ .defaultValue_field .defaultValue_field_hidden{
92
+ display: none;
93
+ }
94
+ .defaultValue_field .defaultValue_field_formula_hidden{
95
+ flex-grow: 0;
96
+ }
97
+ .defaultValue_field .defaultValue_field_formula_hidden .antd-FormulaPicker-input{
98
+ display: none;
99
+ }
100
+
101
+ </style>`);
102
+ $("head").append(styleCss);
103
+ } catch (error) {
104
+ console.log(error);
105
+ }
106
+ })();
@@ -29,6 +29,25 @@ fields:
29
29
  label: 'On'
30
30
  help:
31
31
  description:
32
+ options:
33
+ - label: Display in the top right corner of the list
34
+ value: list
35
+ icon: contact_list
36
+ - label: Displayed in the top right corner of the record viewing page and in the drop-down menu for each item in the list view
37
+ value: record
38
+ icon: contact_list
39
+ - label: Displayed in the "More" dropdown menu in the upper right corner of the record viewing page, as well as in the dropdown menu for each item in the list view
40
+ value: record_more
41
+ icon: lead_list
42
+ - label: Display in the drop-down menu for each item in the list view
43
+ value: list_item
44
+ icon: action_list_component
45
+ - label: Displayed in the upper right corner of the record viewing page
46
+ value: record_only
47
+ icon: contract
48
+ - label: Displayed in the "More" drop-down menu in the upper right corner of the record viewing page
49
+ value: record_only_more
50
+ icon: lead_list
32
51
  type:
33
52
  label: Type
34
53
  options:
@@ -26,6 +26,25 @@ fields:
26
26
  label: 显示位置
27
27
  help:
28
28
  description:
29
+ options:
30
+ - label: 显示在列表右上角
31
+ value: list
32
+ icon: contact_list
33
+ - label: 显示在记录查看页右上角,以及列表视图中每项的下拉菜单中
34
+ value: record
35
+ icon: contact_list
36
+ - label: 显示在记录查看页右上角的“更多”下拉菜单中,以及列表视图中每项的下拉菜单中
37
+ value: record_more
38
+ icon: lead_list
39
+ - label: 显示在列表视图中每项的下拉菜单中
40
+ value: list_item
41
+ icon: action_list_component
42
+ - label: 显示在记录查看页右上角
43
+ value: record_only
44
+ icon: contract
45
+ - label: 显示在记录查看页右上角的“更多”下拉菜单中
46
+ value: record_only_more
47
+ icon: lead_list
29
48
  type:
30
49
  label: 类型
31
50
  options:
@@ -33,6 +33,8 @@ fields:
33
33
  value: html
34
34
  - label: Code
35
35
  value: code
36
+ - label: Markdown
37
+ value: markdown
36
38
  - label: Select
37
39
  value: select
38
40
  - label: Checkbox
@@ -325,6 +327,10 @@ fields:
325
327
  permission to create, edit, or delete child records. This setting is more
326
328
  restrictive than true, and is the default value.
327
329
  description:
330
+ amis:
331
+ label: Amis Attribute
332
+ help:
333
+ description:
328
334
  groups:
329
335
  external_data_source: External data source
330
336
  advanced: Advanced
@@ -30,6 +30,8 @@ fields:
30
30
  value: html
31
31
  - label: 代码
32
32
  value: code
33
+ - label: Markdown
34
+ value: markdown
33
35
  - label: 选择框
34
36
  value: select
35
37
  - label: 复选框
@@ -298,6 +300,10 @@ fields:
298
300
  help: >-
299
301
  设置主记录上创建、编辑或删除子记录所需的最低访问级别。此字段仅适用于·主表/子表·字段类型。勾选表示允许具有'读取'访问权限的用户创建、编辑或删除子记录。反之表示允许具有'读取/写入'访问权限的用户创建、编辑或删除子记录的权限。
300
302
  description:
303
+ amis:
304
+ label: Amis 属性
305
+ help:
306
+ description:
301
307
  groups:
302
308
  external_data_source: 外部数据源
303
309
  advanced: 高级
@@ -60,7 +60,14 @@ fields:
60
60
  listviews:
61
61
  all:
62
62
  label: All
63
+ groups:
64
+ general_information: General Information
65
+ buttons: Buttons
66
+ fields: Fields
67
+ related_lists: Related Lists
63
68
  actions:
69
+ createDefaultRecordView:
70
+ label: Create Default Page Layout
64
71
  customize:
65
72
  label: Customize
66
73
  CustomLabels:
@@ -106,7 +106,14 @@ fields:
106
106
  listviews:
107
107
  all:
108
108
  label: 所有
109
+ groups:
110
+ general_information: 基本信息
111
+ buttons: 按钮
112
+ fields: 字段
113
+ related_lists: 子表
109
114
  actions:
115
+ createDefaultRecordView:
116
+ label: 创建默认页面布局
110
117
  customize:
111
118
  label: 自定义
112
119
  CustomLabels:
@@ -14,6 +14,21 @@ fields:
14
14
  label: Execution Time Option
15
15
  help:
16
16
  description:
17
+ options:
18
+ - label: "Before adding a new record"
19
+ value: "beforeInsert"
20
+ - label: "After adding a new record"
21
+ value: "afterInsert"
22
+ - label: "Before modifying a record"
23
+ value: "beforeUpdate"
24
+ - label: "After modifying a record"
25
+ value: "afterUpdate"
26
+ - label: "Before deleting a record"
27
+ value: "beforeDelete"
28
+ - label: "After deleting a record"
29
+ value: "afterDelete"
30
+ - label: "Before checking the records"
31
+ value: "beforeFind"
17
32
  is_enable:
18
33
  label: Enable
19
34
  help:
@@ -14,6 +14,21 @@ fields:
14
14
  label: 运行时
15
15
  help:
16
16
  description:
17
+ options:
18
+ - label: "新增记录之前"
19
+ value: "beforeInsert"
20
+ - label: "新增记录之后"
21
+ value: "afterInsert"
22
+ - label: "修改记录之前"
23
+ value: "beforeUpdate"
24
+ - label: "修改记录之后"
25
+ value: "afterUpdate"
26
+ - label: "删除记录之前"
27
+ value: "beforeDelete"
28
+ - label: "删除记录之后"
29
+ value: "afterDelete"
30
+ - label: "查下记录之前"
31
+ value: "beforeFind"
17
32
  isEnabled:
18
33
  label: 已启用
19
34
  help:
@@ -212,6 +212,8 @@ actions:
212
212
  label: Preview
213
213
  copy_odata:
214
214
  label: Copy OData URL
215
+ createDefaultRecordView:
216
+ label: Create Default Page Layout
215
217
  CustomLabels:
216
218
  objects_field_datasource_defaultValue: Default data source
217
219
  objects_field_datasource_meteor: Meteor
@@ -209,6 +209,8 @@ actions:
209
209
  label: 预览
210
210
  copy_odata:
211
211
  label: 复制OData网址
212
+ createDefaultRecordView:
213
+ label: 创建默认页面布局
212
214
  CustomLabels:
213
215
  objects_field_datasource_defaultValue: 默认数据源
214
216
  objects_field_datasource_meteor: Meteor
@@ -0,0 +1,44 @@
1
+ /*
2
+ * @Author: 孙浩林 sunhaolin@steedos.com
3
+ * @Date: 2023-06-28 16:15:36
4
+ * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
+ * @LastEditTime: 2023-06-28 18:59:40
6
+ * @FilePath: /project-template/Users/sunhaolin/Documents/GitHub/steedos-platform-2.3/services/standard-object-database/main/default/objects/16.permission_tabs.observe.object.js
7
+ * @Description:
8
+ */
9
+ const objectql = require("@steedos/objectql");
10
+ const objectName = "permission_tabs";
11
+ const SERVICE_NAME = `~database-permission_tabs`;
12
+ Meteor.startup(function () {
13
+ var _change, _remove, inited = false;
14
+ _change = function (document) {
15
+ objectql.registerPermissionTabs.register(broker, SERVICE_NAME, document)
16
+ };
17
+ _remove = function (document) {
18
+ objectql.registerPermissionTabs.remove(broker, SERVICE_NAME, document)
19
+ };
20
+ Creator.getCollection(objectName).find({}, {
21
+ fields: {
22
+ created: 0,
23
+ created_by: 0,
24
+ modified: 0,
25
+ modified_by: 0
26
+ }
27
+ }).observe({
28
+ added: function (newDocument) {
29
+ if (inited) {
30
+ return _change(newDocument);
31
+ }
32
+ },
33
+ changed: function (newDocument, oldDocument) {
34
+ if (newDocument.name != oldDocument.name) {
35
+ _remove(oldDocument)
36
+ }
37
+ return _change(newDocument);
38
+ },
39
+ removed: function (oldDocument) {
40
+ return _remove(oldDocument);
41
+ }
42
+ });
43
+ inited = true;
44
+ });
@@ -7,7 +7,7 @@
7
7
  */
8
8
  module.exports = {
9
9
  showDesign: function (object_name, record_id) {
10
- document.location = Steedos.absoluteUrl(`/api/amisButtonDesign?id=${record_id}&object=${this.record.record.object}&assetUrls=${Builder.settings.assetUrls}`);
10
+ document.location = Steedos.absoluteUrl(`/api/amisButtonDesign?id=${record_id}&object=${this.record.record.object}&assetUrls=${Builder.settings.assetUrls}&locale=${Builder.settings.locale}`);
11
11
  },
12
12
  showDesignVisible: function (object_name, record_id, record_permissions) {
13
13
  var perms;
@@ -46,34 +46,53 @@ fields:
46
46
  required: true
47
47
  showIcon: false
48
48
  sort_no: 160
49
- optionsFunction: !<tag:yaml.org,2002:js/function> |-
50
- function () {
51
- return [{
52
- label: "显示在列表右上角",
53
- value: "list",
54
- icon: "contact_list"
55
- }, {
56
- label: "显示在记录查看页右上角,以及列表视图中每项的下拉菜单中",
57
- value: "record",
58
- icon: "contact_list"
59
- }, {
60
- label: "显示在记录查看页右上角的“更多”下拉菜单中,以及列表视图中每项的下拉菜单中",
61
- value: "record_more",
62
- icon: "lead_list"
63
- }, {
64
- label: "显示在列表视图中每项的下拉菜单中",
65
- value: "list_item",
66
- icon: "action_list_component"
67
- }, {
68
- label: "显示在记录查看页右上角",
69
- value: "record_only",
70
- icon: "contract"
71
- }, {
72
- label: "显示在记录查看页右上角的“更多”下拉菜单中",
73
- value: "record_only_more",
74
- icon: "lead_list"
75
- }];
76
- }
49
+ options:
50
+ - label: 显示在列表右上角
51
+ value: list
52
+ icon: contact_list
53
+ - label: 显示在记录查看页右上角,以及列表视图中每项的下拉菜单中
54
+ value: record
55
+ icon: contact_list
56
+ - label: 显示在记录查看页右上角的“更多”下拉菜单中,以及列表视图中每项的下拉菜单中
57
+ value: record_more
58
+ icon: lead_list
59
+ - label: 显示在列表视图中每项的下拉菜单中
60
+ value: list_item
61
+ icon: action_list_component
62
+ - label: 显示在记录查看页右上角
63
+ value: record_only
64
+ icon: contract
65
+ - label: 显示在记录查看页右上角的“更多”下拉菜单中
66
+ value: record_only_more
67
+ icon: lead_list
68
+ # optionsFunction: !<tag:yaml.org,2002:js/function> |-
69
+ # function () {
70
+ # return [{
71
+ # label: "显示在列表右上角",
72
+ # value: "list",
73
+ # icon: "contact_list"
74
+ # }, {
75
+ # label: "显示在记录查看页右上角,以及列表视图中每项的下拉菜单中",
76
+ # value: "record",
77
+ # icon: "contact_list"
78
+ # }, {
79
+ # label: "显示在记录查看页右上角的“更多”下拉菜单中,以及列表视图中每项的下拉菜单中",
80
+ # value: "record_more",
81
+ # icon: "lead_list"
82
+ # }, {
83
+ # label: "显示在列表视图中每项的下拉菜单中",
84
+ # value: "list_item",
85
+ # icon: "action_list_component"
86
+ # }, {
87
+ # label: "显示在记录查看页右上角",
88
+ # value: "record_only",
89
+ # icon: "contract"
90
+ # }, {
91
+ # label: "显示在记录查看页右上角的“更多”下拉菜单中",
92
+ # value: "record_only_more",
93
+ # icon: "lead_list"
94
+ # }];
95
+ # }
77
96
  type:
78
97
  type: select
79
98
  sort_no: 170
@@ -203,9 +203,37 @@ fields:
203
203
  sort_no: 155
204
204
  visible_on: "{{['code'].indexOf(formData.type) > -1 ? true: false}}"
205
205
  defaultValue:
206
- type: text
206
+ type: object
207
+ blackbox: true
207
208
  label: Default Value
208
209
  sort_no: 160
210
+ amis:
211
+ type: service
212
+ className:
213
+ antd-Form-item: true
214
+ antd-Form-item--normal: true
215
+ m-1: true
216
+ "md:border-b": global.mode === "read"
217
+ defaultValue_field: true
218
+ flex: true
219
+ schemaApi:
220
+ url: "${context.rootUrl}/service/api/object_fields/defaultValue/schema?object=${object}&name=${name}&options=${options}&type=${type}&reference_to=${reference_to}&multiple=${multiple}&filtersFunction=${filtersFunction}&reference_to_field=${reference_to_field}&mode=${global.mode}&_id=${_id}"
221
+ method: get
222
+ headers:
223
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
224
+ # sendOn: "!!this.type"
225
+ onEvent:
226
+ fetchSchemaInited:
227
+ weight: 0
228
+ actions:
229
+ - actionType: "setValue"
230
+ componentId: "service_detail_page"
231
+ args:
232
+ value:
233
+ defaultValue: "${event.data.body[0].value}"
234
+ expression: "global.mode ==='read' && event.data.body[0].value"
235
+
236
+
209
237
  group:
210
238
  type: text
211
239
  label: Group
@@ -10,19 +10,23 @@ fields:
10
10
  required: true
11
11
  label: Api Name
12
12
  is_wide: true
13
+ group: general_information
13
14
  label:
14
15
  type: text
15
16
  required: true
16
17
  label: Label
17
18
  is_wide: true
18
19
  is_name: true
20
+ group: general_information
19
21
  object_name:
20
22
  label: Object
21
23
  type: master_detail
22
24
  required: true
23
25
  reference_to: objects
24
26
  reference_to_field: name
27
+ is_wide: true
25
28
  write_requires_master_read: true
29
+ group: general_information
26
30
  type:
27
31
  type: select
28
32
  options:
@@ -42,6 +46,10 @@ fields:
42
46
  create: false
43
47
  reference_to: permission_set
44
48
  reference_to_field: name
49
+ is_wide: true
50
+ defaultValue:
51
+ - admin
52
+ - user
45
53
  optionsFunction: !<tag:yaml.org,2002:js/function> |-
46
54
  function () {
47
55
  var profiles = Creator.odata.query('permission_set', {$filter: "(type eq 'profile')"}, true);
@@ -54,12 +62,14 @@ fields:
54
62
  });
55
63
  return result;
56
64
  }
65
+ group: general_information
57
66
  buttons:
58
67
  type: grid
59
68
  blackbox: true
60
69
  is_wide: true
61
70
  depend_on:
62
71
  - object_name
72
+ group: buttons
63
73
  buttons.$.button_name:
64
74
  type: lookup
65
75
  reference_to: object_actions
@@ -83,6 +93,7 @@ fields:
83
93
  required: true
84
94
  depend_on:
85
95
  - object_name
96
+ group: fields
86
97
  fields.$:
87
98
  label: Field
88
99
  blackbox: true
@@ -116,6 +127,7 @@ fields:
116
127
  is_wide: true
117
128
  depend_on:
118
129
  - object_name
130
+ group: related_lists
119
131
  related_lists.$.related_field_fullname:
120
132
  type: lookup
121
133
  optionsFunction: !!js/function |
@@ -92,7 +92,7 @@ module.exports = {
92
92
  return true;
93
93
  },
94
94
  showDesign: function (object_name, record_id) {
95
- document.location = Steedos.absoluteUrl(`/api/amisListviewDesign?id=${record_id}&object=${this.record.object_name}&assetUrls=${Builder.settings.assetUrls}`);
95
+ document.location = Steedos.absoluteUrl(`/api/amisListviewDesign?id=${record_id}&object=${this.record.object_name}&assetUrls=${Builder.settings.assetUrls}&locale=${Builder.settings.locale}`);
96
96
  },
97
97
  showDesignVisible: function (object_name, record_id, record_permissions) {
98
98
  var perms= {};
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-03-28 09:35:34
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2022-05-30 18:38:47
4
+ * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
+ * @LastEditTime: 2023-07-13 13:28:02
6
6
  * @Description:
7
7
  */
8
8
  const _ = require("underscore");
@@ -91,7 +91,7 @@ Creator.Objects['object_listviews'].triggers = Object.assign(Creator.Objects['ob
91
91
  on: "server",
92
92
  when: "before.remove",
93
93
  todo: function (userId, doc) {
94
- console.log("before.remove");
94
+ // console.log("before.remove");
95
95
  if (doc.owner !== userId) {
96
96
  throw new Meteor.Error(403, "can only remove own list view");
97
97
  }
@@ -0,0 +1,42 @@
1
+ {
2
+ "type": "page",
3
+ "body": [
4
+ {
5
+ "type": "steedos-object-form",
6
+ "label": "对象表单",
7
+ "objectApiName": "object_fields",
8
+ "recordId": "${recordId}",
9
+ "className": "sm:border sm:shadow sm:rounded sm:border-gray-300 bg-white p-4",
10
+ "id": "u:b3d626885b90",
11
+ "mode": "edit",
12
+ "layout": "normal",
13
+ "enableTabs": true,
14
+ "onEvent": {
15
+ "change": {
16
+ "actions": [
17
+ {
18
+ "actionType": "setValue",
19
+ "args": {
20
+ "value": {
21
+ "defaultValue": ""
22
+ }
23
+ },
24
+ "expression": "${!!event.data.defaultValue_formula}"
25
+ }
26
+ ]
27
+ }
28
+ },
29
+ "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;",
30
+ "apiRequestAdaptor": "if(formData.defaultValue_formula){ formData.defaultValue = formData.defaultValue_formula } __saveData = JSON.stringify(JSON.stringify(formData)); api.data = {query: query.replace('{__saveData}', __saveData)};"
31
+ }
32
+ ],
33
+ "regions": [
34
+ "body"
35
+ ],
36
+ "data": {
37
+ "objectName": "object_fields"
38
+ },
39
+ "name": "page_object_fields_form",
40
+ "bodyClassName": "",
41
+ "id": "u:6e9674f278b0"
42
+ }
@@ -0,0 +1,12 @@
1
+ name: object_fields
2
+ is_active: true
3
+ label: 对象字段表单
4
+ object_name: object_fields
5
+ pageAssignments:
6
+ - desktop: true
7
+ mobile: true
8
+ page: object_fields_form
9
+ type: orgDefault
10
+ render_engine: amis
11
+ type: form
12
+ widgets: []
@@ -24,9 +24,16 @@ router.get('/api/amisButtonDesign', core.requireAuthentication, async function (
24
24
  // userId: userSession.userId,
25
25
  // authToken: userSession.authToken
26
26
  // }
27
+
28
+ let locale = "zh-CN";
29
+ if (req.query.locale == "en-us") {
30
+ locale = "en-US";
31
+ } else if (req.query.locale == "zh-cn") {
32
+ locale = "zh-CN";
33
+ }
27
34
  const retUrl = __meteor_runtime_config__.ROOT_URL + `/app/admin/object_actions/view/${req.query.id}`
28
35
  const steedosBuilderUrl = process.env.STEEDOS_BUILDER_URL || 'https://builder.steedos.cn';
29
- const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}retUrl=${retUrl}`;
36
+ const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}locale=${locale}&retUrl=${retUrl}`;
30
37
 
31
38
  // let data = fs.readFileSync(__dirname+'/design.html', 'utf8');
32
39
  // res.send(data.replace('SteedosBuilderHost',steedosBuilderHost).replace('DataContext', JSON.stringify(dataContext)));
@@ -24,10 +24,15 @@ router.get('/api/amisListviewDesign', core.requireAuthentication, async function
24
24
  // userId: userSession.userId,
25
25
  // authToken: userSession.authToken
26
26
  // }
27
-
27
+ let locale = "zh-CN";
28
+ if (req.query.locale == "en-us") {
29
+ locale = "en-US";
30
+ } else if (req.query.locale == "zh-cn") {
31
+ locale = "zh-CN";
32
+ }
28
33
  const retUrl = __meteor_runtime_config__.ROOT_URL + `/app/admin/object_listviews/view/${req.query.id}`
29
34
  const steedosBuilderUrl = process.env.STEEDOS_BUILDER_URL || 'https://builder.steedos.cn';
30
- const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}retUrl=${retUrl}`;
35
+ const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}locale=${locale}&retUrl=${retUrl}`;
31
36
  const record = await objectql.getObject('object_listviews').findOne(req.query.id);
32
37
  // let data = fs.readFileSync(__dirname+'/design.html', 'utf8');
33
38
  // res.send(data.replace('SteedosBuilderHost',steedosBuilderHost).replace('DataContext', JSON.stringify(dataContext)));
@@ -0,0 +1,242 @@
1
+ /*
2
+ * @Description: 提供action_field_updates(字段更新对象)需要的数据接口
3
+ */
4
+
5
+ const register = require("@steedos/metadata-registrar");
6
+ const steedosI18n = require("@steedos/i18n");
7
+ const _ = require("lodash");
8
+ const clone = require("clone");
9
+
10
+
11
+ module.exports = {
12
+ name: "object_fields",
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
+ getDefaultValueSchema: {
31
+ // 需要传 objectName, targetObject(非必填), field_name 参数进来。
32
+ rest: {
33
+ method: "GET",
34
+ path: "/defaultValue/schema"
35
+ },
36
+ async handler(ctx) {
37
+ const data = await this.getDefaultValueSchema(ctx);
38
+ return { status: 0, msg: "", data: data }
39
+ }
40
+ }
41
+ },
42
+
43
+ /**
44
+ * Events
45
+ */
46
+ events: {
47
+
48
+ },
49
+
50
+ /**
51
+ * Methods
52
+ */
53
+ methods: {
54
+ /* defaultValue 字段使用*/
55
+ getDefaultValueSchema: {
56
+ async handler(ctx) {
57
+ const userSession = ctx.meta.user;
58
+ const lng = userSession.language || 'zh-CN';
59
+ const type = ctx.params.type || 'text';
60
+ const objectName = ctx.params.object;
61
+ const fieldName = ctx.params.name;
62
+ const reference_to = ctx.params.reference_to;
63
+ const options = ctx.params.options;
64
+ const multiple = ctx.params.multiple;
65
+ const filtersFunction = ctx.params.filtersFunction;
66
+ const reference_to_field = ctx.params.reference_to_field || '_id';
67
+ const _id = ctx.params._id;
68
+ const mode = ctx.params.mode;
69
+ // const mode = global.mode;
70
+
71
+ const partialType = ['text','textarea','html','code','markdown','boolean','toggle','date','datetime','time','number','currency','percent','password','url','email'];
72
+ // const fieldType = partialType.indexOf(type) > -1 ? type : 'text';
73
+
74
+ let targetField = null;
75
+ let NAME_FIELD_KEY = null;
76
+ if (mode === 'read') {
77
+ const objectConfig = await register.getObjectConfig(objectName);
78
+ NAME_FIELD_KEY = objectConfig.NAME_FIELD_KEY || 'name';
79
+ targetField = objectConfig.fields[fieldName];
80
+ }
81
+ const value = (targetField && targetField.defaultValue) || '';
82
+ const translatedLabel = lng === 'zh-CN' ? "默认值" : 'DefaultValue';
83
+ let defaultValue_schema = {
84
+ "type": "text",
85
+ "name": "defaultValue",
86
+ "label": translatedLabel,
87
+ "labelClassName": "text-left"
88
+ }
89
+
90
+ if(partialType.indexOf(type) > -1){
91
+ defaultValue_schema.type = type;
92
+ }else if(type === 'select' && options){
93
+ defaultValue_schema.type = type;
94
+ defaultValue_schema.options = options;
95
+ defaultValue_schema.multiple = multiple;
96
+ }else if(['lookup','master_detail'].includes(type) && reference_to){
97
+ defaultValue_schema.type = type;
98
+ defaultValue_schema.reference_to = reference_to;
99
+ defaultValue_schema.multiple = multiple;
100
+ defaultValue_schema.filtersFunction = filtersFunction;
101
+ defaultValue_schema.reference_to_field = reference_to_field;
102
+ }
103
+
104
+ let steedos_field = {
105
+ type:'steedos-field',
106
+ name:'defaultValue',
107
+ clearValueOnHidden: true,
108
+ fieldName: 'defaultValue',
109
+ field: defaultValue_schema,
110
+ value: value,
111
+ readonly: mode === 'read' ? true : false
112
+ };
113
+ if(mode === 'read'){
114
+ const baseFieldConfig = {
115
+ "name": "defaultValue",
116
+ "label": translatedLabel,
117
+ "labelClassName": "text-left",
118
+ "clearValueOnHidden": true,
119
+ "fieldName": "defaultValue"
120
+ }
121
+ if(_.isString(value) && value.indexOf('{')>-1){
122
+ // 只读时值是公式就显示公式
123
+ steedos_field = {
124
+ "type": "control",
125
+ "label": translatedLabel,
126
+ "body": {
127
+ "name": "defaultValue",
128
+ "label": translatedLabel,
129
+ "labelClassName": "text-left",
130
+ "type": "tpl",
131
+ "tpl": value.indexOf('$') > -1 ? "\\"+value : value
132
+ }
133
+ }
134
+ }else if(['number','currency','percent'].includes(type)){
135
+ steedos_field = {
136
+ ...baseFieldConfig,
137
+ "type": "static-tpl",
138
+ "tpl": `<div>${value}</div>`,
139
+ "className": "m-1 md:border-b steedos-static-tpl-readonly",
140
+ "quickEdit": false,
141
+ }
142
+ }else if(['date','datetime','time'].includes(type)){
143
+ let fieldTypeConfig ={};
144
+ if(type==='date'){
145
+ fieldTypeConfig = {
146
+ "type": "input-date",
147
+ "inputFormat": "YYYY-MM-DD",
148
+ "format": "YYYY-MM-DDT00:00:00.000[Z]",
149
+ "className": "m-1 steedos-input-date-edit",
150
+ }
151
+ }else if(type==='datetime'){
152
+ fieldTypeConfig = {
153
+ "type": "input-datetime",
154
+ "inputFormat": "YYYY-MM-DD HH:mm",
155
+ "format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
156
+ "className": "m-1 steedos-input-datetime-edit",
157
+ }
158
+ }else if(type==='time'){
159
+ fieldTypeConfig = {
160
+ "type": "input-time",
161
+ "inputFormat": "HH:mm",
162
+ "format": "1970-01-01THH:mm:00.000[Z]",
163
+ "className": "m-1 steedos-input-time-edit",
164
+ }
165
+ }
166
+ steedos_field = {
167
+ ...baseFieldConfig,
168
+ ...fieldTypeConfig,
169
+ value: value,
170
+ static: true
171
+ }
172
+ }else if(['boolean'].includes(type)){
173
+ steedos_field = {
174
+ ...baseFieldConfig,
175
+ value: value,
176
+ "type": "static",
177
+ "tpl": `${value}`,
178
+ "className": "m-1 md:border-b steedos-static-readonly"
179
+ }
180
+ }else if(['lookup','master_detail'].includes(type)){
181
+ // console.log('t==>', type, reference_to, NAME_FIELD_KEY, targetField)
182
+ if(value && value.length && _.isString(reference_to)){
183
+ const query = {
184
+ fields: [NAME_FIELD_KEY],
185
+ filters: [reference_to_field, '=', value]
186
+ }
187
+ const res = await this.broker.call(
188
+ 'objectql.find',
189
+ {
190
+ objectName: reference_to,
191
+ query
192
+ }
193
+ );
194
+ // console.log('res==>', res, reference_to, NAME_FIELD_KEY, targetField);
195
+ const tpl = _.map(res, NAME_FIELD_KEY).join('、')
196
+ steedos_field = {
197
+ "type": "control",
198
+ "label": translatedLabel,
199
+ "body": {
200
+ "name": "defaultValue",
201
+ "label": translatedLabel,
202
+ "labelClassName": "text-left",
203
+ "type": "tpl",
204
+ "tpl": tpl
205
+ },
206
+ value: value
207
+ }
208
+ }
209
+ }
210
+ }
211
+ let body = [
212
+ steedos_field
213
+ ]
214
+ if(mode === 'edit'){
215
+ body[0].field.amis = {
216
+ // disabledOn: "!!this.defaultValue_formula",
217
+ "className": {
218
+ "defaultValue_field_hidden": "!this.defaultValue && (!this.defaultValue || '').toString() && !!this.defaultValue_formula"
219
+ }
220
+ }
221
+ body.push({
222
+ "name": "defaultValue_formula",
223
+ "label": translatedLabel,
224
+ "evalMode": false,
225
+ "type": "input-formula",
226
+ "placeholder": "公式",
227
+ // "disabledOn": "!!this.defaultValue && !!this.defaultValue.toString()",
228
+ "className": {
229
+ "defaultValue_field_formula": true,
230
+ "defaultValue_field_formula_visible": "!!this.defaultValue_formula",
231
+ "defaultValue_field_formula_hidden": "(!!this.defaultValue && !!this.defaultValue.toString()) || (!this.defaultValue && !this.defaultValue_formula)"
232
+ }
233
+ })
234
+ }
235
+ // console.log('body==>', body);
236
+ return {
237
+ body
238
+ }
239
+ }
240
+ }
241
+ }
242
+ };
@@ -52,8 +52,8 @@ module.exports = {
52
52
  let views = []
53
53
  if(filters._id && !filters._id.$ne){
54
54
  let id = filters._id
55
- id = id.replace(/\\/g, '');
56
55
  if(_.isString(id)){
56
+ id = id.replace(/\\/g, ''); // string类型才有replce方法
57
57
  let objectName = id.substr(0, id.indexOf("."));
58
58
  if(objectName){
59
59
  let view = await InternalData.getObjectListView(objectName, this.userId, id);
@@ -62,6 +62,21 @@ module.exports = {
62
62
  }
63
63
  }
64
64
  }
65
+ else if (id.$in) {
66
+ for (const _id of id.$in) {
67
+ if(_.isString(_id) && _id.indexOf('.') > 0){
68
+ let objectName = _id.split('.')[0];
69
+ let view = await InternalData.getObjectListView(objectName, this.userId, _id);
70
+ if(view){
71
+ if (_.isArray(this.query.fields)) {
72
+ const fields = ["_id"].concat(this.query.fields);
73
+ view = _.pick(view, fields);
74
+ }
75
+ views.push(view);
76
+ }
77
+ }
78
+ }
79
+ }
65
80
  }else if(filters.object_name){
66
81
  views = await InternalData.getObjectListViews(filters.object_name, this.userId);
67
82
  }
@@ -76,10 +76,35 @@ module.exports = {
76
76
  }
77
77
  },
78
78
  afterInsert: async function(){
79
- const doc = this.doc;
80
- if(doc.enable_tree){
81
- await objectTree.insertParentAndChildrenFieldForTreeObject(doc)
79
+ const object = this.doc;
80
+ const { spaceId , userId } = this;
81
+ if(object.enable_tree){
82
+ await objectTree.insertParentAndChildrenFieldForTreeObject(object)
82
83
  }
84
+
85
+ const tabLabel = object.label || object.name;
86
+ const tabName = "object_" + object.name.replace(/__c$/, "");
87
+ const now = new Date();
88
+ const tabDoc = {
89
+ label: tabLabel,
90
+ name: tabName,
91
+ icon: object.icon,
92
+ type: "object",
93
+ mobile: true,
94
+ desktop: true,
95
+ object: object.name,
96
+ space: spaceId,
97
+ owner: userId,
98
+ created_by: userId,
99
+ created: now,
100
+ modified_by: userId,
101
+ modified: now,
102
+ company_id: object.companyId,
103
+ company_ids: object.companyIds
104
+ };
105
+ await objectql.getObject('tabs').insert(tabDoc);
106
+
107
+
83
108
  // let spaceProfiles = await objectql.getObject('permission_set').find({space: this.spaceId, type: 'profile'});
84
109
  // await objectql.getObject('object_layouts').insert({
85
110
  // label: 'default',
@@ -145,5 +170,13 @@ module.exports = {
145
170
  */
146
171
 
147
172
  await sleep(1000 * 2)
173
+ },
174
+ afterDelete: async function(){
175
+ const { previousDoc: object, spaceId } = this;
176
+ const objectTabs = await objectql.getObject('tabs').find({filters: [['type', '=', 'object'], ['object', '=', object.name], ['space', '=', spaceId]]})
177
+ for(const record of objectTabs){
178
+ // console.log(`delete tabs`, record._id, record.name)
179
+ await objectql.getObject('tabs').delete(record._id);
180
+ }
148
181
  }
149
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.6.1-beta.6",
3
+ "version": "2.6.1-beta.7",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,5 +15,5 @@
15
15
  },
16
16
  "repository": {},
17
17
  "license": "MIT",
18
- "gitHead": "d77961251196c5352622d977e554660796ed6208"
18
+ "gitHead": "b12f271460ef3686face095e875aa38e8ddc4c7f"
19
19
  }