@steedos/service-core-objects 3.0.0-beta.69 → 3.0.0-beta.70

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.
@@ -163,5 +163,7 @@ actions:
163
163
  label: Export Excel
164
164
  standard_print:
165
165
  label: Print
166
+ standard_customize:
167
+ label: Customize
166
168
  groups:
167
169
  system_information: System Information
@@ -163,5 +163,7 @@ actions:
163
163
  label: 导出
164
164
  standard_print:
165
165
  label: 打印
166
+ standard_customize:
167
+ label: 自定义
166
168
  groups:
167
169
  system_information: 系统信息
@@ -1,3 +1,42 @@
1
+ var standardCustomizeSaveRequestAdaptor = `
2
+ var uiSchema = context.uiSchema;
3
+ var objectFields = uiSchema.fields;
4
+ var objectName = context.objectName;
5
+ var doc = context.docForStandardCustomize;
6
+ var newDoc = {}
7
+ if(objectName === "apps"){
8
+ newDoc = doc;//应用中有隐藏字段,uiSchema中没有这些字段,比如字段tab_items
9
+ newDoc.from_code_id = doc._id;
10
+ delete newDoc._id;
11
+ delete newDoc.record_permissions;
12
+ delete newDoc.__filename;
13
+ delete newDoc.responseData;
14
+ delete newDoc.responseStatus;
15
+ }
16
+ else if(objectName === "permission_set"){
17
+ objectFields = ['name', 'label', 'type', 'license', 'lockout_interval', 'max_login_attempts', 'password_history', 'default_standard_buttons'];
18
+ _.each(objectFields, function(v, k){
19
+ if(_.has(doc, v)){
20
+ newDoc[v] = doc[v];
21
+ }
22
+ });
23
+ }
24
+ else{
25
+ _.each(objectFields, function(v, k){
26
+ if(_.has(doc, k)){
27
+ newDoc[k] = doc[k];
28
+ }
29
+ });
30
+ }
31
+ delete newDoc.is_system;
32
+ return {
33
+ ...api,
34
+ data: {
35
+ doc: newDoc
36
+ }
37
+ };
38
+ `;
39
+
1
40
  module.exports = {
2
41
  extend: 'base',
3
42
  actions: {
@@ -446,5 +485,119 @@ module.exports = {
446
485
  "bodyClassName": "p-0"
447
486
  }
448
487
  },
488
+ standard_customize: {
489
+ label: "Customize",
490
+ visible: function (object_name, record_id, record_permissions, data) {
491
+ if(object_name == "objects" || object_name == "object_fields"){
492
+ return false;
493
+ }
494
+ var record = data && data.record;
495
+ if(!record){
496
+ record = {}
497
+ }
498
+ var isVisible = Steedos.Object.base.actions.standard_new.visible() && record.is_system && data.uiSchema.isMetadata;
499
+ if (isVisible){
500
+ if(object_name == "apps"){
501
+ if(record_id === 'admin'){return false;}
502
+ isVisible = !record.from_code_id;
503
+ }
504
+ else if (object_name == "object_actions"){
505
+ isVisible = record.type == 'amis_button';
506
+ }
507
+ }
508
+ return isVisible;
509
+ },
510
+ on: "record_only",
511
+ type: 'amis_button',
512
+ amis_schema: {
513
+ "type": "service",
514
+ "body": [
515
+ {
516
+ "type": "button",
517
+ "label": "${'CustomAction.base.standard_customize' | t}",
518
+ "id": "u:disable",
519
+ "onEvent": {
520
+ "click": {
521
+ "weight": 0,
522
+ "actions": [
523
+ {
524
+ "ignoreError": false,
525
+ "actionType": "ajax",
526
+ "outputVar": "docForStandardCustomize",
527
+ "options": {},
528
+ "api": {
529
+ "url": "${context.rootUrl}/api/v1/${objectName}/${recordId}",
530
+ "method": "get",
531
+ "adaptor": "",
532
+ "messages": {}
533
+ }
534
+ },
535
+ {
536
+ "ignoreError": false,
537
+ "actionType": "ajax",
538
+ "outputVar": "standardCustomizeResponseResult",
539
+ "options": {},
540
+ "api": {
541
+ "url": "${context.rootUrl}/api/v1/${objectName}",
542
+ "method": "post",
543
+ "sendOn": "docForStandardCustomize",
544
+ "requestAdaptor": standardCustomizeSaveRequestAdaptor,
545
+ "adaptor": "",
546
+ "messages": {}
547
+ }
548
+ },
549
+ {
550
+ "actionType": "link",
551
+ "args": {
552
+ "link": "/app/${appId}/${objectName}/view/${standardCustomizeResponseResult._id}"
553
+ },
554
+ "expression": "${_inDrawer != true}"
555
+ },
556
+ {
557
+ "actionType": "url",
558
+ "args": {
559
+ "link": "${context.rootUrl}/app/${appId}/${objectName}/view/${standardCustomizeResponseResult._id}",
560
+ "blank": true
561
+ },
562
+ "expression": "${_inDrawer == true}"
563
+ },
564
+ {
565
+ "actionType": "closeDrawer",
566
+ "expression": "${_inDrawer == true}"
567
+ },
568
+ {
569
+ "actionType": "broadcast",
570
+ "args": {
571
+ "eventName": "@data.changed.${objectName}"
572
+ },
573
+ "data": {
574
+ "objectName": "${objectName}"
575
+ },
576
+ "expression": "${_inDrawer == true}"
577
+ }
578
+ ]
579
+ }
580
+ }
581
+ }
582
+ ],
583
+ "regions": [
584
+ "body"
585
+ ],
586
+ "data": {
587
+ "context": {},
588
+ "dataComponentId": "",
589
+ "record_id": "",
590
+ "record": {},
591
+ "permissions": {}
592
+ },
593
+ "bodyClassName": "p-0",
594
+ "dsType": "api",
595
+ "asideResizor": false,
596
+ "editorState": "default",
597
+ "pullRefresh": {
598
+ "disabled": true
599
+ }
600
+ }
601
+ },
449
602
  }
450
603
  };
@@ -278,6 +278,9 @@ actions:
278
278
  on: list
279
279
  standard_print:
280
280
  label: Print
281
+ standard_customize:
282
+ label: Customize
283
+ on: record_only
281
284
  permission_set:
282
285
  none:
283
286
  allowCreate: false
@@ -292,9 +292,6 @@ fields:
292
292
  paging:
293
293
  enabled: false
294
294
  actions:
295
- customize:
296
- label: Customize
297
- on: record_only
298
295
  reset:
299
296
  label: Reset
300
297
  on: record_only
@@ -1,39 +1,10 @@
1
+ /*
2
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
3
+ * @Date: 2025-08-12 17:48:56
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-08-12 17:50:22
6
+ */
1
7
  module.exports = {
2
-
3
- custom: function(object_name, record_id) {
4
- $(document.body).addClass('loading');
5
- let url = `/graphql`;
6
- const obj = Creator.odata.get("objects", record_id);
7
- delete obj.record_permissions;
8
- delete obj["@odata.context"]
9
- delete obj["@odata.editLink"]
10
- delete obj["@odata.etag"]
11
- delete obj["@odata.id"]
12
- delete obj.idFieldName;
13
- let options = {
14
- type: 'post',
15
- async: true,
16
- data: JSON.stringify({
17
- query: `mutation{objects__upsert(id: "${obj.name}", doc: ${JSON.stringify(JSON.stringify(obj))}){_id,name}}`
18
- }),
19
- success: function(data) {
20
- SteedosUI.notification.success({
21
- message: '对象已自定义。'
22
- });
23
- // SteedosUI.router.go({}, "/app/" + Session.get("app_id") + "/" + object_name + "/view/" + data.data.objects__upsert._id);
24
- FlowRouter.reload()
25
- $(document.body).removeClass('loading');
26
- },
27
- error: function(XMLHttpRequest, textStatus, errorThrown) {
28
- SteedosUI.notification.error({
29
- message: '操作失败',
30
- description: t(XMLHttpRequest.responseJSON.error),
31
- });
32
- $(document.body).removeClass('loading');
33
- }
34
- };
35
- Steedos.authRequest(url, options);
36
- },
37
8
  customVisible: function(object_name, record_id, permission, data) {
38
9
  if (Steedos.settings.public.enable_saas) {
39
10
  return false;
@@ -1,5 +1,89 @@
1
1
  name: custom
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "id": "u:custom",
8
+ "type": "button",
9
+ "label": "${'CustomAction.objects.custom' | t}",
10
+ "onEvent": {
11
+ "click": {
12
+ "actions": [
13
+ {
14
+ "actionType": "ajax",
15
+ "ignoreError": false,
16
+ "outputVar": "docForCustomize",
17
+ "options": {},
18
+ "api": {
19
+ "url": "${context.rootUrl}/api/v1/objects/${recordId}",
20
+ "method": "get",
21
+ "adaptor": "",
22
+ "messages": {}
23
+ }
24
+ },
25
+ {
26
+ "ignoreError": false,
27
+ "actionType": "ajax",
28
+ "outputVar": "customizeResponseResult",
29
+ "options": {},
30
+ "api": {
31
+ "url": "${context.rootUrl}/graphql",
32
+ "method": "post",
33
+ "sendOn": "docForCustomize",
34
+ "requestAdaptor": "var doc = context.docForCustomize;\ndoc.is_customize = true;\ndoc.is_enable = true;\ndoc.in_development = \"0\";\n// delete doc.is_system;\ndelete doc.record_permissions;\ndelete doc.NAME_FIELD_KEY;\ndelete doc.idFieldName;\ndelete doc.idFieldNames;\ndelete doc.table_name;\ndelete doc.originalFields;\ndelete doc.extend;\ndelete doc.listeners;\ndelete doc.responseData;\ndelete doc.responseNsg;\ndelete doc.responseStatus;\ndelete doc.__filename;\ndelete doc.__timestamp;\nvar data = {\n query: `mutation{objects__upsert(id: \"${doc.name}\", doc: ${JSON.stringify(JSON.stringify(doc))}){_id,name}}`\n};\nreturn {\n ...api,\n data\n};",
35
+ "adaptor": "",
36
+ "messages": {
37
+ "success": "对象已自定义。",
38
+ "failed": "${msg}"
39
+ }
40
+ }
41
+ },
42
+ {
43
+ "actionType": "broadcast",
44
+ "args": {
45
+ "eventName": "@data.changed.objects"
46
+ },
47
+ "data": {
48
+ "objectName": "objects"
49
+ },
50
+ "expression": "${_inDrawer != true}"
51
+ },
52
+ {
53
+ "actionType": "url",
54
+ "expression": "${_inDrawer == true}",
55
+ "args": {
56
+ "link": "${context.rootUrl}/app/${appId}/objects/view/${_id}",
57
+ "blank": true
58
+ }
59
+ },
60
+ {
61
+ "actionType": "closeDrawer",
62
+ "expression": "${_inDrawer == true}"
63
+ }
64
+ ],
65
+ "weight": 0
66
+ }
67
+ },
68
+ "editorState": "default"
69
+ }
70
+ ],
71
+ "regions": [
72
+ "body"
73
+ ],
74
+ "data": {
75
+ "context": {},
76
+ "dataComponentId": "",
77
+ "record_id": "",
78
+ "record": {},
79
+ "permissions": {}
80
+ },
81
+ "id": "u:be6e9cd18e15",
82
+ "bodyClassName": "p-0",
83
+ "dsType": "api"
84
+ }
2
85
  is_enable: true
3
86
  label: 自定义
4
87
  'on': record_only
5
- sort: 200
88
+ type: amis_button
89
+ visible: true
@@ -29,7 +29,8 @@ amis_schema: |-
29
29
  "showCloseButton": true,
30
30
  "data": {
31
31
  "&": "$$",
32
- "recordId": "${recordId}"
32
+ "recordId": "${recordId}",
33
+ "record": "${record}"
33
34
  },
34
35
  "onEvent": {
35
36
  "confirm": {
@@ -206,10 +206,6 @@ list_views:
206
206
  - type
207
207
  - license
208
208
  - is_system
209
- actions:
210
- customize:
211
- label: Customize
212
- on: record_only
213
209
  # relatedList:
214
210
  # - objectName: permission_objects
215
211
  # filters: !!js/function |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-core-objects",
3
- "version": "3.0.0-beta.69",
3
+ "version": "3.0.0-beta.70",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -10,12 +10,12 @@
10
10
  "steedos"
11
11
  ],
12
12
  "dependencies": {
13
- "@steedos/service-package-loader": "3.0.0-beta.69",
13
+ "@steedos/service-package-loader": "3.0.0-beta.70",
14
14
  "json2xls": "^0.1.2",
15
15
  "lodash": "^4.17.21"
16
16
  },
17
17
  "description": "steedos package",
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "d72511a0c3e21fd5fde9cb00745654ca886b1fc7"
20
+ "gitHead": "597f124ef73efa97a2da52b4de3c7d733ebd6887"
21
21
  }
@@ -1,33 +0,0 @@
1
- module.exports = {
2
- customize:function (object_name, record_id, fields) {
3
- var doc = Creator.odata.get(object_name, record_id);
4
- var newDoc = {}
5
- _.each(Creator.getObject(object_name).fields, function(v, k){
6
- if(_.has(doc, k)){
7
- newDoc[k] = doc[k]
8
- }
9
- })
10
- delete newDoc.is_system;
11
-
12
- let docName = doc.name
13
- let docObjectName = doc.object
14
-
15
- Creator.odata.insert(object_name, Object.assign(newDoc, {name: docName, object: docObjectName}), function(result, error){
16
- if(result){
17
- if(Session.get("object_name") === 'object_actions'){
18
- FlowRouter.go(`/app/-/${object_name}/view/${result._id}`)
19
- }else{
20
- href = Creator.getObjectUrl(object_name, result._id);
21
- window.open(href,'_blank','width=800, height=600, left=50, top= 50, toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes')
22
- }
23
- }
24
- });
25
- },
26
- customizeVisible:function(object_name, record_id, record_permissions, data){
27
- var record = data && data.record;
28
- if(!record){
29
- record = {}
30
- }
31
- return Steedos.Object.base.actions.standard_new.visible() && record.is_system && record.type == 'amis_button';
32
- }
33
- }
@@ -1,3 +0,0 @@
1
- name: customize
2
- label: 自定义
3
- 'on': record_only