@steedos/service-pages 2.2.34 → 2.2.37
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/client/page.render.client.js +60 -20
- package/main/default/objects/pages/buttons/deploy.button.js +9 -4
- package/main/default/objects/pages/buttons/deploy.button.yml +2 -1
- package/main/default/objects/pages/buttons/disable.button.yml +2 -1
- package/main/default/objects/pages/buttons/enable.button.yml +2 -1
- package/main/default/objects/pages/buttons/resetSchema.button.js +47 -0
- package/main/default/objects/pages/buttons/resetSchema.button.yml +6 -0
- package/main/default/objects/pages/buttons/showDesign.button.yml +2 -1
- package/main/default/objects/pages/fields/version.field.yml +3 -2
- package/main/default/routes/page_design.ejs +0 -1
- package/main/default/routes/page_design.router.js +1 -0
- package/main/default/services/page.service.js +43 -0
- package/main/default/triggers/page_versions_metadata.trigger.js +4 -3
- package/main/default/triggers/pages_init.trigger.js +50 -0
- package/package.json +2 -2
|
@@ -57,8 +57,7 @@
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
Steedos.Page.render = function (root, page, data) {
|
|
61
|
-
|
|
60
|
+
Steedos.Page.render = function (root, page, data, options) {
|
|
62
61
|
const loadingContentData = {
|
|
63
62
|
"inputs": [],
|
|
64
63
|
// "title": "loading",
|
|
@@ -111,7 +110,8 @@
|
|
|
111
110
|
if (page.render_engine && page.render_engine != 'redash') {
|
|
112
111
|
|
|
113
112
|
let schema = typeof page.schema === 'string' ? JSON.parse(page.schema) : page.schema;
|
|
114
|
-
|
|
113
|
+
|
|
114
|
+
const defData = lodash.defaultsDeep({}, data , {
|
|
115
115
|
data: {
|
|
116
116
|
context: {
|
|
117
117
|
rootUrl: __meteor_runtime_config__.ROOT_URL,
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
authToken: Creator.USER_CONTEXT.user.authToken
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
})
|
|
123
|
+
});
|
|
124
124
|
|
|
125
125
|
schema = lodash.defaultsDeep(defData , schema);
|
|
126
126
|
|
|
@@ -135,7 +135,8 @@
|
|
|
135
135
|
"options": {
|
|
136
136
|
"schema": schema,
|
|
137
137
|
"data": data,
|
|
138
|
-
"name": page.name
|
|
138
|
+
"name": page.name,
|
|
139
|
+
"pageType": page.type
|
|
139
140
|
}
|
|
140
141
|
},
|
|
141
142
|
}
|
|
@@ -148,23 +149,62 @@
|
|
|
148
149
|
return lodash.find(obj, {name : componentName})
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
if(!lodash.isFunction(root)){
|
|
153
|
+
//渲染loading
|
|
154
|
+
SteedosUI.render(BuilderComponent, {
|
|
155
|
+
model: "page", content: {
|
|
156
|
+
"data": loadingContentData
|
|
157
|
+
}
|
|
158
|
+
}, root)
|
|
159
|
+
}
|
|
157
160
|
|
|
158
161
|
Promise.all([
|
|
159
162
|
waitForThing(window, 'BuilderComponent'),
|
|
160
163
|
waitForThing(Builder.components, upperFirst(page.render_engine), findComponent)
|
|
161
164
|
]).then(()=>{
|
|
162
165
|
//渲染page
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
+
if(!lodash.isFunction(root)){
|
|
167
|
+
SteedosUI.render(BuilderComponent, {
|
|
168
|
+
model: "page", content: {
|
|
169
|
+
"data": pageContentData
|
|
170
|
+
}
|
|
171
|
+
}, root)
|
|
172
|
+
}else{
|
|
173
|
+
if(root === SteedosUI.Drawer){
|
|
174
|
+
data.drawerName = data.drawerName || lodash.uniqueId(`drawer-${page.object_name}`);
|
|
175
|
+
SteedosUI.Drawer(Object.assign({
|
|
176
|
+
name: data.drawerName,
|
|
177
|
+
title: data.title,
|
|
178
|
+
destroyOnClose: true,
|
|
179
|
+
maskClosable: false,
|
|
180
|
+
footer: null,
|
|
181
|
+
bodyStyle: {padding: "0px", paddingTop: "12px"},
|
|
182
|
+
children: React.createElement(BuilderComponent, {
|
|
183
|
+
model: "page", content: {
|
|
184
|
+
"data": pageContentData
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
}, options?.props)).show();
|
|
188
|
+
}else{
|
|
189
|
+
data.modalName = data.modalName || lodash.uniqueId(`modal-${page.object_name}`);
|
|
190
|
+
SteedosUI.Modal(Object.assign({
|
|
191
|
+
name: data.modalName,
|
|
192
|
+
title: data.title,
|
|
193
|
+
destroyOnClose: true,
|
|
194
|
+
maskClosable: false,
|
|
195
|
+
keyboard: false, // 禁止 esc 关闭
|
|
196
|
+
footer: null,
|
|
197
|
+
bodyStyle: {padding: "0px", paddingTop: "12px"},
|
|
198
|
+
children: React.createElement(BuilderComponent, {
|
|
199
|
+
model: "page", content: {
|
|
200
|
+
"data": pageContentData
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
}, options?.props)).show();
|
|
166
204
|
}
|
|
167
|
-
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
}
|
|
168
208
|
});
|
|
169
209
|
}
|
|
170
210
|
|
|
@@ -287,12 +327,12 @@
|
|
|
287
327
|
Steedos.Page.Form.StandardNew.render = function (appId, objectApiName, title, initialValues, options) {
|
|
288
328
|
const page = Steedos.Page.getPage('form', appId, objectApiName);
|
|
289
329
|
if (page && page.schema) {
|
|
290
|
-
const elementId = getModalElement(`${objectApiName}-standard_new`);
|
|
291
|
-
return Steedos.Page.render(
|
|
330
|
+
// const elementId = getModalElement(`${objectApiName}-standard_new`);
|
|
331
|
+
return Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
|
|
292
332
|
appId: appId,
|
|
293
333
|
objectName: objectApiName,
|
|
294
334
|
title: title,
|
|
295
|
-
|
|
335
|
+
data: initialValues,
|
|
296
336
|
}));
|
|
297
337
|
}
|
|
298
338
|
|
|
@@ -318,8 +358,8 @@
|
|
|
318
358
|
Steedos.Page.Form.StandardEdit.render = function (appId, objectApiName, title, recordId, options) {
|
|
319
359
|
const page = Steedos.Page.getPage('form', appId, objectApiName, recordId);
|
|
320
360
|
if (page && page.schema) {
|
|
321
|
-
const elementId = getModalElement(`${objectApiName}-standard_edit`);
|
|
322
|
-
return Steedos.Page.render(
|
|
361
|
+
// const elementId = getModalElement(`${objectApiName}-standard_edit`);
|
|
362
|
+
return Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, options, {
|
|
323
363
|
appId: appId,
|
|
324
364
|
objectName: objectApiName,
|
|
325
365
|
title: title,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: baozhoutaon@hotoa.com
|
|
3
3
|
* @Date: 2022-03-29 20:33:44
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime: 2022-
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2022-05-28 17:44:34
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
module.exports = {
|
|
@@ -14,13 +14,18 @@ module.exports = {
|
|
|
14
14
|
async: true,
|
|
15
15
|
data: JSON.stringify({ pageId: record_id }),
|
|
16
16
|
success: function (data) {
|
|
17
|
-
|
|
17
|
+
SteedosUI.notification.success({
|
|
18
|
+
message: '页面已发布。'
|
|
19
|
+
});
|
|
18
20
|
SteedosUI.reloadRecord(object_name, record_id);
|
|
19
21
|
FlowRouter.reload();
|
|
20
22
|
$(document.body).removeClass('loading');
|
|
21
23
|
},
|
|
22
24
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
23
|
-
|
|
25
|
+
SteedosUI.notification.error({
|
|
26
|
+
message: '操作失败',
|
|
27
|
+
description: t(XMLHttpRequest.responseJSON.error),
|
|
28
|
+
});
|
|
24
29
|
$(document.body).removeClass('loading');
|
|
25
30
|
}
|
|
26
31
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: baozhoutaon@hotoa.com
|
|
3
|
+
* @Date: 2022-03-29 20:33:44
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2022-05-27 18:08:21
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
resetSchema: function (object_name, record_id) {
|
|
10
|
+
SteedosUI.Modal.confirm({
|
|
11
|
+
title: "重置页面",
|
|
12
|
+
content: "重置页面后,会根据最新的对象字段配置生成一个新的页面版本.",
|
|
13
|
+
onOk: function(){
|
|
14
|
+
$(document.body).addClass('loading');
|
|
15
|
+
let url = `/service/api/page/resetDefaultSchema`;
|
|
16
|
+
let options = {
|
|
17
|
+
type: 'post',
|
|
18
|
+
async: true,
|
|
19
|
+
data: JSON.stringify({ pageId: record_id }),
|
|
20
|
+
success: function (data) {
|
|
21
|
+
SteedosUI.notification.success({
|
|
22
|
+
message: '操作成功',
|
|
23
|
+
description: `页面已重置.`,
|
|
24
|
+
});
|
|
25
|
+
SteedosUI.router.go({
|
|
26
|
+
type: 'new',
|
|
27
|
+
objectName: object_name,
|
|
28
|
+
recordId: record_id
|
|
29
|
+
});
|
|
30
|
+
$(document.body).removeClass('loading');
|
|
31
|
+
},
|
|
32
|
+
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
33
|
+
SteedosUI.notification.error({
|
|
34
|
+
message: '操作失败',
|
|
35
|
+
description: t(XMLHttpRequest.responseJSON.error),
|
|
36
|
+
});
|
|
37
|
+
$(document.body).removeClass('loading');
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Steedos.authRequest(url, options);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
resetSchemaVisible: function (object_name, record_id, permission, record) {
|
|
45
|
+
return record && !record.is_system && record.type === 'form';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -28,6 +28,7 @@ router.get('/api/pageDesign', core.requireAuthentication, async function (req, r
|
|
|
28
28
|
|
|
29
29
|
const retUrl = __meteor_runtime_config__.ROOT_URL + '/app/admin/pages/view/' + req.query.pageId
|
|
30
30
|
const builderHost = `https://builder.steedos.com/amis?${assetUrl}&retUrl=${retUrl}`;
|
|
31
|
+
// const builderHost = `http://127.0.0.1:3000/amis?${assetUrl}&retUrl=${retUrl}`;
|
|
31
32
|
|
|
32
33
|
// let data = fs.readFileSync(__dirname+'/design.html', 'utf8');
|
|
33
34
|
// res.send(data.replace('SteedosBuilderHost',steedosBuilderHost).replace('DataContext', JSON.stringify(dataContext)));
|
|
@@ -108,6 +108,49 @@ module.exports = {
|
|
|
108
108
|
const { pageId, schema } = ctx.params;
|
|
109
109
|
return await this.changePageVersion(pageId, schema, userSession);
|
|
110
110
|
}
|
|
111
|
+
},
|
|
112
|
+
resetDefaultVersion: {
|
|
113
|
+
rest: {
|
|
114
|
+
method: "POST",
|
|
115
|
+
path: "/resetDefaultSchema"
|
|
116
|
+
},
|
|
117
|
+
params: {
|
|
118
|
+
pageId: { type: 'string' }
|
|
119
|
+
},
|
|
120
|
+
handler: async function (ctx) {
|
|
121
|
+
const userSession = ctx.meta.user;
|
|
122
|
+
const { pageId } = ctx.params;
|
|
123
|
+
const page = await objectql.getObject('pages').findOne(pageId)
|
|
124
|
+
const pageVersion = await this.getLatestPageVersion(pageId);
|
|
125
|
+
const broker = objectql.getSteedosSchema().broker;
|
|
126
|
+
const actions = broker.registry.getActionList({
|
|
127
|
+
onlyLocal: false
|
|
128
|
+
});
|
|
129
|
+
if(_.find(actions, (action)=>{
|
|
130
|
+
return action.name === `${page.render_engine}.getInitSchema`
|
|
131
|
+
})){
|
|
132
|
+
const schema = await broker.call(`${page.render_engine}.getInitSchema`, {type: page.type, objectApiName: page.object_name})
|
|
133
|
+
if(schema){
|
|
134
|
+
const now = new Date();
|
|
135
|
+
await objectql.getObject('page_versions').directInsert({
|
|
136
|
+
page: pageId,
|
|
137
|
+
is_active: false,
|
|
138
|
+
version: pageVersion && pageVersion.version ? pageVersion.version + 1 : 1,
|
|
139
|
+
schema: JSON.stringify(schema, null, 4),
|
|
140
|
+
space: page.space,
|
|
141
|
+
owner: userSession.userId,
|
|
142
|
+
created: now,
|
|
143
|
+
modified: now,
|
|
144
|
+
created_by: userSession.userId,
|
|
145
|
+
modified_by: userSession.userId,
|
|
146
|
+
company_id: page.company_id,
|
|
147
|
+
company_ids: page.company_ids
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {}
|
|
153
|
+
}
|
|
111
154
|
}
|
|
112
155
|
},
|
|
113
156
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 2022-04-10 14:27:24
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime: 2022-
|
|
4
|
+
* @LastEditors: baozhoutao@hotoa.com
|
|
5
|
+
* @LastEditTime: 2022-05-18 16:49:40
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
const objectql = require('@steedos/objectql');
|
|
@@ -20,10 +20,11 @@ async function getAll(){
|
|
|
20
20
|
versions.push({
|
|
21
21
|
_id: item._id,
|
|
22
22
|
description: item.description,
|
|
23
|
-
is_active:
|
|
23
|
+
is_active: true,
|
|
24
24
|
page: item._id,
|
|
25
25
|
schema: item.schema,
|
|
26
26
|
version: 1,
|
|
27
|
+
record_permissions: item.record_permissions
|
|
27
28
|
});
|
|
28
29
|
})
|
|
29
30
|
return versions;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: baozhoutao@steedos.com
|
|
3
|
+
* @Date: 2022-05-23 10:02:16
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2022-05-28 11:15:32
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
const auth = require('@steedos/auth');
|
|
9
|
+
const objectql = require('@steedos/objectql');
|
|
10
|
+
const _ = require('lodash');
|
|
11
|
+
module.exports = {
|
|
12
|
+
listenTo: 'pages',
|
|
13
|
+
afterInsert: async function(){
|
|
14
|
+
const { id } = this;
|
|
15
|
+
const page = await objectql.getObject('pages').findOne(id)
|
|
16
|
+
const broker = objectql.getSteedosSchema().broker;
|
|
17
|
+
|
|
18
|
+
const user = await auth.getSessionByUserId(page.owner, page.space);
|
|
19
|
+
await broker.call(`page.resetDefaultVersion`, {
|
|
20
|
+
pageId: page._id
|
|
21
|
+
}, {
|
|
22
|
+
meta: {
|
|
23
|
+
user: user
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// const actions = broker.registry.getActionList({
|
|
28
|
+
// onlyLocal: false
|
|
29
|
+
// });
|
|
30
|
+
// if(_.find(actions, (action)=>{
|
|
31
|
+
// return action.name === `${page.render_engine}.getInitSchema`
|
|
32
|
+
// })){
|
|
33
|
+
// const schema = await broker.call(`${page.render_engine}.getInitSchema`, {type: page.type, objectApiName: page.object_name})
|
|
34
|
+
// if(schema){
|
|
35
|
+
// await objectql.getObject('page_versions').directInsert({
|
|
36
|
+
// page: id,
|
|
37
|
+
// is_active: false,
|
|
38
|
+
// version: 1,
|
|
39
|
+
// schema: JSON.stringify(schema, null, 4),
|
|
40
|
+
// space: page.space,
|
|
41
|
+
// owner: page.owner,
|
|
42
|
+
// created_by: page.created_by,
|
|
43
|
+
// modified_by: page.modified_by,
|
|
44
|
+
// company_id: page.company_id,
|
|
45
|
+
// company_ids: page.company_ids
|
|
46
|
+
// })
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.37",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {},
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@builder.io/react": "^1.1.50"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "f824c11de5f099c1063aa4ef1941fd90666892a3"
|
|
15
15
|
}
|