@steedos/service-pages 2.2.43 → 2.2.46

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.
@@ -12,7 +12,7 @@ admin_menus:
12
12
  permission_sets:
13
13
  - admin
14
14
  - _id: pages
15
- name: 页面
15
+ name: 微页面
16
16
  object_name: pages
17
17
  parent: user_interface
18
18
  sort: 300
@@ -425,7 +425,12 @@
425
425
  if(objectApiName === 'space_users' && fieldName === 'company_ids'){
426
426
  spaceUsersCompanyIdsExpand = ',name,admins'
427
427
  }
428
- const refObject = Creator.getObject(objectFields[fieldName].reference_to)
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
+ }
@@ -0,0 +1,6 @@
1
+ name: customPage
2
+ is_enable: true
3
+ label: 自定义
4
+ 'on': record_only
5
+ visible: true
6
+ sort: 200
@@ -1,8 +1,8 @@
1
1
  name: label
2
2
  index: true
3
3
  label: 名称
4
- required: false
4
+ required: true
5
5
  searchable: true
6
6
  sort_no: 120
7
- is_name: false
7
+ is_name: true
8
8
  type: text
@@ -1,7 +1,7 @@
1
1
  name: all
2
2
  columns:
3
- - field: name
4
3
  - field: label
4
+ - field: name
5
5
  - field: render_engine
6
6
  - field: type
7
7
  - field: is_active
@@ -1,7 +1,7 @@
1
1
  name: recent
2
2
  columns:
3
- - field: name
4
3
  - field: label
4
+ - field: name
5
5
  - field: render_engine
6
6
  - field: type
7
7
  - field: is_active
@@ -16,7 +16,7 @@ enable_workflow: false
16
16
  hidden: true
17
17
  icon: contract
18
18
  is_enable: true
19
- label: 页面
19
+ label: 微页面
20
20
  version: 2
21
21
  form:
22
22
  afterView: !!js/function |
@@ -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.43",
3
+ "version": "2.2.46",
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
- "dependencies": {
12
- "@builder.io/react": "^1.1.50"
13
- },
14
- "gitHead": "4aa9568edad23cdef05ebbee5299c17904a76dde"
11
+ "gitHead": "480163256639fa1db7fdfcd321afafc288b09095"
15
12
  }