@steedos/standard-object-database 2.3.0-beta.8 → 2.3.0

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.
@@ -0,0 +1,29 @@
1
+ /*
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2022-09-21 18:19:06
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2022-09-22 15:01:31
6
+ * @Description:
7
+ */
8
+ module.exports = {
9
+ showDesign: function (object_name, record_id) {
10
+ document.location = Steedos.absoluteUrl(`/api/amisButtonDesign?id=${record_id}&object=${this.record.object}`);
11
+ },
12
+ showDesignVisible: function (object_name, record_id, record_permissions) {
13
+ var perms;
14
+ var record = Creator.getObjectRecord(object_name, record_id);
15
+ if(record.type === 'amis_button'){
16
+ perms = {};
17
+ if (record_permissions) {
18
+ perms = record_permissions;
19
+ } else {
20
+ record_permissions = Creator.getRecordPermissions(object_name, record, Meteor.userId());
21
+ if (record_permissions) {
22
+ perms = record_permissions;
23
+ }
24
+ }
25
+ return perms["allowEdit"];
26
+ }
27
+ return false;
28
+ }
29
+ }
@@ -94,8 +94,8 @@ fields:
94
94
  options:
95
95
  - label: Custom JavaScript
96
96
  value: script
97
- - label: Amis Action
98
- value: amis_action
97
+ - label: Amis Button
98
+ value: amis_button
99
99
  # - label: 打印模板(word)
100
100
  # value: word-print
101
101
  defaultValue: script
@@ -109,21 +109,25 @@ fields:
109
109
  sort_no: 180
110
110
  type: code
111
111
  language: javascript
112
- required: "{{formData.type != 'amis_action' ? true: false}}"
112
+ required: "{{formData.type != 'amis_button' ? true: false}}"
113
113
  # omit: true
114
114
  # hidden: true
115
115
  is_wide: true
116
- visible_on: "{{formData.type != 'amis_action' ? true: false}}"
117
- amis_actions:
118
- label: Amis Actions
116
+ visible_on: "{{formData.type != 'amis_button' ? true: false}}"
117
+ amis_schema:
118
+ label: Amis Schema
119
119
  sort_no: 180
120
120
  type: code
121
121
  language: json
122
- required: "{{formData.type == 'amis_action' ? true: false}}"
122
+ required: false
123
123
  is_wide: true
124
- visible_on: "{{formData.type == 'amis_action' ? true: false}}"
124
+ visible_on: "{{formData.type == 'amis_button' ? true: false}}"
125
125
  paging:
126
126
  enabled: false
127
+ actions:
128
+ showDesign:
129
+ label: 设计器
130
+ on: record_only
127
131
  list_views:
128
132
  all:
129
133
  columns:
@@ -492,7 +492,7 @@ var triggers = {
492
492
  throw new Meteor.Error(500, "华炎云服务不包含自定义业务对象的功能,请部署私有云版本");
493
493
  }
494
494
  if (doc.name === "name" && !canRemoveNameFileld(doc)) {
495
- throw new Meteor.Error(500, "不能删除此纪录");
495
+ throw new Meteor.Error(500, "不能删除此记录");
496
496
  }
497
497
  }
498
498
  }
@@ -0,0 +1,44 @@
1
+ name: standard_edit
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "编辑",
9
+ "id": "u:standard_edit",
10
+ "onEvent": {
11
+ "click": {
12
+ "actions": [
13
+ {
14
+ "actionType": "custom",
15
+ "script": "const appId = null;\nconst page = Steedos.Page.getPage('form', appId, null, null, \"object_layouts\");\nif (page && page.schema) {\n const pageSchema = JSON.parse(page.schema);\n let formSchema = pageSchema.body[0];\n // 设置form的canAccessSuperData属性防止弹出窗口从父级取字段默认值\n formSchema.canAccessSuperData = false;\n // 设置form的wrapWithPanel属性隐藏其底部保存取消按钮\n formSchema.wrapWithPanel = false;\n formSchema.className = \"steedos-amis-form\";\n const title = \"编辑 页面布局\";\n doAction({\n \"actionType\": \"dialog\",\n \"dialog\": {\n \"type\": \"dialog\",\n \"title\": title,\n \"body\": [{\n \"type\": \"service\",\n \"body\": [formSchema],\n \"data\": {\n \"objectName\": \"${object_name}\",\n \"recordId\": \"${record_id}\"\n }\n }],\n \"size\": \"lg\"\n }\n });\n}"
16
+ }
17
+ ],
18
+ "weight": 0
19
+ }
20
+ },
21
+ "className": "slds-button slds-button--neutral p-0"
22
+ }
23
+ ],
24
+ "regions": [
25
+ "body"
26
+ ],
27
+ "data": {
28
+ "context": {
29
+ "rootUrl": "http://127.0.0.1:5000"
30
+ },
31
+ "app_id": "",
32
+ "tab_id": "",
33
+ "object_name": "",
34
+ "dataComponentId": "",
35
+ "record_id": "",
36
+ "record": {},
37
+ "permissions": {}
38
+ },
39
+ "bodyClassName": "p-0"
40
+ }
41
+ is_enable: true
42
+ label: 编辑
43
+ 'on': record_only
44
+ type: amis_button
@@ -35,17 +35,8 @@ module.exports = {
35
35
  gridName: gridName
36
36
  };
37
37
  const fullScreenProps = {
38
- width: "unset",
39
- style: {
40
- top: "50px",
41
- bottom: "50px",
42
- left: "50px",
43
- right: "50px",
44
- padding: "0px",
45
- margin: "0px",
46
- width: "unset"
47
- },
48
- className: "absolute"
38
+ "width": "96%",
39
+ className: "!max-w-[96%]"
49
40
  };
50
41
  Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
51
42
  appId: appId,
@@ -57,6 +48,7 @@ module.exports = {
57
48
  });
58
49
  }
59
50
  },
51
+ /*
60
52
  standard_edit: function (object_name, record_id, fields){
61
53
  var object = Creator.getObject(object_name);
62
54
  var gridName = this.action.gridName;
@@ -68,17 +60,8 @@ module.exports = {
68
60
  gridName: gridName
69
61
  };
70
62
  const fullScreenProps = {
71
- width: "unset",
72
- style: {
73
- top: "50px",
74
- bottom: "50px",
75
- left: "50px",
76
- right: "50px",
77
- padding: "0px",
78
- margin: "0px",
79
- width: "unset"
80
- },
81
- className: "absolute"
63
+ "width": "96%",
64
+ className: "!max-w-[96%]"
82
65
  };
83
66
  Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
84
67
  appId: appId,
@@ -90,4 +73,5 @@ module.exports = {
90
73
  });
91
74
  }
92
75
  }
76
+ */
93
77
  }
@@ -323,12 +323,20 @@ fields:
323
323
  type: number
324
324
  scale: 0
325
325
  defaultValue: 5
326
+ is_system:
327
+ type: boolean
328
+ label: System
329
+ # omit: true
330
+ readonly: true
331
+ visible_on: "{{global.mode ==='read' ? true : false}}"
332
+ disabled: true
326
333
  list_views:
327
334
  all:
328
335
  columns:
329
336
  - label
330
337
  - object_name
331
338
  - profiles
339
+ - is_system
332
340
  label: All
333
341
  filter_scope: space
334
342
  actions:
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-03-28 09:35:34
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2022-07-26 17:21:35
5
+ * @LastEditTime: 2022-10-27 15:49:00
6
6
  * @Description:
7
7
  */
8
8
  module.exports = {
@@ -34,7 +34,7 @@ module.exports = {
34
34
  return Creator.baseObject.actions.standard_new.visible() && record.is_system;
35
35
  },
36
36
  copy: function(object_name, record_id){
37
- let newRecord = _.clone(Creator.getListView(Session.get("object_name"), record_id));
37
+ let newRecord = null; // _.clone(Creator.getListView(Session.get("object_name"), record_id));
38
38
  if(!newRecord){
39
39
  let doc = Creator.odata.get(object_name, record_id);
40
40
  if(!doc.columns || !doc.columns.length){
@@ -84,7 +84,6 @@ module.exports = {
84
84
  data._filters_function = data.filters;
85
85
  }
86
86
  }
87
-
88
87
  Steedos.Page.Form.StandardNew.render(Session.get("app_id"), 'object_listviews', t("creator_list_copy_list_view"), data, {});
89
88
  },
90
89
  copyVisible: function(object_name, record_id, record_permissions, record){
@@ -273,6 +273,13 @@ fields:
273
273
  type: number
274
274
  scale: 0
275
275
  defaultValue: 100
276
+ is_system:
277
+ type: boolean
278
+ label: System
279
+ # omit: true
280
+ readonly: true
281
+ visible_on: "{{global.mode ==='read' ? true : false}}"
282
+ disabled: true
276
283
  paging:
277
284
  enabled: false
278
285
  list_views:
@@ -283,6 +290,7 @@ list_views:
283
290
  - shared
284
291
  - owner
285
292
  - modified
293
+ - is_system
286
294
  label: All List View
287
295
  filter_scope: space
288
296
  actions:
@@ -0,0 +1,178 @@
1
+ <!--
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2022-06-02 17:45:15
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2022-09-22 15:10:22
6
+ * @Description:
7
+ -->
8
+ <html>
9
+ <head>
10
+ <script src="/unpkg.com/@steedos-builder/fiddle@0.0.5/dist/builder-fiddle.umd.js"></script>
11
+ <script src="/unpkg.com/axios@0.26.1/dist/axios.min.js"></script>
12
+ </head>
13
+
14
+ <body>
15
+ <builder-fiddle host="<%=builderHost%>"></builder-fiddle>
16
+ <script>
17
+ const settings = {
18
+ assetUrls: "<%=assetUrls%>",
19
+ rootUrl: "<%=rootUrl%>",
20
+ userId: "<%=userId%>",
21
+ tenantId: "<%=tenantId%>",
22
+ authToken: "<%=authToken%>",
23
+ id: "<%=id%>",
24
+ pageId: "<%=id%>",
25
+ messageOnly: true,
26
+ hiddenDeploy: true
27
+ };
28
+
29
+ let comp = document.querySelector("builder-fiddle");
30
+
31
+ const loadPage = async () => {
32
+ const { assetUrls, rootUrl, userId, tenantId, authToken, id } = settings;
33
+
34
+ // 如果传入 steedos rooturl
35
+ if (rootUrl && !authToken) return;
36
+
37
+ const initialContent = {
38
+ type: "service",
39
+ bodyClassName: 'p-0',
40
+ regions: [
41
+ "body"
42
+ ]
43
+ };
44
+
45
+ if (id) {
46
+ const result = await axios.post(
47
+ `${rootUrl}/graphql`,
48
+ {
49
+ query: `
50
+ {
51
+ record:object_actions__findOne(id: "${id}"){
52
+ _id,
53
+ label,
54
+ type,
55
+ name,
56
+ amis_schema,
57
+ object
58
+ }
59
+ }
60
+ `
61
+ },
62
+ {
63
+ withCredentials: true,
64
+ headers: { Authorization: `Bearer ${tenantId},${authToken}` },
65
+ }
66
+ );
67
+ if (result?.data?.data) {
68
+ const button = result.data.data.record;
69
+ let schema = button?.amis_schema ;
70
+ if(!schema){
71
+ schema = Object.assign({}, initialContent, {body: [
72
+ {
73
+ type: "button",
74
+ label: button ? button.label : "",
75
+ id: button ? `u:${button.name}` : "",
76
+ }
77
+ ]});
78
+ }
79
+
80
+ let objectName = result.data.object;
81
+ let pageType = result.data.type;
82
+ if (typeof schema === "string") {
83
+ schema = JSON.parse(schema);
84
+ }
85
+
86
+ if (!schema.data) {
87
+ schema.data = {};
88
+ }
89
+
90
+ if (!schema.data.context) {
91
+ schema.data.context = {};
92
+ }
93
+
94
+ schema.data.app_id = '';
95
+ schema.data.tab_id = '';
96
+ schema.data.object_name = '';
97
+ schema.data.dataComponentId = '';
98
+ schema.data.record_id = '';
99
+ schema.data.record = {};
100
+ schema.data.permissions = {};
101
+
102
+ schema.data.context.rootUrl = rootUrl;
103
+ schema.data.context.tenantId = tenantId;
104
+ schema.data.context.userId = userId;
105
+ schema.data.context.authToken = authToken;
106
+
107
+ return schema || initialContent
108
+ }
109
+ } else {
110
+ return initialContent
111
+ }
112
+ };
113
+
114
+ const savePage = async (data) => {
115
+ const { rootUrl, userId, tenantId, authToken, id } = settings;
116
+
117
+ if (!id) {
118
+ return;
119
+ }
120
+
121
+ // 保存schema时,清理context下的认证信息
122
+ const schema = JSON.parse(
123
+ JSON.stringify(data.data.AmisSchema, null, 4)
124
+ );
125
+ if (schema.data && typeof schema.data.context === 'object' ) {
126
+ delete schema.data.context.userId;
127
+ delete schema.data.context.tenantId;
128
+ delete schema.data.context.authToken;
129
+ delete schema.data.context.user;
130
+ }
131
+ return await axios.post(
132
+ `${rootUrl}/graphql`,
133
+ {
134
+ query: `
135
+ mutation{
136
+ object_actions__update(id: "${id}", doc: {amis_schema: ${JSON.stringify(JSON.stringify(schema, null, 4))}}){_id}
137
+ }
138
+ `,
139
+ },
140
+ {
141
+ withCredentials: true,
142
+ headers: { Authorization: `Bearer ${tenantId},${authToken}` },
143
+ }
144
+ )
145
+ .catch(function (error) {
146
+ // handle error
147
+ console.log(error);
148
+ });
149
+ };
150
+
151
+ const deployPageVersion = async () => {
152
+
153
+ };
154
+ window.addEventListener('message', function (event) {
155
+ const { data } = event;
156
+ if (data) {
157
+ if (data.type === 'builder.loadContent') {
158
+ loadPage().then((content)=>{
159
+ comp.messageFrame('builder.contentChanged', { AmisSchema : content } )
160
+ })
161
+ }
162
+ if (data.type === 'builder.saveContent') {
163
+ savePage(data.data).then(()=>{
164
+ comp.messageFrame('builder.contentSaved')
165
+ })
166
+ }
167
+ if(data.type === "builder.deployContent"){
168
+ deployPageVersion().then(()=>{
169
+ comp.messageFrame('builder.contentDeployed')
170
+ })
171
+ }
172
+ }
173
+ })
174
+
175
+ comp.settings = settings;
176
+ </script>
177
+ </body>
178
+ </html>
@@ -0,0 +1,67 @@
1
+ /*
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2022-04-04 16:34:28
4
+ * @Description:
5
+ */
6
+ const express = require("express");
7
+ const router = express.Router();
8
+ const core = require('@steedos/core');
9
+ const ejs = require('ejs');
10
+ const fs = require('fs');
11
+ const _ = require('lodash');
12
+ const path = require('path');
13
+
14
+ router.get('/api/amisButtonDesign', core.requireAuthentication, async function (req, res) {
15
+ try {
16
+ res.set('Content-Type', 'text/html');
17
+ const userSession = req.user;
18
+ let assetUrl = "";
19
+ let assetUrls = null;
20
+ if(process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS && _.isString(process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS)){
21
+ assetUrls = process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS.split(',');
22
+ assetUrl = `assetUrl=${assetUrls.join("&assetUrl=")}&`;
23
+ }else{
24
+ var fullPath = path.resolve(path.dirname(require.resolve('@steedos-ui/builder-widgets' + '/package.json')));
25
+ var packageFile = path.join(fullPath,'package.json');
26
+ var pkg = require(packageFile);
27
+ moduleVersion = pkg.version;
28
+ assetUrls = [`https://unpkg.com/@steedos-ui/builder-widgets@${moduleVersion}/dist/assets.json`];
29
+ assetUrl = `assetUrl=${assetUrls.join("&assetUrl=")}&`;
30
+ }
31
+
32
+ // const dataContext = {
33
+ // rootUrl: __meteor_runtime_config__.ROOT_URL,
34
+ // tenantId: userSession.spaceId,
35
+ // userId: userSession.userId,
36
+ // authToken: userSession.authToken
37
+ // }
38
+
39
+ const retUrl = __meteor_runtime_config__.ROOT_URL + `/app/admin/objects/${req.query.object}/object_actions/grid?related_field_name=object`
40
+ const steedosBuilderUrl = process.env.STEEDOS_BUILDER_URL || 'https://builder.steedos.cn';
41
+ const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}&retUrl=${retUrl}`;
42
+
43
+ // let data = fs.readFileSync(__dirname+'/design.html', 'utf8');
44
+ // res.send(data.replace('SteedosBuilderHost',steedosBuilderHost).replace('DataContext', JSON.stringify(dataContext)));
45
+
46
+ const filename = __dirname+'/amis_button_design.ejs'
47
+ const data = {
48
+ builderHost,
49
+ assetUrls,
50
+ rootUrl: __meteor_runtime_config__.ROOT_URL,
51
+ tenantId: userSession.spaceId,
52
+ userId: userSession.userId,
53
+ authToken: userSession.authToken,
54
+ id: req.query.id,
55
+ }
56
+ const options = {}
57
+ ejs.renderFile(filename, data, options, function(err, str){
58
+ // str => Rendered HTML string
59
+ res.send(str);
60
+ });
61
+
62
+ } catch (error) {
63
+ res.status(500).send({ message: error.message });
64
+ }
65
+
66
+ });
67
+ exports.default = router;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.3.0-beta.8",
3
+ "version": "2.3.0",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,5 +12,5 @@
12
12
  "description": "steedos package",
13
13
  "repository": {},
14
14
  "license": "MIT",
15
- "gitHead": "d0bfd52568ee68e3af0f251c06bd8169e823851f"
15
+ "gitHead": "b00e79e6fb8549b2fabed7b6cd6d4847775ba5df"
16
16
  }