@steedos/standard-object-database 2.6.8-beta.6 → 2.6.8-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.
@@ -313,11 +313,11 @@ fields:
313
313
  description:
314
314
  readonly:
315
315
  label: Readonly
316
- help:
316
+ help: It is read-only and does not appear on the form when you create or edit records.
317
317
  description:
318
318
  static:
319
- label: Static
320
- help: Static mode, displayed as read-only, but the field value can be set by default, autofill, or custom scripts.
319
+ label: Readonly and displayed while editing
320
+ help: Displays as read-only, but the field value can be set by default, autofill, or custom scripts when creating and editing records.
321
321
  description:
322
322
  hidden:
323
323
  label: Hidden
@@ -297,11 +297,11 @@ fields:
297
297
  description:
298
298
  readonly:
299
299
  label: 只读
300
- help:
300
+ help: 只读,且新建和编辑记录时不显示在表单上
301
301
  description:
302
302
  static:
303
- label: 静态模式
304
- help: 显示为只读,但是可以通过默认值,自动填充或自定义脚本设置该字段值
303
+ label: 只读且编辑时显示
304
+ help: 显示为只读,但是在新建和编辑记录时可以通过默认值,自动填充或自定义脚本设置该字段值
305
305
  description:
306
306
  hidden:
307
307
  label: 隐藏
@@ -1,55 +1,55 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-08-05 14:17:44
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-05-12 09:33:27
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2024-02-27 15:41:42
6
6
  * @Description:
7
7
  */
8
- const objectql = require("@steedos/objectql");
9
- const objectName = "object_fields";
10
- Meteor.startup(function () {
11
- var _change, _remove, inited = false;
12
- _change = function (document) {
13
- // 重置字段权限延迟10秒,防止对象服务未上线
14
- setTimeout(()=>{
15
- try {
16
- // console.log("====resetAllPermissionSetFieldPermissions====")
17
- objectql.getSteedosSchema().broker.call(`permission_fields.resetAllPermissionSetFieldPermissions`, {
18
- objectName: document.object
19
- }, {
20
- meta: {
21
- user: {
22
- userId: document.owner,
23
- spaceId: document.space,
24
- company_id: document.company_id,
25
- company_ids: document.company_ids,
26
- }
27
- }
28
- });
29
- } catch (error) {
30
- console.error(`resetAllPermissionSetFieldPermissions`, error)
31
- }
32
- }, 1000 * 10)
33
- };
34
- Creator.getCollection(objectName).find({}, {
35
- fields: {
36
- created: 0,
37
- created_by: 0,
38
- modified: 0,
39
- modified_by: 0
40
- }
41
- }).observe({
42
- added: function (newDocument) {
43
- if (inited) {
44
- return _change(newDocument);
45
- }
46
- },
47
- changed: function (newDocument, oldDocument) {
48
- return _change(newDocument);
49
- },
50
- removed: function (oldDocument) {
51
- return _change(oldDocument);
52
- }
53
- });
54
- inited = true;
55
- });
8
+ // const objectql = require("@steedos/objectql");
9
+ // const objectName = "object_fields";
10
+ // Meteor.startup(function () {
11
+ // var _change, _remove, inited = false;
12
+ // _change = function (document) {
13
+ // // 重置字段权限延迟10秒,防止对象服务未上线
14
+ // setTimeout(()=>{
15
+ // try {
16
+ // // console.log("====resetAllPermissionSetFieldPermissions====")
17
+ // objectql.getSteedosSchema().broker.call(`permission_fields.resetAllPermissionSetFieldPermissions`, {
18
+ // objectName: document.object
19
+ // }, {
20
+ // meta: {
21
+ // user: {
22
+ // userId: document.owner,
23
+ // spaceId: document.space,
24
+ // company_id: document.company_id,
25
+ // company_ids: document.company_ids,
26
+ // }
27
+ // }
28
+ // });
29
+ // } catch (error) {
30
+ // console.error(`resetAllPermissionSetFieldPermissions`, error)
31
+ // }
32
+ // }, 1000 * 10)
33
+ // };
34
+ // Creator.getCollection(objectName).find({}, {
35
+ // fields: {
36
+ // created: 0,
37
+ // created_by: 0,
38
+ // modified: 0,
39
+ // modified_by: 0
40
+ // }
41
+ // }).observe({
42
+ // added: function (newDocument) {
43
+ // if (inited) {
44
+ // return _change(newDocument);
45
+ // }
46
+ // },
47
+ // changed: function (newDocument, oldDocument) {
48
+ // return _change(newDocument);
49
+ // },
50
+ // removed: function (oldDocument) {
51
+ // return _change(oldDocument);
52
+ // }
53
+ // });
54
+ // inited = true;
55
+ // });
@@ -1,56 +1,56 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-08-05 14:17:44
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-05-13 17:09:31
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2024-02-27 15:48:50
6
6
  * @Description:
7
7
  */
8
- const objectql = require("@steedos/objectql");
9
- const objectName = "permission_objects";
10
- Meteor.startup(function () {
11
- var _change, _remove, inited = false;
12
- _change = function (document) {
13
- setTimeout(()=>{
14
- try {
15
- objectql.getSteedosSchema().broker.call(`permission_fields.resetFieldPermissions`, {
16
- permissionObjectId: document._id
17
- }, {
18
- meta: {
19
- user: {
20
- userId: document.owner,
21
- spaceId: document.space,
22
- company_id: document.company_id,
23
- company_ids: document.company_ids,
24
- }
25
- }
26
- });
27
- } catch (error) {
28
- console.error(`resetFieldPermissions`, error)
29
- }
30
- }, 1000 * 10)
31
- };
32
- Creator.getCollection(objectName).find({}, {
33
- fields: {
34
- created: 0,
35
- created_by: 0,
36
- modified: 0,
37
- modified_by: 0
38
- }
39
- }).observe({
40
- added: function (newDocument) {
41
- if (newDocument.copy_from) { // 通过复制简档创建的对象权限,不需要重置字段权限
42
- return;
43
- }
44
- if (inited) {
45
- return _change(newDocument);
46
- }
47
- },
48
- changed: function (newDocument, oldDocument) {
49
- return _change(newDocument);
50
- },
51
- // removed: function (oldDocument) {
52
- // return _change(oldDocument);
53
- // }
54
- });
55
- inited = true;
56
- });
8
+ // const objectql = require("@steedos/objectql");
9
+ // const objectName = "permission_objects";
10
+ // Meteor.startup(function () {
11
+ // var _change, _remove, inited = false;
12
+ // _change = function (document) {
13
+ // setTimeout(()=>{
14
+ // try {
15
+ // objectql.getSteedosSchema().broker.call(`permission_fields.resetFieldPermissions`, {
16
+ // permissionObjectId: document._id
17
+ // }, {
18
+ // meta: {
19
+ // user: {
20
+ // userId: document.owner,
21
+ // spaceId: document.space,
22
+ // company_id: document.company_id,
23
+ // company_ids: document.company_ids,
24
+ // }
25
+ // }
26
+ // });
27
+ // } catch (error) {
28
+ // console.error(`resetFieldPermissions`, error)
29
+ // }
30
+ // }, 1000 * 10)
31
+ // };
32
+ // Creator.getCollection(objectName).find({}, {
33
+ // fields: {
34
+ // created: 0,
35
+ // created_by: 0,
36
+ // modified: 0,
37
+ // modified_by: 0
38
+ // }
39
+ // }).observe({
40
+ // added: function (newDocument) {
41
+ // if (newDocument.copy_from) { // 通过复制简档创建的对象权限,不需要重置字段权限
42
+ // return;
43
+ // }
44
+ // if (inited) {
45
+ // return _change(newDocument);
46
+ // }
47
+ // },
48
+ // changed: function (newDocument, oldDocument) {
49
+ // return _change(newDocument);
50
+ // },
51
+ // // removed: function (oldDocument) {
52
+ // // return _change(oldDocument);
53
+ // // }
54
+ // });
55
+ // inited = true;
56
+ // });
@@ -820,12 +820,13 @@ fields:
820
820
  readonly:
821
821
  type: boolean
822
822
  label: Readonly
823
+ inlineHelpText: It is read-only and does not appear on the form when you create or edit records.
823
824
  group: ui
824
825
  static:
825
826
  type: boolean
826
- label: Static
827
- group: Advanced
828
- inlineHelpText: Static mode, displayed as read-only, but the field value can be set by default, autofill, or custom scripts.
827
+ label: Readonly and displayed while editing
828
+ group: ui
829
+ inlineHelpText: Displays as read-only, but the field value can be set by default, autofill, or custom scripts when creating and editing records.
829
830
  hidden:
830
831
  type: boolean
831
832
  label: Hidden
@@ -312,7 +312,7 @@
312
312
  "headers": {
313
313
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
314
314
  },
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}",
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{{true}}{{false}},则清空\n const visible_on = field.attr_visible_on == \"{{false}}\" || \"{{true}}\" ? null : field.attr_visible_on;\n const hidden = key == \"隐藏\"?true:false;\n let docJson = {\n sort_no: index * 10,\n group, \n hidden\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 is_system: field.is_system,\n hidden\n }\n }\n if (visible_on != field.attr_visible_on) {\n docJson.visible_on = visible_on;\n }\n //hidden为true的字段,required应设为false\n if (hidden == true) {\n docJson.required = 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}",
316
316
  "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
317
  "messages": {},
318
318
  "data": {
@@ -35,12 +35,101 @@
35
35
  {
36
36
  "actionType": "toast",
37
37
  "args": {
38
- "msgType": "success",
39
- "msg": "操作成功, 请刷新浏览器后查看效果",
40
- "position": "top-right"
38
+ "msgType": "success",
39
+ "msg": "操作成功, 请刷新浏览器后查看效果",
40
+ "position": "top-right"
41
41
  }
42
42
  }
43
- ]
43
+ ],
44
+ "fieldsExtend": {
45
+ "readonly": {
46
+ "amis": {
47
+ "onEvent": {
48
+ "change": {
49
+ "actions": [
50
+ {
51
+ "actionType": "setValue",
52
+ "componentId": "steedos_object_fields_form",
53
+ "args": {
54
+ "value": {
55
+ "static": false
56
+ }
57
+ },
58
+ "expression": "!!readonly"
59
+ }
60
+ ]
61
+ }
62
+ },
63
+ "id": "u:a32a4c461450"
64
+ }
65
+ },
66
+ "static": {
67
+ "amis": {
68
+ "onEvent": {
69
+ "change": {
70
+ "actions": [
71
+ {
72
+ "actionType": "setValue",
73
+ "componentId": "steedos_object_fields_form",
74
+ "args": {
75
+ "value": {
76
+ "readonly": false
77
+ }
78
+ },
79
+ "expression": "!!static"
80
+ }
81
+ ]
82
+ }
83
+ },
84
+ "id": "u:7affdbb0ef6d"
85
+ }
86
+ },
87
+ "required": {
88
+ "amis": {
89
+ "onEvent": {
90
+ "change": {
91
+ "actions": [
92
+ {
93
+ "actionType": "setValue",
94
+ "args": {
95
+ "value": {
96
+ "hidden": false
97
+ }
98
+ },
99
+ "componentId": "steedos_object_fields_form",
100
+ "expression": "${event.data.value}"
101
+ }
102
+ ]
103
+ }
104
+ },
105
+ "id": "u:adf4200a2170"
106
+ }
107
+ },
108
+ "hidden": {
109
+ "amis": {
110
+ "onEvent": {
111
+ "change": {
112
+ "actions": [
113
+ {
114
+ "actionType": "setValue",
115
+ "args": {
116
+ "value": {
117
+ "required": false
118
+ }
119
+ },
120
+ "componentId": "steedos_object_fields_form",
121
+ "expression": "${event.data.value}"
122
+ }
123
+ ]
124
+ }
125
+ },
126
+ "id": "u:adf4200a2170"
127
+ }
128
+ }
129
+ },
130
+ "form": {
131
+ "id": "steedos_object_fields_form"
132
+ }
44
133
  }
45
134
  ],
46
135
  "data": {
@@ -125,14 +125,14 @@ async function checkMasterDetailTypeField(doc, oldReferenceTo) {
125
125
 
126
126
  const mastersCount = currentMasters.length;
127
127
  const detailsCount = currentDetails.length;
128
- if (mastersCount > 1) {
129
- throw new Meteor.Error(doc.name, "您无法创建此类型的字段,因为此对象已有两种主表子表关系。");
130
- }
131
- else if (mastersCount > 0) {
132
- if (detailsCount > 0) {
133
- throw new Meteor.Error(doc.name, "由于此对象上已经存在主表子表关系,同时是另一个主表子表关系的主对象,无法创建此类字段。");
134
- }
135
- }
128
+ if (mastersCount > 5) {
129
+ throw new Meteor.Error(doc.name, "您无法创建此类型的字段,因为此对象已有5种主表子表关系。");
130
+ }
131
+ // else if (mastersCount > 0) { // 当前对象已经有1个主子表字段
132
+ // if (detailsCount > 0) { // 当前对象已经作为了其他对象的主子表字段的关联对象
133
+ // throw new Meteor.Error(doc.name, "由于此对象上已经存在主表子表关系,同时是另一个主表子表关系的主对象,无法创建此类字段。");
134
+ // }
135
+ // }
136
136
 
137
137
  const detailPaths = await obj.getDetailPaths();
138
138
  const masterPaths = await refObj.getMasterPaths();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.6.8-beta.6",
3
+ "version": "2.6.8-beta.7",
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.6.8-beta.6",
16
- "@steedos/standard-objects": "2.6.8-beta.6"
15
+ "@steedos/metadata-core": "2.6.8-beta.7",
16
+ "@steedos/standard-objects": "2.6.8-beta.7"
17
17
  },
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "dc91074a4f6662d1a2f49e03d6b5efd45e8cb9bf"
20
+ "gitHead": "177276deba27846002ebc5e7aecd055bf4f61331"
21
21
  }