@steedos/service-plugin-amis 2.2.22 → 2.2.23

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.
@@ -44,67 +44,26 @@
44
44
  });
45
45
 
46
46
  const AmisEnv = {
47
- fetcher: ({url, method, data, config}) => {
48
- console.log('fetcher. url', url);
49
- if(url.startsWith("http") && url.indexOf("://") == -1){
50
- url = decodeURIComponent(url)
47
+ getModalContainer: ()=>{
48
+ let div = document.querySelector("#amisModalContainer");
49
+ if(!div){
50
+ div = document.createElement('div');
51
+ div.className="amis-scope";
52
+ div.style.height='0px';
53
+ div.id="amisModalContainer";
54
+ document.body.appendChild(div)
51
55
  }
52
- config = config || {};
53
- config.headers = config.headers || {};
54
- config.withCredentials = true;
55
-
56
- if (method !== 'post' && method !== 'put' && method !== 'patch') {
57
- if (data) {
58
- config.params = data;
59
- }
60
- return (axios)[method](url, config);
61
- } else if (data && data instanceof FormData) {
62
- // config.headers = config.headers || {};
63
- // config.headers['Content-Type'] = 'multipart/form-data';
64
- } else if (
65
- data &&
66
- typeof data !== 'string' &&
67
- !(data instanceof Blob) &&
68
- !(data instanceof ArrayBuffer)
69
- ) {
70
- data = JSON.stringify(data);
71
- config.headers['Content-Type'] = 'application/json';
72
- }
73
-
74
- return (axios)[method](url, data, config);
75
- },
76
- isCancel: (e) => axios.isCancel(e),
77
- updateLocation: ((location, replace) => {
78
- console.debug('updateLocation==>', location, replace);
79
- // const history = this.props.history;
80
- // if (location === 'goBack') {
81
- // return history.goBack();
82
- // } else if (/^https?\:\/\//.test(location)) {
83
- // return (window.location.href = location);
84
- // }
85
- // history[replace ? 'replace' : 'push'](normalizeLink(location, replace));
86
- }),
87
- notify: (type, msg) => {
88
- AmisSDK.amis.toast[type]
89
- ? AmisSDK.amis.toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
90
- : console.warn('[Notify]', type, msg);
91
- console.log('[notify]', type, msg);
56
+ return div;
92
57
  },
93
- alert: AmisSDK.amis.alert,
94
- confirm: AmisSDK.amis.confirm,
95
- // copy: (contents, options = {}) => {
96
- // const ret = copy(contents, options);
97
- // ret && (!options || options.shutup !== true) && toast.info('内容已拷贝到剪切板');
98
- // return ret;
99
- // },
100
- theme: 'cxd',
58
+ theme: 'antd',
101
59
  };
102
60
 
103
61
  const AmisRender = function (props) {
104
62
  const env = props.env;
105
63
  const schema = props.schema;
106
64
  const data = props.data;
107
- return (React.createElement("div", { className: "amis-scope" }, AmisSDK.amis.render(schema, data, Object.assign({}, AmisEnv, env))));
65
+ const name = props.name;
66
+ return (React.createElement("div", { className: "amis-scope" }, AmisSDK.AmisRender(schema, {data, name}, Object.assign({}, AmisEnv, env))));
108
67
  };
109
68
 
110
69
  Builder.registerComponent(AmisRender, {
@@ -112,6 +71,7 @@
112
71
  inputs: [
113
72
  { name: 'schema', type: 'object' },
114
73
  { name: 'data', type: 'object' },
74
+ { name: 'name', type: 'string' }
115
75
  ]
116
76
  });
117
77
  });
@@ -0,0 +1,128 @@
1
+ /*
2
+ * @Date: 2022-04-19 11:36:12
3
+ * @Description: 提供设计器需要的数据接口
4
+ */
5
+
6
+ const objectql = require("@steedos/objectql");
7
+ const steedosI18n = require("@steedos/i18n");
8
+ const _ = require("underscore");
9
+ const clone = require("clone");
10
+
11
+ const ExcludeObjectNames = [
12
+ 'cfs_instances_filerecord',
13
+ 'cfs_files_filerecord',
14
+ 'cms_files',
15
+ 'chat_messages',
16
+ 'api_keys',
17
+ 'object_webhooks_queue',
18
+ 'users',
19
+ 'cms_posts',
20
+ ];
21
+
22
+
23
+ module.exports = {
24
+ name: "amis-design",
25
+ mixins: [],
26
+ /**
27
+ * Settings
28
+ */
29
+ settings: {
30
+
31
+ },
32
+
33
+ /**
34
+ * Dependencies
35
+ */
36
+ dependencies: [],
37
+
38
+ /**
39
+ * Actions
40
+ */
41
+ actions: {
42
+ getObjects: {
43
+ rest: {
44
+ method: "GET",
45
+ path: "/objects"
46
+ },
47
+ async handler(ctx) {
48
+ return await this.getObjects(ctx);
49
+ }
50
+ }
51
+ },
52
+
53
+ /**
54
+ * Events
55
+ */
56
+ events: {
57
+
58
+ },
59
+
60
+ /**
61
+ * Methods
62
+ */
63
+ methods: {
64
+ getObjects: {
65
+ async handler(ctx) {
66
+ const userSession = ctx.meta.user;
67
+ const lng = userSession.language || 'zh-CN';
68
+ const spaceId = userSession.spaceId;
69
+ const allMetadataObjects = await objectql.getSteedosSchema().getAllObject();
70
+ const allObjects = _.pluck(clone(allMetadataObjects), 'metadata');
71
+
72
+ const query = {
73
+ filters: [ ['hidden', '!=', true] , ['name', '<>', ExcludeObjectNames]],
74
+ projection: {
75
+ name: 1,
76
+ label: 1,
77
+ list_views: 1
78
+ }
79
+ };
80
+
81
+ const objects = objectql.getSteedosSchema().metadataDriver.find(allObjects, query, spaceId);
82
+
83
+ const dbListViews = await objectql.getObject('object_listviews').directFind({filters: [['shared', '!=', false]]})
84
+
85
+ _.each(objects, (object)=>{
86
+ if(object && object.name){
87
+
88
+ steedosI18n.translationObject(lng, object.name, object)
89
+
90
+ if(object.list_views && !_.isEmpty(object.list_views)){
91
+ _.each(object.list_views, (list_view, name)=>{
92
+ list_view.name = name;
93
+ list_view._id = list_view._id || list_view.name;
94
+ list_view.label = list_view.label || list_view.name;
95
+ })
96
+
97
+ object.list_views = objectql.getSteedosSchema().metadataDriver.find(_.values(object.list_views), {
98
+ projection: {
99
+ _id: 1,
100
+ name: 1,
101
+ label: 1
102
+ }
103
+ }, spaceId);
104
+
105
+ }
106
+
107
+ if(_.isEmpty(object.list_views)){
108
+ object.list_views = [];
109
+ }
110
+
111
+ const objectListViews = objectql.getSteedosSchema().metadataDriver.find(dbListViews, {
112
+ filters: [['object_name', '=', object.name], ['shared', '=', true] ],
113
+ fields: "_id, name, label"
114
+ }, spaceId);
115
+
116
+ _.each(object.list_views, (listView)=>{
117
+ if(!_.find(objectListViews, (dbListView)=>{ return dbListView.name === listView.name})){
118
+ objectListViews.push(listView);
119
+ }
120
+ })
121
+ object.list_views = objectListViews;
122
+ }
123
+ })
124
+ return objects;
125
+ }
126
+ }
127
+ }
128
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.2.22",
3
+ "version": "2.2.23",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -8,5 +8,5 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "gitHead": "af4ea8ed034854c8de1ff8b9d5db241183524417"
11
+ "gitHead": "830698bdc5c848858d24ba536d9eff0fa51c22f0"
12
12
  }
@@ -1,4 +1,8 @@
1
- @import '/amis/sdk/sdk.css';
1
+ /* @import '/amis/sdk/sdk.css'; */
2
+
3
+ @import '/unpkg.com/amis@1.8.0/lib/themes/default.css';
4
+
5
+ @import '/unpkg.com/amis@1.8.0/lib/themes/antd.css';
2
6
 
3
7
 
4
8
  /* .amis-routes-wrapper{
@@ -6,7 +10,7 @@
6
10
  } */
7
11
 
8
12
  .amis-scope{
9
- background: none;
13
+ background: #ffffff;
10
14
  }
11
15
 
12
16
  .amis-scope svg {