@steedos/service-pages 2.2.44 → 2.2.47
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/applications/app_charts.app.yml +1 -1
- package/main/default/client/page.render.client.js +6 -1
- package/main/default/objects/pages/buttons/customPage.button.js +36 -0
- package/main/default/objects/pages/buttons/customPage.button.yml +6 -0
- package/main/default/objects/pages/fields/label.field.yml +2 -2
- package/main/default/objects/pages/listviews/all.listview.yml +1 -1
- package/main/default/objects/pages/listviews/recent.listview.yml +1 -1
- package/main/default/objects/pages/pages.object.yml +1 -1
- package/main/default/routes/page_design.router.js +10 -0
- package/main/default/services/page.service.js +52 -2
- package/package.json +2 -5
|
@@ -425,7 +425,12 @@
|
|
|
425
425
|
if(objectApiName === 'space_users' && fieldName === 'company_ids'){
|
|
426
426
|
spaceUsersCompanyIdsExpand = ',name,admins'
|
|
427
427
|
}
|
|
428
|
-
|
|
428
|
+
let referenceTo = objectFields[fieldName].reference_to;
|
|
429
|
+
const refObject = Creator.getObject(referenceTo)
|
|
430
|
+
if(!refObject){
|
|
431
|
+
console.error(`未找到对象“${referenceTo}”,请检查是否该对象依赖的软件包未安装。`);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
429
434
|
if(_.includes(fieldsName, fieldName)){
|
|
430
435
|
fieldsName[_.indexOf(fieldsName, fieldName)] = `${fieldName}:${fieldName}__expand{_id, _NAME_FIELD_VALUE:${refObject.NAME_FIELD_KEY}${spaceUsersCompanyIdsExpand}}`
|
|
431
436
|
}else{
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: baozhoutaon@hotoa.com
|
|
3
|
+
* @Date: 2022-03-29 20:33:44
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2022-06-15 17:40:53
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
customPage: function (object_name, record_id) {
|
|
10
|
+
$(document.body).addClass('loading');
|
|
11
|
+
let url = `/service/api/page/customPage`;
|
|
12
|
+
let options = {
|
|
13
|
+
type: 'post',
|
|
14
|
+
async: true,
|
|
15
|
+
data: JSON.stringify({ pageId: record_id }),
|
|
16
|
+
success: function (data) {
|
|
17
|
+
SteedosUI.notification.success({
|
|
18
|
+
message: '页面已自定义。'
|
|
19
|
+
});
|
|
20
|
+
SteedosUI.router.go({}, "/app/" + Session.get("app_id") + "/" + object_name + "/view/" + data._id);
|
|
21
|
+
$(document.body).removeClass('loading');
|
|
22
|
+
},
|
|
23
|
+
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
24
|
+
SteedosUI.notification.error({
|
|
25
|
+
message: '操作失败',
|
|
26
|
+
description: t(XMLHttpRequest.responseJSON.error),
|
|
27
|
+
});
|
|
28
|
+
$(document.body).removeClass('loading');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
Steedos.authRequest(url, options);
|
|
32
|
+
},
|
|
33
|
+
customPageVisible: function (object_name, record_id, permission, record) {
|
|
34
|
+
return record && record.is_system;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -9,14 +9,24 @@ const core = require('@steedos/core');
|
|
|
9
9
|
const ejs = require('ejs');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const _ = require('lodash');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
12
14
|
router.get('/api/pageDesign', core.requireAuthentication, async function (req, res) {
|
|
13
15
|
try {
|
|
14
16
|
res.set('Content-Type', 'text/html');
|
|
15
17
|
const userSession = req.user;
|
|
16
18
|
let assetUrl = "";
|
|
19
|
+
let assetUrls = null;
|
|
17
20
|
if(process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS && _.isString(process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS)){
|
|
18
21
|
assetUrls = process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS.split(',');
|
|
19
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=")}&`;
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
// const dataContext = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const objectql = require('@steedos/objectql');
|
|
2
|
-
|
|
2
|
+
const metadataAPI = require('@steedos/metadata-api');
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
@@ -151,7 +151,57 @@ module.exports = {
|
|
|
151
151
|
|
|
152
152
|
return {}
|
|
153
153
|
}
|
|
154
|
-
}
|
|
154
|
+
},
|
|
155
|
+
customPage: {
|
|
156
|
+
rest: {
|
|
157
|
+
method: "POST",
|
|
158
|
+
path: "/customPage"
|
|
159
|
+
},
|
|
160
|
+
params: {
|
|
161
|
+
pageId: { type: 'string' }
|
|
162
|
+
},
|
|
163
|
+
handler: async function (ctx) {
|
|
164
|
+
const userSession = ctx.meta.user;
|
|
165
|
+
if(!userSession.is_space_admin){
|
|
166
|
+
throw new Error('Permission denied')
|
|
167
|
+
}
|
|
168
|
+
const { pageId } = ctx.params;
|
|
169
|
+
const page = await objectql.getObject('pages').findOne(pageId);
|
|
170
|
+
const records = await objectql.getObject('pages').find({filters: [['name', '=', page.name]]});
|
|
171
|
+
const dbManager = new metadataAPI.DbManager(userSession);
|
|
172
|
+
let result = {};
|
|
173
|
+
if(records && records.length > 0 && records[0]._id != pageId){
|
|
174
|
+
result = {_id: records[0]._id}
|
|
175
|
+
return result
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
await dbManager.connect();
|
|
179
|
+
var session = await dbManager.startSession();
|
|
180
|
+
const transactionOptions = {
|
|
181
|
+
readPreference: 'primary',
|
|
182
|
+
readConcern: { level: 'majority' },
|
|
183
|
+
writeConcern: { w: 'majority' }
|
|
184
|
+
};
|
|
185
|
+
try {
|
|
186
|
+
await session.withTransaction(async () => {
|
|
187
|
+
const pageCollection = new metadataAPI.PageCollection();
|
|
188
|
+
delete page.is_system
|
|
189
|
+
delete page.record_permissions
|
|
190
|
+
const info = await pageCollection.save(dbManager, page);
|
|
191
|
+
result._id = info.insertedId;
|
|
192
|
+
}, transactionOptions);
|
|
193
|
+
} catch(err) {
|
|
194
|
+
throw err
|
|
195
|
+
}
|
|
196
|
+
}catch (err) {
|
|
197
|
+
throw new Error(err.message) // 重新整理错误信息,否则会导致 service-api 无法处理错误信息导致接口挂起.
|
|
198
|
+
}finally{
|
|
199
|
+
await dbManager.endSession();
|
|
200
|
+
await dbManager.close();
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
155
205
|
},
|
|
156
206
|
|
|
157
207
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.47",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {},
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,5 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
"@builder.io/react": "^1.1.50"
|
|
13
|
-
},
|
|
14
|
-
"gitHead": "8cc999b9a464479dc147f2cdafd6c39b6d511d2f"
|
|
11
|
+
"gitHead": "d36c2021b7eeca48bee5406cd81490fd0cd8a78e"
|
|
15
12
|
}
|