@steedos/standard-object-database 2.5.20-beta.2 → 2.5.20-beta.21
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 +1 -0
- package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +1 -0
- package/main/default/objects/object_fields.object.js +29 -44
- package/main/default/objects/object_fields.object.yml +24 -50
- package/main/default/objects/objects/buttons/custom.button.js +48 -0
- package/main/default/objects/objects/buttons/custom.button.yml +6 -0
- package/main/default/objects/objects.core.js +10 -0
- package/main/default/objects/objects.tree.js +3 -2
- package/main/default/pages/design_field_layout.page.amis.json +114 -48
- package/main/default/pages/object_detail.page.amis.json +5 -19
- package/main/default/pages/object_fields_form.page.amis.json +1 -1
- package/main/default/pages/object_form.page.yml +1 -1
- package/main/default/triggers/object_fields.trigger.js +8 -1
- package/package.json +2 -2
- package/package.service.js +4 -3
|
@@ -3,6 +3,19 @@ var objectql = require('@steedos/objectql');
|
|
|
3
3
|
var clone = require('clone');
|
|
4
4
|
var objectCore = require('./objects.core.js');
|
|
5
5
|
|
|
6
|
+
const objectFieldsFind = function (filter) {
|
|
7
|
+
return objectql.wrapAsync(async function () {
|
|
8
|
+
return await objectql.getObject('object_fields').find(this.filter);
|
|
9
|
+
}, { filter: filter })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const getRecords = function (objectName) {
|
|
14
|
+
return objectql.wrapAsync(async function () {
|
|
15
|
+
return await objectql.getObject(this.objectName).directFind({fields:["_id"], top: 1});
|
|
16
|
+
}, { objectName: objectName })
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
const MAX_MASTER_DETAIL_LEAVE = objectql.MAX_MASTER_DETAIL_LEAVE;
|
|
7
20
|
|
|
8
21
|
function canRemoveNameFileld(doc){
|
|
@@ -105,20 +118,18 @@ function _syncToObject(doc, event) {
|
|
|
105
118
|
};
|
|
106
119
|
|
|
107
120
|
function isRepeatedName(doc, name) {
|
|
108
|
-
var other
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_id: 1
|
|
119
|
-
}
|
|
121
|
+
var other = objectFieldsFind({
|
|
122
|
+
filters: [[
|
|
123
|
+
'object', '=', doc.object
|
|
124
|
+
], [
|
|
125
|
+
'space', '=', doc.space
|
|
126
|
+
], [
|
|
127
|
+
'_id', '!=', doc._id
|
|
128
|
+
], [
|
|
129
|
+
'name', '=', name || doc.name
|
|
130
|
+
]]
|
|
120
131
|
});
|
|
121
|
-
if (other.
|
|
132
|
+
if (other.length > 0) {
|
|
122
133
|
return true;
|
|
123
134
|
}
|
|
124
135
|
return false;
|
|
@@ -428,11 +439,11 @@ var triggers = {
|
|
|
428
439
|
}
|
|
429
440
|
});
|
|
430
441
|
if (object) {
|
|
431
|
-
object_documents =
|
|
432
|
-
if ((modifier != null ? (ref6 = modifier.$set) != null ? ref6.reference_to : void 0 : void 0) && doc.reference_to !== _reference_to && object_documents.
|
|
442
|
+
object_documents = getRecords(object.name);
|
|
443
|
+
if ((modifier != null ? (ref6 = modifier.$set) != null ? ref6.reference_to : void 0 : void 0) && doc.reference_to !== _reference_to && object_documents.length > 0) {
|
|
433
444
|
throw new Meteor.Error(500, `对象${object.label}中已经有记录,不能修改reference_to字段`);
|
|
434
445
|
}
|
|
435
|
-
if ((modifier != null ? (ref7 = modifier.$unset) != null ? ref7.reference_to : void 0 : void 0) && doc.reference_to !== _reference_to && object_documents.
|
|
446
|
+
if ((modifier != null ? (ref7 = modifier.$unset) != null ? ref7.reference_to : void 0 : void 0) && doc.reference_to !== _reference_to && object_documents.length > 0) {
|
|
436
447
|
throw new Meteor.Error(500, `对象${object.label}中已经有记录,不能修改reference_to字段`);
|
|
437
448
|
}
|
|
438
449
|
}
|
|
@@ -455,33 +466,6 @@ var triggers = {
|
|
|
455
466
|
throw new Meteor.Error(500, "华炎云服务不包含自定义业务对象的功能,请部署私有云版本");
|
|
456
467
|
}
|
|
457
468
|
|
|
458
|
-
const staticRequiredFields = ['object','label','_name','type'];
|
|
459
|
-
// const staticRequiredFieldLabel = ['所属对象','显示名称','字段名','字段类型'];
|
|
460
|
-
for(let i = 0; i<staticRequiredFields.length; i++){
|
|
461
|
-
const fieldName = staticRequiredFields[i];
|
|
462
|
-
const fieldValue = doc[fieldName];
|
|
463
|
-
if(!fieldValue){
|
|
464
|
-
throw new Meteor.Error(fieldName, "必填字段");
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
// options子字段、precision、scale、summary_field不参与以下简单动态必填字段组。
|
|
468
|
-
const dynamicsRequired = [
|
|
469
|
-
['language',['code']],['reference_to',['lookup', 'master_detail']],['formula',['autonumber', 'formula']],
|
|
470
|
-
['data_type',['formula']],['rows',['textarea']],['options',['select']],
|
|
471
|
-
['formula_blank_value',['formula']],['summary_object',['summary']],['summary_type',['summary']],
|
|
472
|
-
['deleted_lookup_record_behavior',['lookup']]
|
|
473
|
-
];
|
|
474
|
-
|
|
475
|
-
for(let i = 0; i<dynamicsRequired.length; i++){
|
|
476
|
-
if( dynamicsRequired[i][1].indexOf(doc.type) > -1 ){
|
|
477
|
-
const fieldName = dynamicsRequired[i][0];
|
|
478
|
-
const fieldValue = doc[fieldName];
|
|
479
|
-
if(!fieldValue){
|
|
480
|
-
throw new Meteor.Error(fieldName, "动态必填字段");
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
469
|
checkName(doc._name);
|
|
486
470
|
if(['name','owner','parent','children'].indexOf(doc._name)>-1){
|
|
487
471
|
doc.name = doc._name;
|
|
@@ -492,8 +476,9 @@ var triggers = {
|
|
|
492
476
|
if(doc.name === 'name' || doc.is_name){
|
|
493
477
|
checkNameField({type: doc.type})
|
|
494
478
|
}
|
|
495
|
-
|
|
479
|
+
console.log('insert', doc)
|
|
496
480
|
if (isRepeatedName(doc)) {
|
|
481
|
+
|
|
497
482
|
throw new Meteor.Error(doc.name, "字段名不能重复");
|
|
498
483
|
}
|
|
499
484
|
|
|
@@ -25,6 +25,8 @@ fields:
|
|
|
25
25
|
label: Label
|
|
26
26
|
is_name: true
|
|
27
27
|
sort_no: 120
|
|
28
|
+
amis:
|
|
29
|
+
disabledOn: "${is_system == true}"
|
|
28
30
|
_name:
|
|
29
31
|
type: text
|
|
30
32
|
label: Field Name
|
|
@@ -106,26 +108,6 @@ fields:
|
|
|
106
108
|
amis:
|
|
107
109
|
disabledOn: "${is_system == true}"
|
|
108
110
|
searchable: true
|
|
109
|
-
onEvent:
|
|
110
|
-
change:
|
|
111
|
-
weight: 0
|
|
112
|
-
actions:
|
|
113
|
-
- componentId: 'u:6a556d8a8514'
|
|
114
|
-
args:
|
|
115
|
-
value: '${"lookup"=== type}'
|
|
116
|
-
actionType: visibility
|
|
117
|
-
- componentId: 'u:6a556d8a8514'
|
|
118
|
-
args:
|
|
119
|
-
value: clear
|
|
120
|
-
groupType: component
|
|
121
|
-
actionType: setValue
|
|
122
|
-
expression: '${"lookup"=== type && required!=true}'
|
|
123
|
-
- componentId: 'u:6a556d8a8514'
|
|
124
|
-
args:
|
|
125
|
-
value: retain
|
|
126
|
-
groupType: component
|
|
127
|
-
actionType: setValue
|
|
128
|
-
expression: '${"lookup"=== type && required==true}'
|
|
129
111
|
language:
|
|
130
112
|
type: select
|
|
131
113
|
label: 语言
|
|
@@ -689,12 +671,12 @@ fields:
|
|
|
689
671
|
defaultValue: 100
|
|
690
672
|
scale: 0
|
|
691
673
|
sortable: true
|
|
692
|
-
group:
|
|
674
|
+
group: ui
|
|
693
675
|
sort_no: 370
|
|
694
676
|
is_name:
|
|
695
677
|
type: boolean
|
|
696
678
|
label: Is Name
|
|
697
|
-
group:
|
|
679
|
+
group: External data source
|
|
698
680
|
sort_no: 380
|
|
699
681
|
amis:
|
|
700
682
|
disabledOn: "${is_system == true}"
|
|
@@ -704,18 +686,6 @@ fields:
|
|
|
704
686
|
# group: Advanced
|
|
705
687
|
visible_on: "{{['autonumber','summary','formula'].indexOf(formData.type) > -1 ? false: true}}"
|
|
706
688
|
sort_no: 272
|
|
707
|
-
amis:
|
|
708
|
-
# disabledOn: "${is_system == true}"
|
|
709
|
-
onEvent:
|
|
710
|
-
change:
|
|
711
|
-
weight: 0
|
|
712
|
-
actions:
|
|
713
|
-
- componentId: 'u:6a556d8a8514'
|
|
714
|
-
args:
|
|
715
|
-
value: retain
|
|
716
|
-
groupType: component
|
|
717
|
-
actionType: setValue
|
|
718
|
-
expression: '${"lookup"=== type && required==true}'
|
|
719
689
|
deleted_lookup_record_behavior:
|
|
720
690
|
type: select
|
|
721
691
|
label: 如果相关表记录被删除怎么办?
|
|
@@ -728,27 +698,27 @@ fields:
|
|
|
728
698
|
value: retain
|
|
729
699
|
sort_no: 276
|
|
730
700
|
is_wide: true
|
|
731
|
-
defaultValue: clear
|
|
732
701
|
amis:
|
|
733
|
-
"
|
|
734
|
-
"
|
|
702
|
+
"disabledOn": "${required==true}"
|
|
703
|
+
"value": "${IFS(true===required, \"retain\", !required && !deleted_lookup_record_behavior, \"clear\", deleted_lookup_record_behavior)}"
|
|
735
704
|
is_wide:
|
|
736
705
|
type: boolean
|
|
737
706
|
label: Is Wide
|
|
738
707
|
# group: Advanced
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
708
|
+
sort_no: 274
|
|
709
|
+
group: ui
|
|
710
|
+
readonly:
|
|
711
|
+
type: boolean
|
|
712
|
+
label: Readonly
|
|
713
|
+
group: ui
|
|
714
|
+
hidden:
|
|
715
|
+
type: boolean
|
|
716
|
+
label: Hidden
|
|
717
|
+
group: ui
|
|
747
718
|
# omit:
|
|
748
719
|
# type: boolean
|
|
749
720
|
# label: Omit
|
|
750
721
|
# group: Advanced
|
|
751
|
-
sort_no: 274
|
|
752
722
|
index:
|
|
753
723
|
type: boolean
|
|
754
724
|
label: Is Index Field
|
|
@@ -764,17 +734,17 @@ fields:
|
|
|
764
734
|
sortable:
|
|
765
735
|
type: boolean
|
|
766
736
|
label: Sortable
|
|
767
|
-
group:
|
|
737
|
+
group: ui
|
|
768
738
|
sort_no: 420
|
|
769
739
|
searchable:
|
|
770
740
|
type: boolean
|
|
771
741
|
label: Searchable
|
|
772
|
-
group:
|
|
742
|
+
group: ui
|
|
773
743
|
sort_no: 428
|
|
774
744
|
filterable:
|
|
775
745
|
type: boolean
|
|
776
746
|
label: Filterable
|
|
777
|
-
group:
|
|
747
|
+
group: ui
|
|
778
748
|
sort_no: 430
|
|
779
749
|
show_as_qr:
|
|
780
750
|
type: boolean
|
|
@@ -788,7 +758,7 @@ fields:
|
|
|
788
758
|
type: textarea
|
|
789
759
|
label: Visible On
|
|
790
760
|
is_wide: true
|
|
791
|
-
group:
|
|
761
|
+
group: ui
|
|
792
762
|
sort_no: 450
|
|
793
763
|
inlineHelpText: <a href='https://docs.steedos.com/zh-CN/no-code/customize/fields/field-attributes#%E5%AD%97%E6%AE%B5%E6%98%BE%E7%A4%BA%E5%85%AC%E5%BC%8F' target='_blank'>查看帮助</a>
|
|
794
764
|
inlineHelpText:
|
|
@@ -831,6 +801,8 @@ list_views:
|
|
|
831
801
|
- object
|
|
832
802
|
- sort_no
|
|
833
803
|
- modified
|
|
804
|
+
- hidden
|
|
805
|
+
- readonly
|
|
834
806
|
- is_system
|
|
835
807
|
sort:
|
|
836
808
|
- field_name: sort_no
|
|
@@ -846,6 +818,8 @@ list_views:
|
|
|
846
818
|
- object
|
|
847
819
|
- sort_no
|
|
848
820
|
- modified
|
|
821
|
+
- hidden
|
|
822
|
+
- readonly
|
|
849
823
|
- is_system
|
|
850
824
|
label: 自定义
|
|
851
825
|
filters:
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: baozhoutaon@hotoa.com
|
|
3
|
+
* @Date: 2022-03-29 20:33:44
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-11-19 17:06:18
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
custom: function (object_name, record_id) {
|
|
10
|
+
$(document.body).addClass('loading');
|
|
11
|
+
let url = `/graphql`;
|
|
12
|
+
const obj = Creator.odata.get("objects", record_id);
|
|
13
|
+
delete obj.record_permissions;
|
|
14
|
+
delete obj["@odata.context"]
|
|
15
|
+
delete obj["@odata.editLink"]
|
|
16
|
+
delete obj["@odata.etag"]
|
|
17
|
+
delete obj["@odata.id"]
|
|
18
|
+
delete obj.idFieldName;
|
|
19
|
+
let options = {
|
|
20
|
+
type: 'post',
|
|
21
|
+
async: true,
|
|
22
|
+
data: JSON.stringify({
|
|
23
|
+
query: `mutation{objects__upsert(id: "${obj.name}", doc: ${JSON.stringify(JSON.stringify(obj))}){_id,name}}`
|
|
24
|
+
}),
|
|
25
|
+
success: function (data) {
|
|
26
|
+
console.log(`data====>`, data)
|
|
27
|
+
SteedosUI.notification.success({
|
|
28
|
+
message: '对象已自定义。'
|
|
29
|
+
});
|
|
30
|
+
// SteedosUI.router.go({}, "/app/" + Session.get("app_id") + "/" + object_name + "/view/" + data.data.objects__upsert._id);
|
|
31
|
+
FlowRouter.reload()
|
|
32
|
+
$(document.body).removeClass('loading');
|
|
33
|
+
},
|
|
34
|
+
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
35
|
+
SteedosUI.notification.error({
|
|
36
|
+
message: '操作失败',
|
|
37
|
+
description: t(XMLHttpRequest.responseJSON.error),
|
|
38
|
+
});
|
|
39
|
+
$(document.body).removeClass('loading');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
Steedos.authRequest(url, options);
|
|
43
|
+
},
|
|
44
|
+
customVisible: function (object_name, record_id, permission, data) {
|
|
45
|
+
var record = data && data.record;
|
|
46
|
+
return record && record.is_system && !record.created;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -216,6 +216,16 @@ function loadObject(doc, oldDoc) {
|
|
|
216
216
|
|
|
217
217
|
originalObject.isMain = true;
|
|
218
218
|
|
|
219
|
+
const objConfig = register.getOriginalObjectConfig(doc.name);
|
|
220
|
+
|
|
221
|
+
if(objConfig){
|
|
222
|
+
_.each(objConfig.fields, (config, name)=>{
|
|
223
|
+
if(!config._id && !doc.fields[name]){
|
|
224
|
+
doc.fields[name] = config;
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
|
|
219
229
|
register.addObjectConfig(doc, datasourceName);
|
|
220
230
|
register.loadObjectLazyListViews(doc.name);
|
|
221
231
|
register.loadObjectLazyActions(doc.name);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: yinlianghui@steedos.com
|
|
3
3
|
* @Date: 2022-04-13 10:31:03
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: liaodaxue
|
|
5
|
+
* @LastEditTime: 2023-11-17 15:48:30
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
var objectql = require('@steedos/objectql');
|
|
@@ -11,6 +11,7 @@ async function insertParentAndChildrenFieldForTreeObject(doc, needToCheckExists)
|
|
|
11
11
|
const baseProps = {
|
|
12
12
|
object: doc.name,
|
|
13
13
|
reference_to: doc.name,
|
|
14
|
+
deleted_lookup_record_behavior: "clear",
|
|
14
15
|
type: 'lookup',
|
|
15
16
|
owner: doc.owner,
|
|
16
17
|
space: doc.space,
|
|
@@ -34,25 +34,29 @@
|
|
|
34
34
|
"size": "lg",
|
|
35
35
|
"body": [
|
|
36
36
|
{
|
|
37
|
-
"type": "input-table",
|
|
38
|
-
"
|
|
37
|
+
"type": "steedos-input-table",
|
|
38
|
+
"fields": [
|
|
39
39
|
{
|
|
40
40
|
"name": "group_name",
|
|
41
41
|
"label": "名称",
|
|
42
|
-
"
|
|
42
|
+
"type": "text",
|
|
43
|
+
"id": "u:31952daa443c"
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
"name": "visible_on",
|
|
46
47
|
"label": "显示条件",
|
|
47
|
-
"
|
|
48
|
+
"type": "text",
|
|
49
|
+
"id": "u:8d7551abcd28",
|
|
50
|
+
"value": null
|
|
48
51
|
}
|
|
49
52
|
],
|
|
50
|
-
"
|
|
51
|
-
"name": "setting_groups",
|
|
53
|
+
"name": "groups",
|
|
52
54
|
"addable": true,
|
|
53
55
|
"editable": true,
|
|
54
56
|
"removable": true,
|
|
55
|
-
"
|
|
57
|
+
"draggable": false,
|
|
58
|
+
"showIndex": false,
|
|
59
|
+
"id": "u:776ec89804c0"
|
|
56
60
|
}
|
|
57
61
|
],
|
|
58
62
|
"onEvent": {
|
|
@@ -60,7 +64,7 @@
|
|
|
60
64
|
"actions": [
|
|
61
65
|
{
|
|
62
66
|
"actionType": "custom",
|
|
63
|
-
"script": "
|
|
67
|
+
"script": "debugger;//整理分组数据\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});"
|
|
64
68
|
}
|
|
65
69
|
]
|
|
66
70
|
}
|
|
@@ -136,7 +140,7 @@
|
|
|
136
140
|
"label": "保存",
|
|
137
141
|
"actionType": "submit",
|
|
138
142
|
"id": "u:d9039421ea6b",
|
|
139
|
-
"target": "
|
|
143
|
+
"target": "form_field_design",
|
|
140
144
|
"level": "primary"
|
|
141
145
|
}
|
|
142
146
|
]
|
|
@@ -178,39 +182,86 @@
|
|
|
178
182
|
{
|
|
179
183
|
"type": "tpl",
|
|
180
184
|
"tpl": "<p><strong>${label}</strong> ${designObjectLabel}<span style=\"color: rgb(149, 165, 166);\">${_name}</span></p>",
|
|
181
|
-
"className": "w-4/5",
|
|
182
|
-
"inline": true
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
"className": "w-4/5 field-amplify",
|
|
186
|
+
"inline": true,
|
|
187
|
+
"onEvent": {
|
|
188
|
+
"click": {
|
|
189
|
+
"actions": [
|
|
190
|
+
{
|
|
191
|
+
"actionType": "dialog",
|
|
192
|
+
"dialog": {
|
|
193
|
+
"type": "dialog",
|
|
194
|
+
"title": "编辑字段",
|
|
195
|
+
"data": {
|
|
196
|
+
"appId": "${appId}",
|
|
197
|
+
"global": "${global}",
|
|
198
|
+
"context": "${context}",
|
|
199
|
+
"designObjectName": "${designObjectName}",
|
|
200
|
+
"_master": "${_master}",
|
|
201
|
+
"_id": "${_id}"
|
|
202
|
+
},
|
|
203
|
+
"body": [
|
|
204
|
+
{
|
|
205
|
+
"type": "steedos-object-form",
|
|
206
|
+
"label": "对象表单",
|
|
207
|
+
"objectApiName": "object_fields",
|
|
208
|
+
"recordId": "${_id}",
|
|
209
|
+
"mode": "edit",
|
|
210
|
+
"defaultData": {
|
|
211
|
+
"name": "",
|
|
212
|
+
"shared": false,
|
|
213
|
+
"object": "${designObjectName}"
|
|
214
|
+
},
|
|
215
|
+
"fields": [
|
|
216
|
+
"label",
|
|
217
|
+
"readonly",
|
|
218
|
+
"is_wide"
|
|
219
|
+
],
|
|
220
|
+
"fieldsExtend": {
|
|
221
|
+
"label": {
|
|
222
|
+
"is_wide": true,
|
|
223
|
+
"group": ""
|
|
224
|
+
},
|
|
225
|
+
"readonly": {
|
|
226
|
+
"group": ""
|
|
227
|
+
},
|
|
228
|
+
"is_wide": {
|
|
229
|
+
"group": ""
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"id": "u:b71796d3cb8c",
|
|
233
|
+
"className": "mb-4",
|
|
234
|
+
"apiRequestAdaptor": "api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
|
|
235
|
+
"onEvent": {
|
|
236
|
+
"submitSucc": {
|
|
237
|
+
"weight": 0,
|
|
238
|
+
"actions": [
|
|
239
|
+
{
|
|
240
|
+
"actionType": "custom",
|
|
241
|
+
"script": "setTimeout(() => {\n doAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@data.changed.object_fields\"\n }\n });\n}, 500);\n\n\n"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"showCloseButton": true,
|
|
249
|
+
"showErrorMsg": true,
|
|
250
|
+
"showLoading": true,
|
|
251
|
+
"closeOnEsc": false,
|
|
252
|
+
"dataMapSwitch": false,
|
|
253
|
+
"size": "md",
|
|
254
|
+
"id": "u:066b3884bdd8"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]
|
|
200
258
|
}
|
|
201
|
-
|
|
202
|
-
"placement": "bottomRight",
|
|
203
|
-
"overlayClassName": "shadow !min-w-[160px]",
|
|
204
|
-
"trigger": [
|
|
205
|
-
"click"
|
|
206
|
-
],
|
|
207
|
-
"id": "u:c2140a365019",
|
|
208
|
-
"mode": "edit",
|
|
209
|
-
"className": "mr-7 w-fit h-fit opacity-0"
|
|
259
|
+
}
|
|
210
260
|
}
|
|
211
261
|
],
|
|
212
262
|
"bodyClassName": "h-7 flex justify-between items-center p-0 pl-10 my-2",
|
|
213
|
-
"toolbar": [
|
|
263
|
+
"toolbar": [
|
|
264
|
+
],
|
|
214
265
|
"className": "mb-0 border-0 bg-none card",
|
|
215
266
|
"id": "u:296298da1bef"
|
|
216
267
|
},
|
|
@@ -237,7 +288,7 @@
|
|
|
237
288
|
"headers": {
|
|
238
289
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
239
290
|
},
|
|
240
|
-
"requestAdaptor": "var graphqlOrder = \"\";\n//根据groups
|
|
291
|
+
"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 let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify({ sort_no: index * 10, group, hidden: key == \"隐藏\" ? true : false })) + '){_id}\\n';\n if (field.id == field._id && field.is_system) {\n itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify({ object: api.data.$self.designObjectName,type:field.type, _name: field._name, label: field.label, sort_no: index * 10, group, hidden: key == \"隐藏\" ? true : false, is_system: field.is_system })) + '){_id}\\n';\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}",
|
|
241
292
|
"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;",
|
|
242
293
|
"messages": {
|
|
243
294
|
},
|
|
@@ -250,7 +301,18 @@
|
|
|
250
301
|
},
|
|
251
302
|
"visibleOn": "${dataInitialed}",
|
|
252
303
|
"wrapWithPanel": false,
|
|
253
|
-
"name": "
|
|
304
|
+
"name": "form_field_design",
|
|
305
|
+
"onEvent": {
|
|
306
|
+
"submitSucc": {
|
|
307
|
+
"weight": 0,
|
|
308
|
+
"actions": [
|
|
309
|
+
{
|
|
310
|
+
"actionType": "custom",
|
|
311
|
+
"script": "setTimeout(() => {\n doAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@data.changed.object_fields\"\n }\n });\n}, 500);\n\n\n"
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
}
|
|
254
316
|
}
|
|
255
317
|
],
|
|
256
318
|
"className": "Panel--default max-w-4xl m-auto",
|
|
@@ -261,7 +323,7 @@
|
|
|
261
323
|
"method": "post",
|
|
262
324
|
"url": "${context.rootUrl}/graphql?designObjectId=${designObjectId}",
|
|
263
325
|
"data": {
|
|
264
|
-
"query": "{fields:object_fields(filters: [[\"object\",\"=\",\"${designObjectName}\"]],sort: \"sort_no asc\"){_id,label,_name,group,type,sort_no,modified,is_wide,is_system,recordPermissions: _permissions{allowEdit}}}",
|
|
326
|
+
"query": "{fields:object_fields(filters: [[\"object\",\"=\",\"${designObjectName}\"]],sort: \"sort_no asc\"){_id,label,_name,group,type,sort_no,modified,is_wide,is_system,hidden,recordPermissions: _permissions{allowEdit}}}",
|
|
265
327
|
"field_groups": "${field_groups}",
|
|
266
328
|
"dataInitialed": "${dataInitialed}",
|
|
267
329
|
"designObjectName": "${designObjectName}",
|
|
@@ -274,7 +336,7 @@
|
|
|
274
336
|
"messages": {
|
|
275
337
|
},
|
|
276
338
|
"requestAdaptor": "",
|
|
277
|
-
"adaptor": "//筛选出可编辑的字段\r\
|
|
339
|
+
"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) {\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 }\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};",
|
|
278
340
|
"sendOn": "!!this.designObjectId"
|
|
279
341
|
},
|
|
280
342
|
"messages": {
|
|
@@ -284,7 +346,7 @@
|
|
|
284
346
|
"actions": [
|
|
285
347
|
{
|
|
286
348
|
"actionType": "custom",
|
|
287
|
-
"script": "
|
|
349
|
+
"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",
|
|
288
350
|
"expression": "${event.data.fieldUpdateData}"
|
|
289
351
|
}
|
|
290
352
|
]
|
|
@@ -309,7 +371,7 @@
|
|
|
309
371
|
"messages": {
|
|
310
372
|
},
|
|
311
373
|
"requestAdaptor": "",
|
|
312
|
-
"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_default: true\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}"
|
|
374
|
+
"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}"
|
|
313
375
|
},
|
|
314
376
|
"messages": {
|
|
315
377
|
},
|
|
@@ -341,12 +403,16 @@
|
|
|
341
403
|
},
|
|
342
404
|
"id": "u:993ee4316643",
|
|
343
405
|
"css": {
|
|
344
|
-
".steedos-design-field li.p-1:hover .opacity-0": {
|
|
345
|
-
"opacity": "0.99"
|
|
346
|
-
},
|
|
347
406
|
".antd-TplField p": {
|
|
348
407
|
"margin": "0.625rem 0.625rem"
|
|
408
|
+
},
|
|
409
|
+
".steedos-design-field li.p-1 .field-amplify:hover": {
|
|
410
|
+
"font-size": "17px"
|
|
349
411
|
}
|
|
350
412
|
},
|
|
351
|
-
"className": "steedos-design-field"
|
|
413
|
+
"className": "steedos-design-field",
|
|
414
|
+
"asideResizor": false,
|
|
415
|
+
"pullRefresh": {
|
|
416
|
+
"disabled": true
|
|
417
|
+
}
|
|
352
418
|
}
|
|
@@ -125,18 +125,18 @@
|
|
|
125
125
|
]
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
|
-
"title": "${'
|
|
128
|
+
"title": "${'objects_amis_object_workflows' | t}",
|
|
129
|
+
"hiddenOn": "${_master.record.enable_workflow != true}",
|
|
129
130
|
"body": [
|
|
130
131
|
{
|
|
131
132
|
"type": "steedos-object-related-listview",
|
|
132
133
|
"objectApiName": "objects",
|
|
133
134
|
"recordId": "${recordId}",
|
|
134
135
|
"relatedObjectApiName": "object_workflows",
|
|
135
|
-
"
|
|
136
|
-
"
|
|
136
|
+
"relatedKey": "object_name",
|
|
137
|
+
"perPage": 20
|
|
137
138
|
}
|
|
138
|
-
]
|
|
139
|
-
"id": "u:cbc13e1a7033"
|
|
139
|
+
]
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
"title": "${'objects_amis_validation_rule' | t}",
|
|
@@ -175,20 +175,6 @@
|
|
|
175
175
|
"perPage": 20
|
|
176
176
|
}
|
|
177
177
|
]
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"title": "${'objects_amis_object_workflows' | t}",
|
|
181
|
-
"hiddenOn": "${_master.record.enable_workflow != true}",
|
|
182
|
-
"body": [
|
|
183
|
-
{
|
|
184
|
-
"type": "steedos-object-related-listview",
|
|
185
|
-
"objectApiName": "objects",
|
|
186
|
-
"recordId": "${recordId}",
|
|
187
|
-
"relatedObjectApiName": "object_workflows",
|
|
188
|
-
"relatedKey": "object_name",
|
|
189
|
-
"perPage": 20
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
178
|
}
|
|
193
179
|
],
|
|
194
180
|
"id": "u:6a3b45d7adcf",
|
|
@@ -226,7 +226,11 @@ module.exports = {
|
|
|
226
226
|
let fields = await InternalData.getObjectFields(objectName, this.userId, filters.name ? true : false);
|
|
227
227
|
if(fields){
|
|
228
228
|
_.each(fields, (field)=>{
|
|
229
|
-
this.data.values
|
|
229
|
+
if(!_.find(this.data.values, (item)=>{
|
|
230
|
+
return item.object == field.object && item.name == field.name
|
|
231
|
+
})){
|
|
232
|
+
this.data.values.push(Object.assign({_id: `${objectName}.${field.name}`}, field))
|
|
233
|
+
}
|
|
230
234
|
})
|
|
231
235
|
// this.data.values = this.data.values.concat(fields)
|
|
232
236
|
this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, this.spaceId);
|
|
@@ -255,6 +259,9 @@ module.exports = {
|
|
|
255
259
|
if(query.fields && _.isArray(query.fields) && !_.include(query.fields, 'name')){
|
|
256
260
|
query.fields.push('name')
|
|
257
261
|
}
|
|
262
|
+
if(query.fields && _.isArray(query.fields) && !_.include(query.fields, 'type')){
|
|
263
|
+
query.fields.push('type')
|
|
264
|
+
}
|
|
258
265
|
},
|
|
259
266
|
beforeAggregate: async function(){
|
|
260
267
|
const { query } = this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.5.20-beta.
|
|
3
|
+
"version": "2.5.20-beta.21",
|
|
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": "
|
|
18
|
+
"gitHead": "3c111fed5abe090d3721bd5b2f72fa746a2fd692"
|
|
19
19
|
}
|
package/package.service.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 1985-10-26 16:15:00
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime: 2023-11-10
|
|
4
|
+
* @LastEditors: 孙浩林 sunhaolin@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-11-30 10:13:13
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
@@ -114,7 +114,8 @@ module.exports = {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
if(data.is_system){
|
|
117
|
-
|
|
117
|
+
// 'label' 先禁止编辑label , 目前由于i18n的问题导致 label无效.
|
|
118
|
+
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']);
|
|
118
119
|
}
|
|
119
120
|
return object.update(id, data, userSession)
|
|
120
121
|
},
|