@steedos/standard-object-database 2.3.1-beta.3 → 2.3.1-beta.5
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.
|
@@ -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-11-
|
|
5
|
+
* @LastEditTime: 2022-11-14 16:05:37
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
module.exports = {
|
|
@@ -89,5 +89,21 @@ module.exports = {
|
|
|
89
89
|
},
|
|
90
90
|
copyVisible: function(object_name, record_id, record_permissions, record){
|
|
91
91
|
return true;
|
|
92
|
+
},
|
|
93
|
+
showDesign: function (object_name, record_id) {
|
|
94
|
+
document.location = Steedos.absoluteUrl(`/api/amisListviewDesign?id=${record_id}&object=${this.record.object_name}`);
|
|
95
|
+
},
|
|
96
|
+
showDesignVisible: function (object_name, record_id, record_permissions) {
|
|
97
|
+
var perms= {};
|
|
98
|
+
var record = Creator.getObjectRecord(object_name, record_id);
|
|
99
|
+
if (record_permissions) {
|
|
100
|
+
perms = record_permissions;
|
|
101
|
+
} else {
|
|
102
|
+
record_permissions = Creator.getRecordPermissions(object_name, record, Meteor.userId());
|
|
103
|
+
if (record_permissions) {
|
|
104
|
+
perms = record_permissions;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return perms["allowEdit"];
|
|
92
108
|
}
|
|
93
109
|
}
|
|
@@ -280,6 +280,13 @@ fields:
|
|
|
280
280
|
readonly: true
|
|
281
281
|
visible_on: "{{global.mode ==='read' ? true : false}}"
|
|
282
282
|
disabled: true
|
|
283
|
+
amis_schema:
|
|
284
|
+
label: Amis Schema
|
|
285
|
+
type: code
|
|
286
|
+
language: json
|
|
287
|
+
required: false
|
|
288
|
+
is_wide: true
|
|
289
|
+
# visible_on: "{{formData.type == 'amis_button' ? true: false}}"
|
|
283
290
|
paging:
|
|
284
291
|
enabled: false
|
|
285
292
|
list_views:
|
|
@@ -300,6 +307,9 @@ actions:
|
|
|
300
307
|
copy:
|
|
301
308
|
label: 复制
|
|
302
309
|
on: record_only
|
|
310
|
+
showDesign:
|
|
311
|
+
label: 设计器
|
|
312
|
+
on: record_only
|
|
303
313
|
permission_set:
|
|
304
314
|
user:
|
|
305
315
|
allowCreate: true
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: baozhoutao@steedos.com
|
|
3
|
+
* @Date: 2022-06-02 17:45:15
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2022-11-14 16:06:17
|
|
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_listviews__findOne(id: "${id}"){
|
|
52
|
+
_id,
|
|
53
|
+
label,
|
|
54
|
+
type,
|
|
55
|
+
name,
|
|
56
|
+
amis_schema,
|
|
57
|
+
object: object_name
|
|
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
|
+
]});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let objectName = result.data.object;
|
|
77
|
+
if (typeof schema === "string") {
|
|
78
|
+
schema = JSON.parse(schema);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!schema.data) {
|
|
82
|
+
schema.data = {};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!schema.data.context) {
|
|
86
|
+
schema.data.context = {};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
schema.data.app_id = '';
|
|
90
|
+
schema.data.tab_id = '';
|
|
91
|
+
schema.data.object_name = '';
|
|
92
|
+
schema.data.dataComponentId = '';
|
|
93
|
+
schema.data.record_id = '';
|
|
94
|
+
schema.data.record = {};
|
|
95
|
+
schema.data.permissions = {};
|
|
96
|
+
|
|
97
|
+
schema.data.context.rootUrl = rootUrl;
|
|
98
|
+
schema.data.context.tenantId = tenantId;
|
|
99
|
+
schema.data.context.userId = userId;
|
|
100
|
+
schema.data.context.authToken = authToken;
|
|
101
|
+
|
|
102
|
+
return schema || initialContent
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
return initialContent
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const savePage = async (data) => {
|
|
110
|
+
const { rootUrl, userId, tenantId, authToken, id } = settings;
|
|
111
|
+
|
|
112
|
+
if (!id) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 保存schema时,清理context下的认证信息
|
|
117
|
+
const schema = JSON.parse(
|
|
118
|
+
JSON.stringify(data.data.AmisSchema, null, 4)
|
|
119
|
+
);
|
|
120
|
+
if (schema.data && typeof schema.data.context === 'object' ) {
|
|
121
|
+
delete schema.data.context.userId;
|
|
122
|
+
delete schema.data.context.tenantId;
|
|
123
|
+
delete schema.data.context.authToken;
|
|
124
|
+
delete schema.data.context.user;
|
|
125
|
+
}
|
|
126
|
+
return await axios.post(
|
|
127
|
+
`${rootUrl}/graphql`,
|
|
128
|
+
{
|
|
129
|
+
query: `
|
|
130
|
+
mutation{
|
|
131
|
+
object_listviews__update(id: "${id}", doc: {amis_schema: ${JSON.stringify(JSON.stringify(schema, null, 4))}}){_id}
|
|
132
|
+
}
|
|
133
|
+
`,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
withCredentials: true,
|
|
137
|
+
headers: { Authorization: `Bearer ${tenantId},${authToken}` },
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
.catch(function (error) {
|
|
141
|
+
// handle error
|
|
142
|
+
console.log(error);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const deployPageVersion = async () => {
|
|
147
|
+
|
|
148
|
+
};
|
|
149
|
+
window.addEventListener('message', function (event) {
|
|
150
|
+
const { data } = event;
|
|
151
|
+
if (data) {
|
|
152
|
+
if (data.type === 'builder.loadContent') {
|
|
153
|
+
loadPage().then((content)=>{
|
|
154
|
+
comp.messageFrame('builder.contentChanged', { AmisSchema : content } )
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
if (data.type === 'builder.saveContent') {
|
|
158
|
+
savePage(data.data).then(()=>{
|
|
159
|
+
comp.messageFrame('builder.contentSaved')
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
if(data.type === "builder.deployContent"){
|
|
163
|
+
deployPageVersion().then(()=>{
|
|
164
|
+
comp.messageFrame('builder.contentDeployed')
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
comp.settings = settings;
|
|
171
|
+
</script>
|
|
172
|
+
</body>
|
|
173
|
+
</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/amisListviewDesign', 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_listviews/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_listview_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.1-beta.
|
|
3
|
+
"version": "2.3.1-beta.5",
|
|
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": "
|
|
15
|
+
"gitHead": "4f0d77534bc26bc9b69d1c14f63de97cb03c6806"
|
|
16
16
|
}
|