@steedos/service-plugin-amis 2.3.1-beta.3 → 2.3.1-beta.4

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.
@@ -22,7 +22,7 @@
22
22
  "responseData": {
23
23
  "recordId": "${record._id}"
24
24
  },
25
- "adaptor": "var modal = SteedosUI.getRef(api.body.modalName);\nmodal && modal.close();\nSteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\nreturn payload;\n ",
25
+ "adaptor": "\nSteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\nreturn payload;\n ",
26
26
  "headers": {
27
27
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
28
28
  }
@@ -500,24 +500,7 @@
500
500
  }
501
501
  ],
502
502
  "panelClassName": "m-0 -mt-3",
503
- "actions": [
504
- {
505
- "type": "button",
506
- "label": "取消",
507
- "actionType": "",
508
- "level": "default",
509
- "block": false,
510
- "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
511
- "id": "u:f2208dc2b4cd"
512
- },
513
- {
514
- "type": "button",
515
- "label": "保存",
516
- "actionType": "submit",
517
- "level": "info",
518
- "id": "u:207386fce204"
519
- }
520
- ],
503
+ "actions": false,
521
504
  "actionsClassName": "p-sm b-t b-light text-center",
522
505
  "affixFooter": false,
523
506
  "debug": false,
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "requestAdaptor": "const formData = api.data.$;\napi.data = { objects: formData.objects };\nreturn api;",
22
22
  "responseData": null,
23
- "adaptor": "var modal = SteedosUI.getRef(api.body.modalName);\nmodal && modal.close();\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n refreshGrid && refreshGrid();\n}\nreturn payload;\n ",
23
+ "adaptor": "\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n refreshGrid && refreshGrid();\n}\nreturn payload;\n ",
24
24
  "headers": {
25
25
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
26
26
  }
@@ -47,24 +47,7 @@
47
47
  ],
48
48
  "panelClassName": "m-0",
49
49
  "bodyClassName": "p-4",
50
- "actions": [
51
- {
52
- "type": "button",
53
- "label": "取消",
54
- "actionType": "",
55
- "level": "default",
56
- "block": false,
57
- "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
58
- "id": "u:bf2587b53d64"
59
- },
60
- {
61
- "type": "button",
62
- "label": "确定",
63
- "actionType": "submit",
64
- "level": "info",
65
- "id": "u:08afd6e53cab"
66
- }
67
- ],
50
+ "actions": false,
68
51
  "actionsClassName": "p-sm b-t b-light text-center",
69
52
  "className": "steedos-amis-form -mt-3",
70
53
  "checkAll": false,
@@ -11,7 +11,7 @@
11
11
  "title": "",
12
12
  "api": {
13
13
  "method": "post",
14
- "url": "/graphql",
14
+ "url": "${context.rootUrl}/graphql",
15
15
  "data": {
16
16
  "objectName": "${objectName}",
17
17
  "$": "$$",
@@ -22,11 +22,14 @@
22
22
  "responseData": {
23
23
  "recordId": "${record._id}"
24
24
  },
25
- "adaptor": "\nSteedosUI.getRef(api.body.modalName).close();\nvar object_name = Session.get(\"object_name\");\nif (window.FlowRouter && window.FlowRouter.current().route.pathDef === '/app/:app_id/:object_name/grid/:list_view_id' && object_name != 'object_listviews') {\n var app_id = Session.get(\"app_id\");\n var list_view_id = payload.data.record._id;\n var url = \"/app/\" + app_id + \"/\" + object_name + \"/grid/\" + list_view_id;\n SteedosUI.router.go({ objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit' : 'new' }, url);\n} else { \n SteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\n}\n\nreturn payload;\n "
25
+ "headers": {
26
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
27
+ },
28
+ "adaptor": "\nvar object_name = Session.get(\"object_name\");\nif (window.FlowRouter && window.FlowRouter.current().route.pathDef === '/app/:app_id/:object_name/grid/:list_view_id' && object_name != 'object_listviews') {\n var app_id = Session.get(\"app_id\");\n var list_view_id = payload.data.record._id;\n var url = \"/app/\" + app_id + \"/\" + object_name + \"/grid/\" + list_view_id;\n SteedosUI.router.go({ objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit' : 'new' }, url);\n} else { \n SteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\n}\n\nreturn payload;\n "
26
29
  },
27
30
  "initApi": {
28
31
  "method": "post",
29
- "url": "/graphql?rf=1653731141728",
32
+ "url": "${context.rootUrl}/graphql?rf=1653731141728",
30
33
  "cache": 100,
31
34
  "adaptor": "var data = payload.data.data[0] || { _filters_type_controller: 'conditions' };\n//数据格式转换\nif (data) {\n data.columns = lodash.map(data.columns, 'field');\n data.sort = lodash.map(data.sort, (item) => {\n return `${item.field_name}:${item.order || 'asc'}`\n });\n data.mobile_columns = lodash.map(data.mobile_columns, 'field');\n\n if (data.filters && lodash.isString(data.filters)) {\n try {\n data.filters = JSON.parse(data.filters);\n }catch(e){}\n }\n\n if (data.filters && lodash.isString(data.filters)) {\n data._filters_type_controller = 'function';\n } else {\n data._filters_type_controller = 'conditions'\n }\n\n if (data._filters_type_controller === 'conditions') {\n data._filters_conditions = window.amisConvert.filtersToConditions(data.filters || []);\n } else {\n data._filters_function = data.filters;\n }\n}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;",
32
35
  "data": {
@@ -36,6 +39,9 @@
36
39
  "replaceData": false,
37
40
  "responseData": {
38
41
  "&": "$$"
42
+ },
43
+ "headers": {
44
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
39
45
  }
40
46
  },
41
47
  "initFetch": true,
@@ -83,14 +89,23 @@
83
89
  "extractValue": true,
84
90
  "labelField": "label",
85
91
  "valueField": "value",
86
- "autoComplete": "get:/service/api/amis-metadata-objects/objects/options",
92
+ "autoComplete": {
93
+ "method": "get",
94
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
95
+ "headers": {
96
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
97
+ }
98
+ },
87
99
  "className": "m-0",
88
100
  "labelClassName": "text-left",
89
101
  "checkAll": false,
90
102
  "searchable": true,
91
103
  "source": {
92
104
  "method": "get",
93
- "url": "/service/api/amis-metadata-objects/objects/options"
105
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
106
+ "headers": {
107
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
108
+ }
94
109
  },
95
110
  "en-US": {
96
111
  "label": "Object"
@@ -165,7 +180,10 @@
165
180
  "placeholder": "-",
166
181
  "source": {
167
182
  "method": "get",
168
- "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
183
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
184
+ "headers": {
185
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
186
+ },
169
187
  "data": null,
170
188
  "requestAdaptor": "",
171
189
  "adaptor": "",
@@ -210,7 +228,10 @@
210
228
  "id": "u:ea994ad5816d",
211
229
  "source": {
212
230
  "method": "get",
213
- "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
231
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
232
+ "headers": {
233
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
234
+ },
214
235
  "data": null,
215
236
  "requestAdaptor": "",
216
237
  "adaptor": "",
@@ -259,7 +280,10 @@
259
280
  "source": {
260
281
  "method": "get",
261
282
  "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${object_name}",
262
- "dataType": "json"
283
+ "dataType": "json",
284
+ "headers": {
285
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
286
+ }
263
287
  },
264
288
  "disabled": false,
265
289
  "className": "col-span-2 m-0",
@@ -300,7 +324,10 @@
300
324
  "strictMode": true,
301
325
  "source": {
302
326
  "method": "get",
303
- "url": "/service/api/amis-metadata-objects/objects/${object_name}/sortFields/options",
327
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/sortFields/options",
328
+ "headers": {
329
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
330
+ },
304
331
  "data": null,
305
332
  "requestAdaptor": "",
306
333
  "adaptor": "",
@@ -348,7 +375,10 @@
348
375
  "extractValue": true,
349
376
  "source": {
350
377
  "method": "get",
351
- "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
378
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
379
+ "headers": {
380
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
381
+ },
352
382
  "data": null,
353
383
  "requestAdaptor": "",
354
384
  "adaptor": "",
@@ -372,30 +402,7 @@
372
402
  ],
373
403
  "panelClassName": "m-0",
374
404
  "bodyClassName": "p-4",
375
- "actions": [
376
- {
377
- "type": "button",
378
- "label": "取消",
379
- "actionType": "",
380
- "level": "default",
381
- "block": false,
382
- "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
383
- "en-US": {
384
- "label": "Cancel"
385
- },
386
- "id": "u:2b559c02ad83"
387
- },
388
- {
389
- "type": "button",
390
- "label": "保存",
391
- "actionType": "submit",
392
- "level": "info",
393
- "en-US": {
394
- "label": "Save"
395
- },
396
- "id": "u:a48a8052e83a"
397
- }
398
- ],
405
+ "actions": false,
399
406
  "actionsClassName": "p-sm b-t b-light text-center",
400
407
  "className": "steedos-amis-form",
401
408
  "language": "javascript",
@@ -406,10 +413,7 @@
406
413
  "body"
407
414
  ],
408
415
  "data": {
409
- "objectName": "object_listviews",
410
- "context": {
411
- "rootUrl": "http://127.0.0.1:5800"
412
- }
416
+ "objectName": "object_listviews"
413
417
  },
414
418
  "bodyClassName": "p-0",
415
419
  "name": "page_edit_${recordId}",
@@ -12,11 +12,39 @@ const steedosI18n = require("@steedos/i18n");
12
12
  const clone = require("clone");
13
13
 
14
14
  const getObjectConfig = async function(objectName){
15
- const object = clone(objectql.getObject(objectName).toConfig());
15
+ const object = objectql.getObject(objectName);
16
+ const objectConfig = clone(object.toConfig());
17
+ // TODO: 后续再支持附件子表
18
+ // let relatedLists = []
19
+ // if(objectConfig.enable_files){
20
+ // relatedLists.push("cms_files.parent")
21
+ // }
22
+ const relationsInfo = await object.getRelationsInfo();
23
+
24
+ // TODO: 跨工作区了,后续需要补充spaceId过滤条件
25
+ const dbListViews = await objectql.getObject("object_listviews").directFind({
26
+ filters: [['object_name', '=', objectName], ['shared', '=', true]]
27
+ })
28
+
29
+ objectConfig.list_views = Object.assign({}, objectConfig.list_views)
30
+ _.each(dbListViews, function(dbListView){
31
+ delete dbListView.created;
32
+ delete dbListView.created_by;
33
+ delete dbListView.modified;
34
+ delete dbListView.modified_by;
35
+ objectConfig.list_views[dbListView.name] = dbListView;
36
+ })
37
+
38
+ objectConfig.details = relationsInfo && relationsInfo.details;
39
+ objectConfig.masters = relationsInfo && relationsInfo.masters;
40
+ objectConfig.lookup_details = relationsInfo && relationsInfo.lookup_details;
41
+ // TODO: 后续再支持related_lists
42
+ // objectConfig.related_lists = relationsInfo && relationsInfo.related_lists;
43
+
16
44
  // let lng = objectql.getUserLocale(userSession);
17
45
  let lng = "zh-CN";//先写死中文,后续拟通过环境变量配置语言
18
- steedosI18n.translationObject(lng, object.name, object);
19
- return object;
46
+ steedosI18n.translationObject(lng, object.name, objectConfig);
47
+ return objectConfig;
20
48
  }
21
49
 
22
50
  AmisLib.setUISchemaFunction(async function(objectName, force){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.3.1-beta.3",
3
+ "version": "2.3.1-beta.4",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "node .scripts/build.tailwind.js"
@@ -13,5 +13,5 @@
13
13
  "dependencies": {
14
14
  "@steedos-widgets/amis-lib": "^0.0.7"
15
15
  },
16
- "gitHead": "295037dcb3bd046c5c65a06e02b74e76c0ee7ac2"
16
+ "gitHead": "5e137018242b488852be3e25281746e8e0b84d03"
17
17
  }