@steedos/standard-object-database 2.6.2-beta.13 → 2.6.2-beta.15
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.
- package/main/default/objectTranslations/object_fields.en/object_fields.en.objectTranslation.yml +2 -0
- package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +2 -0
- package/main/default/objects/object_fields.object.yml +4 -2
- package/main/default/objects/object_listviews.object.yml +9 -1
- package/main/default/pages/design_field_layout.page.amis.json +35 -35
- package/main/default/triggers/object_fields.trigger.js +1 -1
- package/package.json +3 -3
|
@@ -66,6 +66,8 @@ fields:
|
|
|
66
66
|
value: markdown
|
|
67
67
|
- label: Select
|
|
68
68
|
value: select
|
|
69
|
+
- label: Color
|
|
70
|
+
value: color
|
|
69
71
|
- label: Boolean
|
|
70
72
|
value: boolean
|
|
71
73
|
- label: Toggle
|
|
@@ -431,7 +433,7 @@ fields:
|
|
|
431
433
|
# group: Advanced
|
|
432
434
|
sort_no: 270
|
|
433
435
|
options:
|
|
434
|
-
type:
|
|
436
|
+
type: table
|
|
435
437
|
label: Options
|
|
436
438
|
is_wide: true
|
|
437
439
|
inlineHelpText: The label and value of each option cannot be empty. Set the background color to FFFFFF in hexadecimal format.
|
|
@@ -454,7 +456,7 @@ fields:
|
|
|
454
456
|
required: true
|
|
455
457
|
options.$.color:
|
|
456
458
|
label: Color
|
|
457
|
-
type:
|
|
459
|
+
type: color
|
|
458
460
|
required: false
|
|
459
461
|
options.$.description:
|
|
460
462
|
label: Description
|
|
@@ -220,7 +220,7 @@ fields:
|
|
|
220
220
|
visible_on: "{{global.mode ==='read' ? true : false}}"
|
|
221
221
|
mobile_columns:
|
|
222
222
|
label: Mobile Columns
|
|
223
|
-
type:
|
|
223
|
+
type: table
|
|
224
224
|
is_wide: true
|
|
225
225
|
depend_on:
|
|
226
226
|
- object_name
|
|
@@ -234,8 +234,16 @@ fields:
|
|
|
234
234
|
type: lookup
|
|
235
235
|
multiple: false
|
|
236
236
|
is_wide: false
|
|
237
|
+
required: true
|
|
238
|
+
depend_on:
|
|
239
|
+
- object_name
|
|
237
240
|
reference_to: object_fields
|
|
238
241
|
reference_to_field: name
|
|
242
|
+
enable_enhanced_lookup: false
|
|
243
|
+
filtersFunction: !<tag:yaml.org,2002:js/function> |-
|
|
244
|
+
function(filters, values){
|
|
245
|
+
return ['object', '=', values.object_name]
|
|
246
|
+
}
|
|
239
247
|
searchable_fields:
|
|
240
248
|
label: Searchable Fields
|
|
241
249
|
type: grid
|
|
@@ -34,29 +34,36 @@
|
|
|
34
34
|
"size": "lg",
|
|
35
35
|
"body": [
|
|
36
36
|
{
|
|
37
|
-
"type": "
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"name": "group_name",
|
|
41
|
-
"label": "名称",
|
|
42
|
-
"type": "text",
|
|
43
|
-
"id": "u:31952daa443c"
|
|
44
|
-
},
|
|
37
|
+
"type": "form",
|
|
38
|
+
"mode": "normal",
|
|
39
|
+
"body": [
|
|
45
40
|
{
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
"type": "steedos-input-table",
|
|
42
|
+
"fields": [
|
|
43
|
+
{
|
|
44
|
+
"name": "group_name",
|
|
45
|
+
"label": "名称",
|
|
46
|
+
"type": "text",
|
|
47
|
+
"id": "u:31952daa443c"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "visible_on",
|
|
51
|
+
"label": "显示条件",
|
|
52
|
+
"type": "text",
|
|
53
|
+
"id": "u:8d7551abcd28",
|
|
54
|
+
"value": null
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"name": "groups",
|
|
58
|
+
"addable": true,
|
|
59
|
+
"editable": true,
|
|
60
|
+
"removable": true,
|
|
61
|
+
"draggable": false,
|
|
62
|
+
"showIndex": false,
|
|
63
|
+
"id": "u:776ec89804c0",
|
|
64
|
+
"label": ""
|
|
51
65
|
}
|
|
52
|
-
]
|
|
53
|
-
"name": "groups",
|
|
54
|
-
"addable": true,
|
|
55
|
-
"editable": true,
|
|
56
|
-
"removable": true,
|
|
57
|
-
"draggable": false,
|
|
58
|
-
"showIndex": false,
|
|
59
|
-
"id": "u:776ec89804c0"
|
|
66
|
+
]
|
|
60
67
|
}
|
|
61
68
|
],
|
|
62
69
|
"onEvent": {
|
|
@@ -261,8 +268,7 @@
|
|
|
261
268
|
}
|
|
262
269
|
],
|
|
263
270
|
"bodyClassName": "h-7 flex justify-between items-center p-0 pl-10 my-2",
|
|
264
|
-
"toolbar": [
|
|
265
|
-
],
|
|
271
|
+
"toolbar": [],
|
|
266
272
|
"className": "mb-0 border-0 bg-none card",
|
|
267
273
|
"id": "u:296298da1bef"
|
|
268
274
|
},
|
|
@@ -291,8 +297,7 @@
|
|
|
291
297
|
},
|
|
292
298
|
"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}",
|
|
293
299
|
"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;",
|
|
294
|
-
"messages": {
|
|
295
|
-
},
|
|
300
|
+
"messages": {},
|
|
296
301
|
"data": {
|
|
297
302
|
"design_field": "${design_field}",
|
|
298
303
|
"groups": "${groups}",
|
|
@@ -334,14 +339,12 @@
|
|
|
334
339
|
"headers": {
|
|
335
340
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
336
341
|
},
|
|
337
|
-
"messages": {
|
|
338
|
-
},
|
|
342
|
+
"messages": {},
|
|
339
343
|
"requestAdaptor": "",
|
|
340
344
|
"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};",
|
|
341
345
|
"sendOn": "!!this.designObjectId"
|
|
342
346
|
},
|
|
343
|
-
"messages": {
|
|
344
|
-
},
|
|
347
|
+
"messages": {},
|
|
345
348
|
"onEvent": {
|
|
346
349
|
"fetchInited": {
|
|
347
350
|
"actions": [
|
|
@@ -369,13 +372,11 @@
|
|
|
369
372
|
"headers": {
|
|
370
373
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
371
374
|
},
|
|
372
|
-
"messages": {
|
|
373
|
-
},
|
|
375
|
+
"messages": {},
|
|
374
376
|
"requestAdaptor": "",
|
|
375
377
|
"adaptor": "const field_groups = payload.data.objects[0] && _.map(payload.data.objects[0].field_groups, function (obj) {\r\n return {\r\n \"id\": obj.group_name,\r\n \"group_name\": obj.group_name,\r\n \"visible_on\": obj.visible_on\r\n }\r\n});\r\nfield_groups.unshift({\r\n id: \"隐藏\",\r\n group_name: \"隐藏\",\r\n visible_on: \"\",\r\n is_hidden: true\r\n});\r\nfield_groups.unshift({\r\n id: \"未分组\",\r\n group_name: \"未分组\",\r\n visible_on: \"\",\r\n is_default: true\r\n});\r\n\r\n\r\n\r\nconst designObjectId = payload.data.objects[0] && payload.data.objects[0]._id;\r\nreturn payload = {\r\n data: {\r\n field_groups,\r\n designObjectId,\r\n designObjectLabel: payload.data.objects[0] && payload.data.objects[0].label,\r\n _master: {\r\n recordId: designObjectId\r\n }\r\n }\r\n}"
|
|
376
378
|
},
|
|
377
|
-
"messages": {
|
|
378
|
-
},
|
|
379
|
+
"messages": {},
|
|
379
380
|
"onEvent": {
|
|
380
381
|
"@data.changed.object_fields": {
|
|
381
382
|
"actions": [
|
|
@@ -395,8 +396,7 @@
|
|
|
395
396
|
"body"
|
|
396
397
|
],
|
|
397
398
|
"data": {
|
|
398
|
-
"initialValues": {
|
|
399
|
-
},
|
|
399
|
+
"initialValues": {},
|
|
400
400
|
"appId": "builder",
|
|
401
401
|
"title": "",
|
|
402
402
|
"context": "${context}",
|
|
@@ -35,7 +35,7 @@ const validateOptionsValue = (value)=>{
|
|
|
35
35
|
|
|
36
36
|
const validateOptionColorValue = (value)=>{
|
|
37
37
|
if(value){
|
|
38
|
-
const reg = /^[\da-f]{6}$/i;
|
|
38
|
+
const reg = /^(#)?[\da-f]{6}$/i;
|
|
39
39
|
if(!reg.test(value)){
|
|
40
40
|
throw new Error("object_fields_error_option_color_not_valid");
|
|
41
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.6.2-beta.
|
|
3
|
+
"version": "2.6.2-beta.15",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"description": "steedos package",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@steedos-widgets/amis-lib": "^1.0.22",
|
|
15
|
-
"@steedos/standard-objects": "2.6.2-beta.
|
|
15
|
+
"@steedos/standard-objects": "2.6.2-beta.15"
|
|
16
16
|
},
|
|
17
17
|
"repository": {},
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "848eb6cdf895971f0ea6638795e8be4e0b7d2b3b"
|
|
20
20
|
}
|