@steedos/standard-object-database 2.3.0-beta.3 → 2.3.0-beta.30
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.
- package/main/default/objects/object_actions.action.js +29 -0
- package/main/default/objects/object_actions.object.yml +12 -8
- package/main/default/objects/object_fields.object.js +1 -1
- package/main/default/objects/object_layouts.layouts.action.js +56 -0
- package/main/default/routes/amis_button_design.ejs +178 -0
- package/main/default/routes/amis_button_design.router.js +67 -0
- package/package.json +2 -2
|
@@ -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
|
|
98
|
-
value:
|
|
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 != '
|
|
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 != '
|
|
117
|
-
|
|
118
|
-
label: Amis
|
|
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:
|
|
122
|
+
required: false
|
|
123
123
|
is_wide: true
|
|
124
|
-
visible_on: "{{formData.type == '
|
|
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
|
}
|
|
@@ -15,5 +15,61 @@ module.exports = {
|
|
|
15
15
|
},
|
|
16
16
|
customizeVisible: function(object_name, record_id, record_permissions, record){
|
|
17
17
|
return Creator.baseObject.actions.standard_new.visible() && record.is_system;
|
|
18
|
+
},
|
|
19
|
+
standard_new: function (object_name, record_id, fields){
|
|
20
|
+
var object = Creator.getObject(object_name);
|
|
21
|
+
var gridName = this.action.gridName;
|
|
22
|
+
// var isRelated = this.action.isRelated;
|
|
23
|
+
var relatedFieldName = this.action.relatedFieldName;
|
|
24
|
+
var masterRecordId = this.action.masterRecordId;
|
|
25
|
+
var initialValues = this.action.initialValues
|
|
26
|
+
if(!initialValues){
|
|
27
|
+
initialValues = {};
|
|
28
|
+
initialValues[relatedFieldName] = masterRecordId
|
|
29
|
+
}
|
|
30
|
+
const appId = Session.get("app_id");
|
|
31
|
+
const page = Steedos.Page.getPage('form', appId, object_name);
|
|
32
|
+
const title = t('New') + ' ' + object.label;
|
|
33
|
+
if (page && page.schema) {
|
|
34
|
+
const options = {
|
|
35
|
+
gridName: gridName
|
|
36
|
+
};
|
|
37
|
+
const fullScreenProps = {
|
|
38
|
+
"width": "96%",
|
|
39
|
+
className: "!max-w-[96%]"
|
|
40
|
+
};
|
|
41
|
+
Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
|
|
42
|
+
appId: appId,
|
|
43
|
+
objectName: object_name,
|
|
44
|
+
title: title,
|
|
45
|
+
data: initialValues,
|
|
46
|
+
}), {
|
|
47
|
+
props: fullScreenProps
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
standard_edit: function (object_name, record_id, fields){
|
|
52
|
+
var object = Creator.getObject(object_name);
|
|
53
|
+
var gridName = this.action.gridName;
|
|
54
|
+
const appId = Session.get("app_id");
|
|
55
|
+
const page = Steedos.Page.getPage('form', appId, object_name, record_id);
|
|
56
|
+
const title = t('Edit') + ' ' + object.label;
|
|
57
|
+
if (page && page.schema) {
|
|
58
|
+
const options = {
|
|
59
|
+
gridName: gridName
|
|
60
|
+
};
|
|
61
|
+
const fullScreenProps = {
|
|
62
|
+
"width": "96%",
|
|
63
|
+
className: "!max-w-[96%]"
|
|
64
|
+
};
|
|
65
|
+
Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
|
|
66
|
+
appId: appId,
|
|
67
|
+
objectName: object_name,
|
|
68
|
+
title: title,
|
|
69
|
+
recordId: record_id
|
|
70
|
+
}), {
|
|
71
|
+
props: fullScreenProps
|
|
72
|
+
});
|
|
73
|
+
}
|
|
18
74
|
}
|
|
19
75
|
}
|
|
@@ -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.
|
|
3
|
+
"version": "2.3.0-beta.30",
|
|
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": "edcebd33164ec6148abccda56589416638b1872d"
|
|
16
16
|
}
|