@steedos/standard-object-database 2.5.17 → 2.5.18-beta.1
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_listviews.en/object_listviews.en.objectTranslation.yml +2 -0
- package/main/default/objectTranslations/object_listviews.zh-CN/object_listviews.zh-CN.objectTranslation.yml +2 -0
- package/main/default/objects/object_actions.object.yml +1 -1
- package/main/default/objects/object_fields.object.js +3 -2
- package/main/default/objects/object_fields.object.yml +55 -2
- package/main/default/objects/object_listviews.object.yml +5 -0
- package/main/default/objects/objects.action.js +25 -2
- package/main/default/objects/objects.object.js +1 -1
- package/main/default/objects/objects.object.yml +25 -0
- package/main/default/pages/design_field_layout.page.amis.json +339 -0
- package/main/default/pages/design_field_layout.page.yml +7 -0
- package/main/default/pages/object_fields_form.page.amis.json +9 -0
- package/main/default/pages/object_form.page.amis.json +31 -0
- package/main/default/pages/object_form.page.yml +12 -0
- package/main/default/triggers/object_fields.trigger.js +6 -6
- package/main/default/triggers/objects.trigger.js +4 -26
- package/package.json +2 -2
- package/package.service.js +93 -3
|
@@ -238,7 +238,7 @@ function checkMasterDetailTypeField(doc, oldReferenceTo) {
|
|
|
238
238
|
|
|
239
239
|
function onChangeName(oldName, newDoc){
|
|
240
240
|
var newName = newDoc.name
|
|
241
|
-
Creator.getCollection("object_listviews").direct.find({space: newDoc.space, object_name: newDoc.object}, {fields: {_id:1, columns: 1}}).forEach(function(view){
|
|
241
|
+
Creator.getCollection("object_listviews").direct.find({space: newDoc.space, object_name: newDoc.object}, {fields: {_id:1, columns: 1, name: 1}}).forEach(function(view){
|
|
242
242
|
if(_.isArray(view.columns)){
|
|
243
243
|
var columns = [];
|
|
244
244
|
_.each(view.columns, function(column){
|
|
@@ -258,7 +258,8 @@ function onChangeName(oldName, newDoc){
|
|
|
258
258
|
columns.push(column)
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
|
|
261
|
+
// 由于 https://github.com/steedos/steedos-platform/issues/4655 改动, 修改列表视图的时候, 必须要传入name, 否则会报错
|
|
262
|
+
Creator.getCollection("object_listviews").update({_id: view._id}, {$set: {name: view.name, columns: columns}});
|
|
262
263
|
}
|
|
263
264
|
})
|
|
264
265
|
}
|
|
@@ -31,6 +31,8 @@ fields:
|
|
|
31
31
|
required: true
|
|
32
32
|
visible_on: "{{global.mode !='read' ? true : false}}"
|
|
33
33
|
sort_no: 130
|
|
34
|
+
amis:
|
|
35
|
+
disabledOn: "${is_system == true}"
|
|
34
36
|
name:
|
|
35
37
|
type: text
|
|
36
38
|
label: API Name
|
|
@@ -41,6 +43,8 @@ fields:
|
|
|
41
43
|
readonly: true
|
|
42
44
|
visible_on: "{{global.mode !='read' ? false : true}}"
|
|
43
45
|
sort_no: 140
|
|
46
|
+
amis:
|
|
47
|
+
disabledOn: "${is_system == true}"
|
|
44
48
|
type:
|
|
45
49
|
type: select
|
|
46
50
|
label: Type
|
|
@@ -98,6 +102,7 @@ fields:
|
|
|
98
102
|
value: summary
|
|
99
103
|
sort_no: 150
|
|
100
104
|
amis:
|
|
105
|
+
disabledOn: "${is_system == true}"
|
|
101
106
|
onEvent:
|
|
102
107
|
change:
|
|
103
108
|
weight: 0
|
|
@@ -204,6 +209,8 @@ fields:
|
|
|
204
209
|
value: yaml
|
|
205
210
|
sort_no: 155
|
|
206
211
|
visible_on: "{{['code'].indexOf(formData.type) > -1 ? true: false}}"
|
|
212
|
+
amis:
|
|
213
|
+
disabledOn: "${is_system == true}"
|
|
207
214
|
defaultValue:
|
|
208
215
|
type: text
|
|
209
216
|
label: Default Value
|
|
@@ -218,6 +225,8 @@ fields:
|
|
|
218
225
|
sort_no: 175
|
|
219
226
|
defaultValue: bd09
|
|
220
227
|
visible_on: "{{['location'].indexOf(formData.type) > -1 ? true: false}}"
|
|
228
|
+
amis:
|
|
229
|
+
disabledOn: "${is_system == true}"
|
|
221
230
|
reference_to:
|
|
222
231
|
type: lookup
|
|
223
232
|
label: Reference to
|
|
@@ -228,6 +237,7 @@ fields:
|
|
|
228
237
|
sort_no: 180
|
|
229
238
|
amis:
|
|
230
239
|
menuTpl: "<div>${label}(${value})</div>"
|
|
240
|
+
disabledOn: "${is_system == true}"
|
|
231
241
|
depend_on:
|
|
232
242
|
type: lookup
|
|
233
243
|
group: Advanced
|
|
@@ -248,12 +258,16 @@ fields:
|
|
|
248
258
|
}
|
|
249
259
|
}
|
|
250
260
|
sort_no: 445
|
|
261
|
+
amis:
|
|
262
|
+
disabledOn: "${is_system == true}"
|
|
251
263
|
create:
|
|
252
264
|
type: boolean
|
|
253
265
|
label: 是否显示新建按钮
|
|
254
266
|
defaultValue: true
|
|
255
267
|
visible_on: "{{['lookup'].indexOf(formData.type) > -1 ? true: false}}"
|
|
256
268
|
sort_no: 185
|
|
269
|
+
amis:
|
|
270
|
+
disabledOn: "${is_system == true}"
|
|
257
271
|
reference_to_field:
|
|
258
272
|
type: lookup
|
|
259
273
|
group: Advanced
|
|
@@ -274,18 +288,24 @@ fields:
|
|
|
274
288
|
}
|
|
275
289
|
}
|
|
276
290
|
sort_no: 440
|
|
291
|
+
amis:
|
|
292
|
+
disabledOn: "${is_system == true}"
|
|
277
293
|
multiple:
|
|
278
294
|
type: boolean
|
|
279
295
|
label: Multiple
|
|
280
296
|
inlineHelpText: Single choice and multiple choice switch to each other. Please resubmit the existing records or modify the saving format of this field in the database.
|
|
281
297
|
visible_on: "{{['select', 'lookup', 'image','file'].indexOf(formData.type) > -1 ? true: false}}"
|
|
282
298
|
sort_no: 190
|
|
299
|
+
amis:
|
|
300
|
+
disabledOn: "${is_system == true}"
|
|
283
301
|
write_requires_master_read:
|
|
284
302
|
label: Write requires master read
|
|
285
303
|
type: boolean
|
|
286
304
|
inlineHelpText: Sets the minimum sharing access level required on the master record to create, edit, or delete child records. This field applies only to master-detail or junction object custom field types. true—Allows users with “Read” access to the master record permission to create, edit, or delete child records. This setting makes sharing less restrictive. false—Allows users with “Read/Write” access to the master record permission to create, edit, or delete child records. This setting is more restrictive than true, and is the default value.
|
|
287
305
|
visible_on: "{{formData.type === 'master_detail' ? true: false}}"
|
|
288
306
|
sort_no: 200
|
|
307
|
+
amis:
|
|
308
|
+
disabledOn: "${is_system == true}"
|
|
289
309
|
formula:
|
|
290
310
|
label: Formula
|
|
291
311
|
type: textarea
|
|
@@ -294,6 +314,8 @@ fields:
|
|
|
294
314
|
visible_on: "{{['autonumber', 'formula'].indexOf(formData.type) > -1 ? true: false}}"
|
|
295
315
|
required: "{{['autonumber', 'formula'].indexOf(formData.type) > -1 ? true: false}}"
|
|
296
316
|
sort_no: 210
|
|
317
|
+
amis:
|
|
318
|
+
disabledOn: "${is_system == true}"
|
|
297
319
|
data_type:
|
|
298
320
|
type: lookup
|
|
299
321
|
label: Data Type
|
|
@@ -308,6 +330,8 @@ fields:
|
|
|
308
330
|
visible_on: "{{['formula','select'].indexOf(formData.type) > -1 ? true: false}}"
|
|
309
331
|
required: "{{['formula'].indexOf(formData.type) > -1 ? true: false}}"
|
|
310
332
|
sort_no: 220
|
|
333
|
+
amis:
|
|
334
|
+
disabledOn: "${is_system == true}"
|
|
311
335
|
filtersFunction:
|
|
312
336
|
label: filters Function
|
|
313
337
|
type: code
|
|
@@ -317,6 +341,7 @@ fields:
|
|
|
317
341
|
sort_no: 448
|
|
318
342
|
group: Advanced
|
|
319
343
|
amis:
|
|
344
|
+
disabledOn: "${is_system == true}"
|
|
320
345
|
placeholder: |-
|
|
321
346
|
function(filters, values){
|
|
322
347
|
|
|
@@ -333,6 +358,7 @@ fields:
|
|
|
333
358
|
scale: 0
|
|
334
359
|
amis:
|
|
335
360
|
value: 18
|
|
361
|
+
disabledOn: "${is_system == true}"
|
|
336
362
|
# defaultValue: 18
|
|
337
363
|
visible_on: "{{
|
|
338
364
|
(function(){
|
|
@@ -372,6 +398,7 @@ fields:
|
|
|
372
398
|
# defaultValue: 2
|
|
373
399
|
amis:
|
|
374
400
|
value: 2
|
|
401
|
+
disabledOn: "${is_system == true}"
|
|
375
402
|
min: 0
|
|
376
403
|
inlineHelpText: If the field type is a Percent, this indicates the number of decimal places the field will display, for example, two decimal places will display as 10.20%.
|
|
377
404
|
visible_on: "{{
|
|
@@ -426,6 +453,8 @@ fields:
|
|
|
426
453
|
visible_on: "{{formData.type === 'select' ? true: false}}"
|
|
427
454
|
required: "{{formData.type === 'select' ? true: false}}"
|
|
428
455
|
sort_no: 280
|
|
456
|
+
amis:
|
|
457
|
+
disabledOn: "${is_system == true}"
|
|
429
458
|
options.$:
|
|
430
459
|
label: Options
|
|
431
460
|
blackbox: true
|
|
@@ -459,6 +488,8 @@ fields:
|
|
|
459
488
|
visible_on: "{{['formula'].indexOf(formData.type) > -1 ? true: false}}"
|
|
460
489
|
required: "{{['formula'].indexOf(formData.type) > -1 ? true: false}}"
|
|
461
490
|
sort_no: 290
|
|
491
|
+
amis:
|
|
492
|
+
disabledOn: "${is_system == true}"
|
|
462
493
|
summary_object:
|
|
463
494
|
type: lookup
|
|
464
495
|
label: Object to Summarize
|
|
@@ -468,6 +499,7 @@ fields:
|
|
|
468
499
|
depend_on:
|
|
469
500
|
- object
|
|
470
501
|
amis:
|
|
502
|
+
disabledOn: "${is_system == true}"
|
|
471
503
|
"source":
|
|
472
504
|
"method": "get"
|
|
473
505
|
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object}/detailLists/options?depend_on_object=${object}"
|
|
@@ -532,6 +564,8 @@ fields:
|
|
|
532
564
|
visible_on: "{{formData.type === 'summary' ? true: false}}"
|
|
533
565
|
required: "{{formData.type === 'summary' ? true: false}}"
|
|
534
566
|
sort_no: 310
|
|
567
|
+
amis:
|
|
568
|
+
disabledOn: "${is_system == true}"
|
|
535
569
|
summary_field:
|
|
536
570
|
type: lookup
|
|
537
571
|
label: Field to Aggregate
|
|
@@ -543,6 +577,7 @@ fields:
|
|
|
543
577
|
- summary_type
|
|
544
578
|
defaultIcon: service_contract
|
|
545
579
|
amis:
|
|
580
|
+
disabledOn: "${is_system == true}"
|
|
546
581
|
"autoComplete":
|
|
547
582
|
"method": "get"
|
|
548
583
|
"url": "${context.rootUrl}/service/api/@${summary_object}/uiSchema?summary_object=${summary_object}&summary_type=${summary_type}&term=${term}"
|
|
@@ -564,6 +599,8 @@ fields:
|
|
|
564
599
|
- summary_object
|
|
565
600
|
visible_on: "{{formData.type === 'summary' && global.mode !='read' ? true: false}}"
|
|
566
601
|
sort_no: 330
|
|
602
|
+
amis:
|
|
603
|
+
disabledOn: "${is_system == true}"
|
|
567
604
|
summary_filters.$:
|
|
568
605
|
label: Filter Criteria
|
|
569
606
|
blackbox: true
|
|
@@ -624,18 +661,24 @@ fields:
|
|
|
624
661
|
group: External data source
|
|
625
662
|
# visible_on: "{{true}}"
|
|
626
663
|
sort_no: 340
|
|
664
|
+
amis:
|
|
665
|
+
disabledOn: "${is_system == true}"
|
|
627
666
|
primary:
|
|
628
667
|
type: boolean
|
|
629
668
|
label: Primary Key
|
|
630
669
|
group: External data source
|
|
631
670
|
# visible_on: "{{true}}"
|
|
632
671
|
sort_no: 350
|
|
672
|
+
amis:
|
|
673
|
+
disabledOn: "${is_system == true}"
|
|
633
674
|
generated:
|
|
634
675
|
type: boolean
|
|
635
676
|
label: Generated
|
|
636
677
|
group: External data source
|
|
637
678
|
# visible_on: "{{formData.database_name || formData.datasource ? true: false}}"
|
|
638
679
|
sort_no: 360
|
|
680
|
+
amis:
|
|
681
|
+
disabledOn: "${is_system == true}"
|
|
639
682
|
sort_no:
|
|
640
683
|
label: Sort Number
|
|
641
684
|
type: number
|
|
@@ -649,6 +692,8 @@ fields:
|
|
|
649
692
|
label: Is Name
|
|
650
693
|
group: Advanced
|
|
651
694
|
sort_no: 380
|
|
695
|
+
amis:
|
|
696
|
+
disabledOn: "${is_system == true}"
|
|
652
697
|
required:
|
|
653
698
|
type: boolean
|
|
654
699
|
label: Required
|
|
@@ -656,6 +701,7 @@ fields:
|
|
|
656
701
|
visible_on: "{{['autonumber','summary','formula'].indexOf(formData.type) > -1 ? false: true}}"
|
|
657
702
|
sort_no: 272
|
|
658
703
|
amis:
|
|
704
|
+
disabledOn: "${is_system == true}"
|
|
659
705
|
onEvent:
|
|
660
706
|
change:
|
|
661
707
|
weight: 0
|
|
@@ -681,7 +727,7 @@ fields:
|
|
|
681
727
|
defaultValue: clear
|
|
682
728
|
amis:
|
|
683
729
|
"id": "u:6a556d8a8514"
|
|
684
|
-
"disabledOn": "${required==true}"
|
|
730
|
+
"disabledOn": "${required==true || is_system == true}"
|
|
685
731
|
is_wide:
|
|
686
732
|
type: boolean
|
|
687
733
|
label: Is Wide
|
|
@@ -725,6 +771,8 @@ fields:
|
|
|
725
771
|
# group: Advanced
|
|
726
772
|
visible_on: "{{formData.type === 'url' ? true: false}}"
|
|
727
773
|
sort_no: 440
|
|
774
|
+
amis:
|
|
775
|
+
disabledOn: "${is_system == true}"
|
|
728
776
|
visible_on:
|
|
729
777
|
type: textarea
|
|
730
778
|
label: Visible On
|
|
@@ -752,6 +800,10 @@ fields:
|
|
|
752
800
|
group: Advanced
|
|
753
801
|
sort_no: 455
|
|
754
802
|
inlineHelpText: <a href='https://docs.steedos.com/zh-CN/no-code/customize/fields/field-attributes/#amis-%E5%B1%9E%E6%80%A7' target='_blank'>查看帮助</a>
|
|
803
|
+
is_system:
|
|
804
|
+
type: boolean
|
|
805
|
+
label: System
|
|
806
|
+
visible_on: "{{false}}"
|
|
755
807
|
paging:
|
|
756
808
|
enabled: false
|
|
757
809
|
list_views:
|
|
@@ -809,7 +861,8 @@ relatedList:
|
|
|
809
861
|
form:
|
|
810
862
|
initialValues: !!js/function |
|
|
811
863
|
function(){
|
|
812
|
-
|
|
864
|
+
//应用程序微页面内Session.get("record_id")获取不到值(比如设计字段布局微页面)
|
|
865
|
+
var object = Creator.odata.get('objects', Session.get("record_id") || (this.master && this.master.recordId), "fields_serial_number");
|
|
813
866
|
if(object){
|
|
814
867
|
let fields_serial_number = object.fields_serial_number
|
|
815
868
|
if(!fields_serial_number || fields_serial_number < 100){
|
|
@@ -225,6 +225,10 @@ fields:
|
|
|
225
225
|
type: number
|
|
226
226
|
scale: 0
|
|
227
227
|
defaultValue: 100
|
|
228
|
+
is_enable:
|
|
229
|
+
type: boolean
|
|
230
|
+
label: Enable
|
|
231
|
+
defaultValue: true
|
|
228
232
|
crud_mode:
|
|
229
233
|
label: 显示模式
|
|
230
234
|
type: select
|
|
@@ -277,6 +281,7 @@ list_views:
|
|
|
277
281
|
- shared
|
|
278
282
|
- owner
|
|
279
283
|
- modified
|
|
284
|
+
- is_enable
|
|
280
285
|
- is_system
|
|
281
286
|
label: All List Views
|
|
282
287
|
filter_scope: space
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
design_field_layout: function (object_name, record_id, item_element) {
|
|
3
|
+
var record = this.record || Creator.getObjectById(record_id);
|
|
4
|
+
if (record && record.record) {
|
|
5
|
+
record = record.record;
|
|
6
|
+
}
|
|
7
|
+
if (!record) {
|
|
8
|
+
return toastr.error("未找到记录");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
window.open(Creator.getRelativeUrl("/api/page/view/design_field_layout?designObjectName=" + record.name));
|
|
12
|
+
},
|
|
13
|
+
design_field_layoutVisible: function (object_name, record_id, record_permissions, data) {
|
|
14
|
+
var record = data && data.record;
|
|
15
|
+
if (!Creator.isSpaceAdmin()) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
if (!record) {
|
|
19
|
+
record = Creator.odata.get("objects", record_id, "is_deleted");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (record && !record.is_deleted && record.name != 'users' && !record.is_system) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
2
26
|
show_object: function (object_name, record_id, item_element) {
|
|
3
27
|
var record = this.record || Creator.getObjectById(record_id);
|
|
4
28
|
if(record && record.record){
|
|
@@ -21,8 +45,7 @@ module.exports = {
|
|
|
21
45
|
return toastr.warning("请先启动数据源");
|
|
22
46
|
}
|
|
23
47
|
}
|
|
24
|
-
|
|
25
|
-
window.open(Creator.getRelativeUrl("/app/admin/" + record.name));
|
|
48
|
+
window.open(Creator.getRelativeUrl("/app/admin/" + (record.name || this.record.name)));
|
|
26
49
|
// SteedosUI.Object.getUISchema(record.name).then((res)=>{
|
|
27
50
|
// if(res.idFieldName){
|
|
28
51
|
// window.open(Creator.getRelativeUrl("/app/-/" + record.name));
|
|
@@ -233,7 +233,7 @@ function onChangeObjectName(oldName, newDoc){
|
|
|
233
233
|
multi: true
|
|
234
234
|
});
|
|
235
235
|
//修改trigger
|
|
236
|
-
Creator.getCollection("object_triggers").direct.update({space: newDoc.space,
|
|
236
|
+
Creator.getCollection("object_triggers").direct.update({space: newDoc.space, listenTo: oldName}, {$set: {listenTo: newDoc.name}}, {
|
|
237
237
|
multi: true
|
|
238
238
|
});
|
|
239
239
|
//字段表中的reference_to
|
|
@@ -23,6 +23,8 @@ fields:
|
|
|
23
23
|
# return options;
|
|
24
24
|
# }
|
|
25
25
|
defaultValue: 'default'
|
|
26
|
+
amis:
|
|
27
|
+
disabledOn: "${is_system == true}"
|
|
26
28
|
label:
|
|
27
29
|
type: text
|
|
28
30
|
label: Label
|
|
@@ -38,6 +40,8 @@ fields:
|
|
|
38
40
|
index: true
|
|
39
41
|
required: true
|
|
40
42
|
inlineHelpText: Can only contain lowercase letters and numbers, must start with a letter, cannot end with an underscore character or contain two consecutive underscore characters
|
|
43
|
+
amis:
|
|
44
|
+
disabledOn: "${is_system == true}"
|
|
41
45
|
icon:
|
|
42
46
|
type: lookup
|
|
43
47
|
label: Icon
|
|
@@ -60,6 +64,8 @@ fields:
|
|
|
60
64
|
label: Enable
|
|
61
65
|
type: boolean
|
|
62
66
|
defaultValue: true
|
|
67
|
+
amis:
|
|
68
|
+
disabledOn: "${is_system == true}"
|
|
63
69
|
in_development:
|
|
64
70
|
type: select
|
|
65
71
|
label: Development State
|
|
@@ -71,6 +77,8 @@ fields:
|
|
|
71
77
|
value: "0"
|
|
72
78
|
defaultValue: "1"
|
|
73
79
|
required: true
|
|
80
|
+
amis:
|
|
81
|
+
disabledOn: "${is_system == true}"
|
|
74
82
|
enable_search:
|
|
75
83
|
type: boolean
|
|
76
84
|
label: Enable Search
|
|
@@ -171,6 +179,8 @@ fields:
|
|
|
171
179
|
searchable: true
|
|
172
180
|
inlineHelpText: The default data source does not support this property
|
|
173
181
|
group: External data source
|
|
182
|
+
amis:
|
|
183
|
+
disabledOn: "${is_system == true}"
|
|
174
184
|
version:
|
|
175
185
|
readonly: true
|
|
176
186
|
label: Version
|
|
@@ -372,6 +382,18 @@ fields:
|
|
|
372
382
|
rows: 3
|
|
373
383
|
is_wide: true
|
|
374
384
|
hidden: true
|
|
385
|
+
field_groups:
|
|
386
|
+
type: grid
|
|
387
|
+
blackbox: true
|
|
388
|
+
is_wide: true
|
|
389
|
+
hidden: false
|
|
390
|
+
field_groups.$.group_name:
|
|
391
|
+
type: text
|
|
392
|
+
field_groups.$.visible_on:
|
|
393
|
+
type: text
|
|
394
|
+
extend:
|
|
395
|
+
type: text
|
|
396
|
+
hidden: true
|
|
375
397
|
paging:
|
|
376
398
|
enabled: false
|
|
377
399
|
relatedList:
|
|
@@ -493,6 +515,9 @@ actions:
|
|
|
493
515
|
delete_object:
|
|
494
516
|
on: record_more
|
|
495
517
|
label: 删除
|
|
518
|
+
design_field_layout:
|
|
519
|
+
on: record_only
|
|
520
|
+
label: 设计字段布局
|
|
496
521
|
# export:
|
|
497
522
|
# label: Export
|
|
498
523
|
# visible: true
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "page",
|
|
3
|
+
"title": "Welcome to Steedos",
|
|
4
|
+
"body": [
|
|
5
|
+
{
|
|
6
|
+
"type": "service",
|
|
7
|
+
"body": [
|
|
8
|
+
{
|
|
9
|
+
"type": "service",
|
|
10
|
+
"id": "service_field_design",
|
|
11
|
+
"body": [
|
|
12
|
+
{
|
|
13
|
+
"type": "panel",
|
|
14
|
+
"header": {
|
|
15
|
+
"type": "flex",
|
|
16
|
+
"id": "u:b2c8374e93fe",
|
|
17
|
+
"items": [
|
|
18
|
+
{
|
|
19
|
+
"type": "tpl",
|
|
20
|
+
"tpl": "设计字段布局 ${designObjectLabel}(${designObjectName})",
|
|
21
|
+
"id": "u:4c7bef616400"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "flex",
|
|
25
|
+
"id": "u:1bfde03380f8",
|
|
26
|
+
"items": [
|
|
27
|
+
{
|
|
28
|
+
"type": "button",
|
|
29
|
+
"id": "u:ec9931ea883c",
|
|
30
|
+
"actionType": "dialog",
|
|
31
|
+
"dialog": {
|
|
32
|
+
"type": "dialog",
|
|
33
|
+
"title": "设置分组",
|
|
34
|
+
"size": "lg",
|
|
35
|
+
"body": [
|
|
36
|
+
{
|
|
37
|
+
"type": "input-table",
|
|
38
|
+
"columns": [
|
|
39
|
+
{
|
|
40
|
+
"name": "group_name",
|
|
41
|
+
"label": "名称",
|
|
42
|
+
"id": "u:ee2fb813a3e7"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "visible_on",
|
|
46
|
+
"label": "显示条件",
|
|
47
|
+
"id": "u:ed37c3ff9dcb"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"value": "${groups}",
|
|
51
|
+
"name": "setting_groups",
|
|
52
|
+
"addable": true,
|
|
53
|
+
"editable": true,
|
|
54
|
+
"removable": true,
|
|
55
|
+
"id": "u:483827aac3e8"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"onEvent": {
|
|
59
|
+
"confirm": {
|
|
60
|
+
"actions": [
|
|
61
|
+
{
|
|
62
|
+
"actionType": "custom",
|
|
63
|
+
"script": "//整理分组数据\nlet setting_groups = event.data.setting_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}\nsetting_groups.forEach(function (group) {\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})\n\n//整理字段与分组关系的数据\nconst fieldForGroup = {};\nlet oldGroup = 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}\nconsole.log(\"setting_groups,fieldForGroup===>\", setting_groups, fieldForGroup);\n\ndoAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n groups: setting_groups,\n fieldForGroup\n }\n }\n});"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"id": "u:e02c8f59216e",
|
|
69
|
+
"closeOnEsc": false,
|
|
70
|
+
"closeOnOutside": false,
|
|
71
|
+
"showCloseButton": true,
|
|
72
|
+
"showErrorMsg": true,
|
|
73
|
+
"showLoading": true
|
|
74
|
+
},
|
|
75
|
+
"label": "设置分组",
|
|
76
|
+
"className": ""
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "button",
|
|
80
|
+
"label": "新增字段",
|
|
81
|
+
"actionType": "dialog",
|
|
82
|
+
"id": "u:5857ae729799",
|
|
83
|
+
"dialog": {
|
|
84
|
+
"type": "dialog",
|
|
85
|
+
"title": "新增字段",
|
|
86
|
+
"data": {
|
|
87
|
+
"appId": "${appId}",
|
|
88
|
+
"global": "${global}",
|
|
89
|
+
"context": "${context}",
|
|
90
|
+
"designObjectName": "${designObjectName}",
|
|
91
|
+
"_master": "${_master}"
|
|
92
|
+
},
|
|
93
|
+
"body": [
|
|
94
|
+
{
|
|
95
|
+
"type": "steedos-object-form",
|
|
96
|
+
"label": "对象表单",
|
|
97
|
+
"objectApiName": "object_fields",
|
|
98
|
+
"recordId": "",
|
|
99
|
+
"mode": "edit",
|
|
100
|
+
"defaultData": {
|
|
101
|
+
"name": "",
|
|
102
|
+
"shared": false,
|
|
103
|
+
"object": "${designObjectName}"
|
|
104
|
+
},
|
|
105
|
+
"fieldsExtend": {
|
|
106
|
+
"object": {
|
|
107
|
+
"amis": {
|
|
108
|
+
"disabledOn": "true"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"group": {
|
|
112
|
+
"amis": {
|
|
113
|
+
"hidden": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"fields": "",
|
|
118
|
+
"id": "u:b71796d3cb8c",
|
|
119
|
+
"className": "mb-4",
|
|
120
|
+
"enableTabs": true,
|
|
121
|
+
"tabsMode": "line"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"showCloseButton": true,
|
|
125
|
+
"showErrorMsg": true,
|
|
126
|
+
"showLoading": true,
|
|
127
|
+
"closeOnEsc": false,
|
|
128
|
+
"dataMapSwitch": false,
|
|
129
|
+
"size": "lg",
|
|
130
|
+
"id": "u:066b3884bdd8"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"type": "button",
|
|
135
|
+
"label": "保存",
|
|
136
|
+
"actionType": "submit",
|
|
137
|
+
"id": "u:d9039421ea6b",
|
|
138
|
+
"target": "form_design_form",
|
|
139
|
+
"level": "primary"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"style": {
|
|
145
|
+
"position": "static",
|
|
146
|
+
"flexWrap": "nowrap",
|
|
147
|
+
"justifyContent": "space-between",
|
|
148
|
+
"alignItems": "baseline"
|
|
149
|
+
},
|
|
150
|
+
"isFixedHeight": false,
|
|
151
|
+
"isFixedWidth": false
|
|
152
|
+
},
|
|
153
|
+
"body": [
|
|
154
|
+
{
|
|
155
|
+
"type": "form",
|
|
156
|
+
"title": "",
|
|
157
|
+
"body": [
|
|
158
|
+
{
|
|
159
|
+
"type": "steedos-board",
|
|
160
|
+
"id": "steedos_field_deign",
|
|
161
|
+
"columns": 2,
|
|
162
|
+
"name": "design_field",
|
|
163
|
+
"boardSource": "${groups}",
|
|
164
|
+
"boardClassName": "bg-gray-50 p-2 border rounded shadow",
|
|
165
|
+
"boardHeader": {
|
|
166
|
+
"type": "tpl",
|
|
167
|
+
"tpl": "字段分组:${group_name}",
|
|
168
|
+
"id": "u:76d9a6c7d401"
|
|
169
|
+
},
|
|
170
|
+
"cardClassName": "p-1 bg-white border w-full rounded shadow",
|
|
171
|
+
"cardSchema": {
|
|
172
|
+
"type": "card",
|
|
173
|
+
"header": {
|
|
174
|
+
"className": "items-center py-0 border-0",
|
|
175
|
+
"title": "${label}(${_name})"
|
|
176
|
+
},
|
|
177
|
+
"toolbar": [
|
|
178
|
+
{
|
|
179
|
+
"type": "steedos-dropdown-button",
|
|
180
|
+
"label": "xxx",
|
|
181
|
+
"buttons": [
|
|
182
|
+
{
|
|
183
|
+
"type": "steedos-object-button",
|
|
184
|
+
"name": "standard_edit",
|
|
185
|
+
"objectName": "object_fields",
|
|
186
|
+
"className": "antd-Button--default"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "steedos-object-button",
|
|
190
|
+
"name": "standard_delete",
|
|
191
|
+
"objectName": "object_fields",
|
|
192
|
+
"className": "antd-Button--default"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"placement": "bottomRight",
|
|
196
|
+
"overlayClassName": "shadow !min-w-[160px]",
|
|
197
|
+
"trigger": [
|
|
198
|
+
"click"
|
|
199
|
+
],
|
|
200
|
+
"id": "u:c2140a365019",
|
|
201
|
+
"className": "mx-3 hidden"
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"className": "mb-0 border-0 bg-none card",
|
|
205
|
+
"id": "u:296298da1bef"
|
|
206
|
+
},
|
|
207
|
+
"cardSource": "${fields}",
|
|
208
|
+
"vertical": true,
|
|
209
|
+
"onEvent": {
|
|
210
|
+
"change": {
|
|
211
|
+
"actions": [
|
|
212
|
+
{
|
|
213
|
+
"actionType": "custom",
|
|
214
|
+
"script": "const newGroups = _.keys(event.data.value);\nconst lastGroups = _.map(context.props.data.groups, 'group_name');\nif (newGroups != lastGroups) {\n doAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n groups: field_groups = _.sortBy(context.props.data.groups, function (group) { return _.findIndex(newGroups, function (group_name) { return group.group_name === group_name; }); })\n }\n }\n });\n}\n"
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"value": "${fieldForGroup}"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"id": "form_field_design",
|
|
223
|
+
"api": {
|
|
224
|
+
"url": "${context.rootUrl}/graphql",
|
|
225
|
+
"method": "post",
|
|
226
|
+
"dataType": "json",
|
|
227
|
+
"headers": {
|
|
228
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
229
|
+
},
|
|
230
|
+
"requestAdaptor": "var graphqlOrder = \"\";\n//根据groups,修改对象的字段分组field_groups\nvar field_groups = _.cloneDeep(api.data.groups);\n_.remove(field_groups, { is_default: true });\nfield_groups = field_groups.map(function (group) {\n return _.omit(group, 'id');\n})\nconst groupOrder = 'upsert0:objects__upsert(id:\"' + api.data.$self.designObjectId + '\" , doc:' + JSON.stringify(JSON.stringify({ field_groups })) + ') {_id}';\ngraphqlOrder += groupOrder;\n\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\n_.forEach(api.data.design_field, function (items, key) {\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n const itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify({ object: api.data.$self.designObjectName, _name: field._name, label: field.label, sort_no: index * 10, group: key == \"未分组\" ? null : key })) + '){_id}\\n';\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\ngraphqlOrder = 'mutation {' + graphqlOrder + '}';\nreturn {\n ...api,\n data: {\n query: graphqlOrder\n }\n}",
|
|
231
|
+
"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;",
|
|
232
|
+
"messages": {
|
|
233
|
+
},
|
|
234
|
+
"data": {
|
|
235
|
+
"design_field": "${design_field}",
|
|
236
|
+
"groups": "${groups}",
|
|
237
|
+
"fields": "${fields}",
|
|
238
|
+
"$self": "$$"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"visibleOn": "${dataInitialed}",
|
|
242
|
+
"wrapWithPanel": false,
|
|
243
|
+
"name": "form_design_form"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"className": "Panel--default max-w-xl m-auto",
|
|
247
|
+
"id": "u:3a90104cb6b4"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"api": {
|
|
251
|
+
"method": "post",
|
|
252
|
+
"url": "${context.rootUrl}/graphql?designObjectId=${designObjectId}",
|
|
253
|
+
"data": {
|
|
254
|
+
"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}}}",
|
|
255
|
+
"field_groups": "${field_groups}",
|
|
256
|
+
"dataInitialed": "${dataInitialed}",
|
|
257
|
+
"designObjectName": "${designObjectName}",
|
|
258
|
+
"eventData": "${eventData}",
|
|
259
|
+
"fieldForGroup": "${fieldForGroup}"
|
|
260
|
+
},
|
|
261
|
+
"headers": {
|
|
262
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
263
|
+
},
|
|
264
|
+
"messages": {
|
|
265
|
+
},
|
|
266
|
+
"requestAdaptor": "",
|
|
267
|
+
"adaptor": "//筛选出可编辑的字段\r\n\r\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\r\n//将group为空的字段分为未分组的组中\r\noldFields = _.map(oldFields, function (obj) {\r\n 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,\r\n \"_name\": field._name,\r\n \"label\": field.label,\r\n \"_id\": field._id,\r\n \"columnSpan\": field.is_wide ? 2 : 1\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\nconst 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\nconst 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\nreturn payload = {\r\n data: {\r\n fields,\r\n groups,\r\n fieldForGroup,\r\n dataInitialed: true\r\n }\r\n};",
|
|
268
|
+
"sendOn": "!!this.designObjectId"
|
|
269
|
+
},
|
|
270
|
+
"messages": {
|
|
271
|
+
},
|
|
272
|
+
"onEvent": {
|
|
273
|
+
"fetchInited": {
|
|
274
|
+
"actions": [
|
|
275
|
+
{
|
|
276
|
+
"actionType": "custom",
|
|
277
|
+
"script": "const 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}\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field: fieldForGroup }\n }\n});\n\n",
|
|
278
|
+
"expression": "${event.data.fieldUpdateData}"
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"initFetch": false,
|
|
284
|
+
"data": {
|
|
285
|
+
"eventData": ""
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
],
|
|
289
|
+
"id": "u:02f594329e1e",
|
|
290
|
+
"api": {
|
|
291
|
+
"method": "post",
|
|
292
|
+
"url": "${context.rootUrl}/graphql",
|
|
293
|
+
"data": {
|
|
294
|
+
"query": "{objects(filters: [[\"name\",\"=\",\"${designObjectName}\"]]){_id,name,label,field_groups}}"
|
|
295
|
+
},
|
|
296
|
+
"headers": {
|
|
297
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
298
|
+
},
|
|
299
|
+
"messages": {
|
|
300
|
+
},
|
|
301
|
+
"requestAdaptor": "",
|
|
302
|
+
"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}"
|
|
303
|
+
},
|
|
304
|
+
"messages": {
|
|
305
|
+
},
|
|
306
|
+
"onEvent": {
|
|
307
|
+
"@data.changed.object_fields": {
|
|
308
|
+
"actions": [
|
|
309
|
+
{
|
|
310
|
+
"actionType": "reload",
|
|
311
|
+
"data": {
|
|
312
|
+
"eventData": "${event.data}"
|
|
313
|
+
},
|
|
314
|
+
"componentId": "service_field_design"
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"regions": [
|
|
322
|
+
"body"
|
|
323
|
+
],
|
|
324
|
+
"data": {
|
|
325
|
+
"initialValues": {
|
|
326
|
+
},
|
|
327
|
+
"appId": "builder",
|
|
328
|
+
"title": "",
|
|
329
|
+
"context": "${context}",
|
|
330
|
+
"dataInitialed": false
|
|
331
|
+
},
|
|
332
|
+
"id": "u:993ee4316643",
|
|
333
|
+
"css": {
|
|
334
|
+
".steedos-design-field .card:hover .slds-button": {
|
|
335
|
+
"display": "inline-block"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"className": "steedos-design-field"
|
|
339
|
+
}
|
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
"enableTabs": true,
|
|
11
11
|
"mode": "edit",
|
|
12
12
|
"layout": "normal",
|
|
13
|
+
"apiRequestAdaptor": "api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
|
|
13
14
|
"submitSuccActions": [
|
|
14
15
|
{
|
|
15
16
|
"actionType": "custom",
|
|
16
17
|
"script": "setTimeout(function(){doAction({'actionType': 'setValue','componentId': 'form_object_fields','args': {'value': {'sort_no': event.data.sort_no + 10}}})}, 300)"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"actionType": "toast",
|
|
21
|
+
"args": {
|
|
22
|
+
"msgType": "success",
|
|
23
|
+
"msg": "操作成功, 请刷新浏览器后查看效果",
|
|
24
|
+
"position": "top-right"
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
27
|
]
|
|
19
28
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "service",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "steedos-object-form",
|
|
6
|
+
"label": "对象表单",
|
|
7
|
+
"objectApiName": "objects",
|
|
8
|
+
"recordId": "${recordId}",
|
|
9
|
+
"className": "",
|
|
10
|
+
"enableTabs": true,
|
|
11
|
+
"mode": "edit",
|
|
12
|
+
"layout": "normal",
|
|
13
|
+
"apiRequestAdaptor": "console.log('api.data.query===', api.data.query);api.data.query = api.data.query.replace('objects__update', 'objects__upsert')",
|
|
14
|
+
"submitSuccActions": [
|
|
15
|
+
{
|
|
16
|
+
"actionType": "toast",
|
|
17
|
+
"args": {
|
|
18
|
+
"msgType": "success",
|
|
19
|
+
"msg": "操作成功, 请刷新浏览器后查看效果",
|
|
20
|
+
"position": "top-right"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"data": {
|
|
27
|
+
"context": {}
|
|
28
|
+
},
|
|
29
|
+
"name": "object_fields_form",
|
|
30
|
+
"id": "u:bb11df394baf"
|
|
31
|
+
}
|
|
@@ -353,12 +353,12 @@ module.exports = {
|
|
|
353
353
|
const obj = this.getObject(object_name);
|
|
354
354
|
const latestDoc = await obj.findOne(id);
|
|
355
355
|
// !!!暂不允许修改name
|
|
356
|
-
if (_.has(doc, '_name')) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
356
|
+
// if (_.has(doc, '_name')) {
|
|
357
|
+
// const newFieldName = doc._name;
|
|
358
|
+
// if (newFieldName && (latestDoc._name != newFieldName)) {
|
|
359
|
+
// throw new Error('禁止修改字段名。');
|
|
360
|
+
// }
|
|
361
|
+
// }
|
|
362
362
|
// !!!暂不允许修改字段类型
|
|
363
363
|
if (_.has(doc, 'type')) {
|
|
364
364
|
const newFieldType = doc.type;
|
|
@@ -36,28 +36,6 @@ module.exports = {
|
|
|
36
36
|
}
|
|
37
37
|
})
|
|
38
38
|
},
|
|
39
|
-
afterAggregate: async function(){
|
|
40
|
-
let userId = this.userId
|
|
41
|
-
let spaceId = this.spaceId;
|
|
42
|
-
for (const doc of this.data.values) {
|
|
43
|
-
doc.fields = Object.assign({}, doc.fields, await InternalData.getDefaultSysFields(doc.name, userId)) ;
|
|
44
|
-
}
|
|
45
|
-
// this.data.values = this.data.values.concat(await InternalData.findObjects(userId, this.query.filters));
|
|
46
|
-
|
|
47
|
-
this.data.values = this.data.values.concat(await InternalData.getObjects(userId));
|
|
48
|
-
|
|
49
|
-
this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
|
|
50
|
-
|
|
51
|
-
_.each(this.data.values, function(value){
|
|
52
|
-
if(value){
|
|
53
|
-
delete value.actions;
|
|
54
|
-
delete value.fields;
|
|
55
|
-
delete value.list_views;
|
|
56
|
-
delete value.permission_set;
|
|
57
|
-
delete value.triggers;
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
},
|
|
61
39
|
afterCount: async function(){
|
|
62
40
|
let userId = this.userId
|
|
63
41
|
let spaceId = this.spaceId;
|
|
@@ -134,9 +112,9 @@ module.exports = {
|
|
|
134
112
|
const latestDoc = await obj.findOne(id);
|
|
135
113
|
const newObjName = doc.name;
|
|
136
114
|
// !!!暂不允许修改name
|
|
137
|
-
if (newObjName && (latestDoc.name != newObjName)) {
|
|
138
|
-
|
|
139
|
-
}
|
|
115
|
+
// if (newObjName && (latestDoc.name != newObjName)) {
|
|
116
|
+
// throw new Error('禁止修改API 名称。');
|
|
117
|
+
// }
|
|
140
118
|
/*
|
|
141
119
|
if (newObjName && (latestDoc.name != newObjName) && latestDoc.datasource === 'default') {
|
|
142
120
|
const datasource = objectql.getDataSource(latestDoc.datasource);
|
|
@@ -169,7 +147,7 @@ module.exports = {
|
|
|
169
147
|
}
|
|
170
148
|
*/
|
|
171
149
|
|
|
172
|
-
await sleep(1000 * 2)
|
|
150
|
+
// await sleep(1000 * 2)
|
|
173
151
|
},
|
|
174
152
|
afterDelete: async function(){
|
|
175
153
|
const { previousDoc: object, spaceId } = this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.18-beta.1",
|
|
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": "c4ba4e73e2182af6a1b825988b5d325c4af918ff"
|
|
19
19
|
}
|
package/package.service.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 1985-10-26 16:15:00
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-10-30 17:18:36
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
9
9
|
const project = require('./package.json');
|
|
10
10
|
const packageName = project.name;
|
|
11
11
|
const packageLoader = require('@steedos/service-meteor-package-loader');
|
|
12
|
+
const serviceObjectMixin = require('@steedos/service-object-mixin');
|
|
12
13
|
/**
|
|
13
14
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
14
15
|
*/
|
|
15
16
|
module.exports = {
|
|
16
17
|
name: packageName,
|
|
17
18
|
namespace: "steedos",
|
|
18
|
-
mixins: [packageLoader],
|
|
19
|
+
mixins: [packageLoader, serviceObjectMixin],
|
|
19
20
|
/**
|
|
20
21
|
* Settings
|
|
21
22
|
*/
|
|
@@ -36,7 +37,96 @@ module.exports = {
|
|
|
36
37
|
* Actions
|
|
37
38
|
*/
|
|
38
39
|
actions: {
|
|
40
|
+
objects__upsert: {
|
|
41
|
+
graphql: {
|
|
42
|
+
mutation:
|
|
43
|
+
"objects__upsert(id: String, doc: JSON): objects"
|
|
44
|
+
},
|
|
45
|
+
async handler(ctx) {
|
|
46
|
+
const userSession = ctx.meta.user;
|
|
47
|
+
let { id, doc } = ctx.params;
|
|
48
|
+
let data = '';
|
|
49
|
+
if (_.isString(doc)) {
|
|
50
|
+
data = JSON.parse(doc);
|
|
51
|
+
} else {
|
|
52
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
53
|
+
}
|
|
39
54
|
|
|
55
|
+
if(data.form && _.isString(data.form)){
|
|
56
|
+
data.form = JSON.parse(data.form)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
delete data.space;
|
|
60
|
+
|
|
61
|
+
const object = await this.getObject('objects');
|
|
62
|
+
const dbRecord = await object.directFind({filters: ['_id','=',id]});
|
|
63
|
+
if(dbRecord.length === 0){
|
|
64
|
+
// const newId = await object._makeNewID();
|
|
65
|
+
const now = new Date();
|
|
66
|
+
await object.directInsert(Object.assign({}, data, {
|
|
67
|
+
// _id: newId,
|
|
68
|
+
_id: id, // saas模式不支持修改对象
|
|
69
|
+
owner: userSession.userId,
|
|
70
|
+
space: userSession.spaceId,
|
|
71
|
+
created: now,
|
|
72
|
+
modified: now,
|
|
73
|
+
created_by: userSession.userId,
|
|
74
|
+
modified_by: userSession.userId,
|
|
75
|
+
company_id: userSession.company_id,
|
|
76
|
+
company_ids: userSession.company_ids,
|
|
77
|
+
extend: data.name,
|
|
78
|
+
custom: false,
|
|
79
|
+
is_system: true
|
|
80
|
+
}));
|
|
81
|
+
// id = newId;
|
|
82
|
+
}
|
|
83
|
+
return object.update(id, data, userSession)
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
object_fields__upsert: {
|
|
87
|
+
graphql: {
|
|
88
|
+
mutation:
|
|
89
|
+
"object_fields__upsert(id: String, doc: JSON): object_fields"
|
|
90
|
+
},
|
|
91
|
+
async handler(ctx) {
|
|
92
|
+
const userSession = ctx.meta.user;
|
|
93
|
+
let { id, doc } = ctx.params;
|
|
94
|
+
let data = '';
|
|
95
|
+
if (_.isString(doc)) {
|
|
96
|
+
data = JSON.parse(doc);
|
|
97
|
+
} else {
|
|
98
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
99
|
+
}
|
|
100
|
+
delete data.space;
|
|
101
|
+
|
|
102
|
+
const object = await this.getObject('object_fields');
|
|
103
|
+
if(id.indexOf('.') > 0){
|
|
104
|
+
const [objectName, fieldName] = id.split('.');
|
|
105
|
+
const dbRecord = await object.directFind({filters: [['object','=',objectName], ['name','=',fieldName]]});
|
|
106
|
+
if(dbRecord.length > 0){
|
|
107
|
+
id = dbRecord[0]._id;
|
|
108
|
+
}else{
|
|
109
|
+
const newId = await object._makeNewID();
|
|
110
|
+
const now = new Date();
|
|
111
|
+
await object.directInsert(Object.assign({}, data, {
|
|
112
|
+
_id: newId,
|
|
113
|
+
name: data._name || fieldName,
|
|
114
|
+
owner: userSession.userId,
|
|
115
|
+
space: userSession.spaceId,
|
|
116
|
+
object: objectName,
|
|
117
|
+
created: now,
|
|
118
|
+
modified: now,
|
|
119
|
+
created_by: userSession.userId,
|
|
120
|
+
modified_by: userSession.userId,
|
|
121
|
+
company_id: userSession.company_id,
|
|
122
|
+
company_ids: userSession.company_ids
|
|
123
|
+
}));
|
|
124
|
+
id = newId;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return object.update(id, data, userSession)
|
|
128
|
+
},
|
|
129
|
+
},
|
|
40
130
|
},
|
|
41
131
|
|
|
42
132
|
/**
|