@steedos/service-pages 3.0.0-beta.9 → 3.0.0-beta.90

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.
@@ -322,12 +322,9 @@
322
322
  this.containerList = [];
323
323
  this.pageName = null;
324
324
  return this.autorun(function(computation) {
325
- // console.log('autorun=====>computation:', computation)
326
- // Session.get("record_id");
327
325
  var container, e, lastData, ref, ref1, ref2, regions, schema, updateProps, updatePropsData;
328
326
  if(self.data.regions){
329
327
  regions = self.data.regions();
330
- // console.log('regions====>', regions, this.lastRegions);
331
328
  updateProps = true;
332
329
  if (regions.objectName !== ((ref = this.lastRegions) != null ? ref.objectName : void 0)) {
333
330
  updateProps = false;
@@ -105,4 +105,14 @@ actions:
105
105
  showDesign:
106
106
  label: Show Design
107
107
  viewPage:
108
- label: View
108
+ label: View
109
+ CustomLabels:
110
+ pages_action_disable_success: The page has been disabled.
111
+ pages_action_disable_failed: Operation failed
112
+ pages_action_enable_success: The page has been enabled.
113
+ pages_action_enable_failed: Operation failed
114
+ pages_action_resetSchema_dialog_title: Reset Page Schema
115
+ pages_action_resetSchema_dialog_content: After resetting the page, a new page version will be generated based on the latest object field configuration.
116
+ pages_action_resetSchema_success_message: Operation successful
117
+ pages_action_resetSchema_success_description: The page has been reset.
118
+ pages_action_resetSchema_failed_message: Operation failed
@@ -106,3 +106,13 @@ actions:
106
106
  label: 设计器
107
107
  viewPage:
108
108
  label: 查看
109
+ CustomLabels:
110
+ pages_action_disable_success: 页面已禁用。
111
+ pages_action_disable_failed: 操作失败
112
+ pages_action_enable_success: 页面已启用。
113
+ pages_action_enable_failed: 操作失败
114
+ pages_action_resetSchema_dialog_title: 重置页面
115
+ pages_action_resetSchema_dialog_content: 重置页面后,会根据最新的对象字段配置生成一个新的页面版本.
116
+ pages_action_resetSchema_success_message: 操作成功
117
+ pages_action_resetSchema_success_description: 页面已重置。
118
+ pages_action_resetSchema_failed_message: 操作失败
@@ -7,7 +7,6 @@
7
7
  */
8
8
  module.exports = {
9
9
  customPage: function (object_name, record_id) {
10
- $(document.body).addClass('loading');
11
10
  let url = `/service/api/page/customPage`;
12
11
  let options = {
13
12
  type: 'post',
@@ -17,15 +16,13 @@ module.exports = {
17
16
  SteedosUI.notification.success({
18
17
  message: '页面已自定义。'
19
18
  });
20
- SteedosUI.router.go({}, "/app/" + Session.get("app_id") + "/" + object_name + "/view/" + data._id);
21
- $(document.body).removeClass('loading');
19
+ navigate("/app/admin/pages/view/" + data._id)
22
20
  },
23
21
  error: function (XMLHttpRequest, textStatus, errorThrown) {
24
22
  SteedosUI.notification.error({
25
23
  message: '操作失败',
26
24
  description: t(XMLHttpRequest.responseJSON.error),
27
25
  });
28
- $(document.body).removeClass('loading');
29
26
  }
30
27
  };
31
28
  Steedos.authRequest(url, options);
@@ -7,7 +7,6 @@
7
7
  */
8
8
  module.exports = {
9
9
  deploy: function (object_name, record_id) {
10
- $(document.body).addClass('loading');
11
10
  let url = `/service/api/page/deploy`;
12
11
  let options = {
13
12
  type: 'post',
@@ -18,15 +17,13 @@ module.exports = {
18
17
  message: '页面已发布。'
19
18
  });
20
19
  SteedosUI.reloadRecord(object_name, record_id);
21
- FlowRouter.reload();
22
- $(document.body).removeClass('loading');
20
+ window.location.reload();
23
21
  },
24
22
  error: function (XMLHttpRequest, textStatus, errorThrown) {
25
23
  SteedosUI.notification.error({
26
24
  message: '操作失败',
27
25
  description: t(XMLHttpRequest.responseJSON.error),
28
26
  });
29
- $(document.body).removeClass('loading');
30
27
  }
31
28
  };
32
29
  Steedos.authRequest(url, options);
@@ -1,6 +1,48 @@
1
1
  name: disable
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "${'CustomAction.pages.disable' | t}",
9
+ "id": "u:disable",
10
+ "visibleOn": "${is_active && !is_system}",
11
+ "actionType": "ajax",
12
+ "api": {
13
+ "url": "${context.rootUrl}/service/api/page/disable",
14
+ "method": "post",
15
+ "requestAdaptor": "var recordId = context.recordId;\napi.data = {\n pageId: recordId\n}",
16
+ "adaptor": "",
17
+ "messages": {
18
+ "success": "${'CustomLabels.pages_action_disable_success' | t}",
19
+ "failed": "${'CustomLabels.pages_action_disable_failed' | t}"
20
+ }
21
+ },
22
+ "editorState": "default"
23
+ }
24
+ ],
25
+ "regions": [
26
+ "body"
27
+ ],
28
+ "data": {
29
+ "context": {},
30
+ "dataComponentId": "",
31
+ "record_id": "",
32
+ "record": {},
33
+ "permissions": {}
34
+ },
35
+ "bodyClassName": "p-0",
36
+ "dsType": "api",
37
+ "asideResizor": false,
38
+ "editorState": "default",
39
+ "pullRefresh": {
40
+ "disabled": true
41
+ }
42
+ }
2
43
  is_enable: true
3
44
  label: 禁用
4
45
  'on': record_only
46
+ type: amis_button
5
47
  visible: true
6
48
  sort: 100
@@ -1,6 +1,48 @@
1
1
  name: enable
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "${'CustomAction.pages.enable' | t}",
9
+ "id": "u:enable",
10
+ "visibleOn": "${!is_active && !record.is_system}",
11
+ "actionType": "ajax",
12
+ "api": {
13
+ "url": "${context.rootUrl}/service/api/page/enable",
14
+ "method": "post",
15
+ "requestAdaptor": "var recordId = context.recordId;\napi.data = {\n pageId: recordId\n}",
16
+ "adaptor": "",
17
+ "messages": {
18
+ "success": "${'CustomLabels.pages_action_enable_success' | t}",
19
+ "failed": "${'CustomLabels.pages_action_enable_failed' | t}"
20
+ }
21
+ },
22
+ "editorState": "default"
23
+ }
24
+ ],
25
+ "regions": [
26
+ "body"
27
+ ],
28
+ "data": {
29
+ "context": {},
30
+ "dataComponentId": "",
31
+ "record_id": "",
32
+ "record": {},
33
+ "permissions": {}
34
+ },
35
+ "bodyClassName": "p-0",
36
+ "dsType": "api",
37
+ "asideResizor": false,
38
+ "editorState": "default",
39
+ "pullRefresh": {
40
+ "disabled": true
41
+ }
42
+ }
2
43
  is_enable: true
3
44
  label: 启用
4
45
  'on': record_only
46
+ type: amis_button
5
47
  visible: true
6
48
  sort: 100
@@ -1,15 +1,15 @@
1
1
  /*
2
2
  * @Author: baozhoutaon@hotoa.com
3
3
  * @Date: 2022-03-29 20:33:44
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2022-05-27 18:08:21
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-08-26 13:58:13
6
6
  * @Description:
7
7
  */
8
8
  module.exports = {
9
9
  resetSchema: function (object_name, record_id) {
10
10
  SteedosUI.Modal.confirm({
11
- title: "重置页面",
12
- content: "重置页面后,会根据最新的对象字段配置生成一个新的页面版本.",
11
+ title: t("CustomLabels.pages_action_resetSchema_dialog_title"),
12
+ content: t("CustomLabels.pages_action_resetSchema_dialog_title"),
13
13
  onOk: function(){
14
14
  $(document.body).addClass('loading');
15
15
  let url = `/service/api/page/resetDefaultSchema`;
@@ -19,8 +19,8 @@ module.exports = {
19
19
  data: JSON.stringify({ pageId: record_id }),
20
20
  success: function (data) {
21
21
  SteedosUI.notification.success({
22
- message: '操作成功',
23
- description: `页面已重置.`,
22
+ message: t("CustomLabels.pages_action_resetSchema_success_message"),
23
+ description: t("CustomLabels.pages_action_resetSchema_success_description"),
24
24
  });
25
25
  SteedosUI.router.go({
26
26
  type: 'new',
@@ -31,7 +31,7 @@ module.exports = {
31
31
  },
32
32
  error: function (XMLHttpRequest, textStatus, errorThrown) {
33
33
  SteedosUI.notification.error({
34
- message: '操作失败',
34
+ message: t("CustomLabels.pages_action_resetSchema_failed_message"),
35
35
  description: t(XMLHttpRequest.responseJSON.error),
36
36
  });
37
37
  $(document.body).removeClass('loading');
@@ -1,19 +1,23 @@
1
+ /*
2
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
3
+ * @Date: 2025-07-07 16:57:38
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-08-25 11:24:10
6
+ */
1
7
  module.exports = {
2
8
  showDesign: function (object_name, record_id) {
3
9
  // Steedos.openWindow();
4
- document.location = Steedos.absoluteUrl(`/api/pageDesign?pageId=${record_id}&assetUrls=${Builder.settings.assetUrls}&locale=${Builder.settings.locale}`);
10
+ var locale = Builder.settings.context?.user?.language || window.navigator.language;
11
+ if(locale === 'en' || locale.startsWith('en-')){
12
+ locale = 'en-us'
13
+ }
14
+ document.location = Steedos.absoluteUrl(`/api/pageDesign?pageId=${record_id}&assetUrls=${Builder.settings.assetUrls}&locale=${locale}`);
5
15
  },
6
16
  showDesignVisible: function (object_name, record_id, record_permissions) {
7
17
  var perms, record;
8
18
  perms = {};
9
19
  if (record_permissions) {
10
20
  perms = record_permissions;
11
- } else {
12
- record = Creator.getObjectRecord(object_name, record_id);
13
- record_permissions = Creator.getRecordPermissions(object_name, record, Meteor.userId());
14
- if (record_permissions) {
15
- perms = record_permissions;
16
- }
17
21
  }
18
22
  return perms["allowEdit"];
19
23
  }
@@ -16,7 +16,8 @@ module.exports = {
16
16
  }
17
17
  },
18
18
  viewPageVisible: function (object_name, record_id, permission, data) {
19
- var record = data && data.record;
20
- return record && record.type === 'app';
19
+ // var record = data && data.record;
20
+ // return record && record.type === 'app';
21
+ return false;
21
22
  }
22
23
  }
@@ -142,13 +142,13 @@
142
142
 
143
143
  if (objectName && pageType === "record") {
144
144
  const record = await axios.get(
145
- `${rootUrl}/api/v4/${objectName}?$orderby=modified&$top=1`,
145
+ `${rootUrl}/api/v1/${objectName}?$sort=modified&$top=1`,
146
146
  {
147
147
  withCredentials: true,
148
148
  headers: { Authorization: `Bearer ${tenantId},${authToken}` },
149
149
  }
150
150
  );
151
- const value = record?.data?.value;
151
+ const value = record?.data?.items;
152
152
  if (value?.length > 0) {
153
153
  schema.data.recordId = value[0]._id;
154
154
  }
@@ -3,7 +3,9 @@ const metadataAPI = require('@steedos/metadata-api');
3
3
  const _ = require('lodash');
4
4
  // 使用变量,存储所有资产
5
5
  const ASSETS = {};
6
- const ENV_ASSETS = process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS.split(',')
6
+ const ENV_ASSETS = process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS
7
+ ? process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS.split(",")
8
+ : []
7
9
  module.exports = {
8
10
  name: "page",
9
11
  mixins: [],
@@ -1,12 +1,16 @@
1
1
  const objectql = require('@steedos/objectql');
2
2
  async function isSpaceUnique(spaceId, object_name, doc, name, _id){
3
- const filters = [];
4
- filters.push(['space', '=', spaceId])
5
- filters.push(['name', '=', name || doc.name])
3
+ const query = {space: spaceId, name: name || doc.name};
6
4
  if(_id){
7
- filters.push(['_id', '!=', _id])
5
+ query._id = {
6
+ '$ne': _id
7
+ }
8
8
  }
9
- const count = await objectql.getObject(object_name).count({filters: filters})
9
+ const datasource = objectql.getDataSource('default');
10
+ const adapter = datasource.adapter
11
+ await adapter.connect()
12
+ const collection = adapter.collection(object_name);
13
+ const count = await collection.countDocuments(query)
10
14
  if(count > 0)
11
15
  return false
12
16
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-pages",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-beta.90",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "gitHead": "9111ae9e9ce7c57c67c6bd670706f4344c28d69d",
11
+ "gitHead": "196645f156c4c4cf4d07f288117c5e5d271bba0f",
12
12
  "dependencies": {
13
13
  "clone": "^2.1.2",
14
14
  "ejs": "^3.1.8"
@@ -1,36 +0,0 @@
1
- /*
2
- * @Author: baozhoutao@steedos.com
3
- * @Date: 2022-03-29 19:19:01
4
- * @Description:
5
- */
6
- module.exports = {
7
- disable: function (object_name, record_id) {
8
- $(document.body).addClass('loading');
9
- let url = `/service/api/page/disable`;
10
- let options = {
11
- type: 'post',
12
- async: true,
13
- data: JSON.stringify({ pageId: record_id }),
14
- success: function (data) {
15
- SteedosUI.notification.success({
16
- message: '页面已禁用。'
17
- });
18
- SteedosUI.reloadRecord(object_name, record_id);
19
- FlowRouter.reload();
20
- $(document.body).removeClass('loading');
21
- },
22
- error: function (XMLHttpRequest, textStatus, errorThrown) {
23
- SteedosUI.notification.error({
24
- message: '操作失败',
25
- description: t(XMLHttpRequest.responseJSON.error),
26
- });
27
- $(document.body).removeClass('loading');
28
- }
29
- };
30
- Steedos.authRequest(url, options);
31
- },
32
- disableVisible: function (object_name, record_id, permission, data) {
33
- var record = data && data.record;
34
- return record && record.is_active && !record.is_system
35
- }
36
- }
@@ -1,31 +0,0 @@
1
- /*
2
- * @Author: baozhoutao@steedos.com
3
- * @Date: 2022-03-29 19:19:01
4
- * @Description:
5
- */
6
- module.exports = {
7
- enable: function (object_name, record_id) {
8
- $(document.body).addClass('loading');
9
- let url = `/service/api/page/enable`;
10
- let options = {
11
- type: 'post',
12
- async: true,
13
- data: JSON.stringify({ pageId: record_id }),
14
- success: function (data) {
15
- toastr.success('页面已启用。');
16
- SteedosUI.reloadRecord(object_name, record_id);
17
- FlowRouter.reload();
18
- $(document.body).removeClass('loading');
19
- },
20
- error: function (XMLHttpRequest, textStatus, errorThrown) {
21
- toastr.error(t(XMLHttpRequest.responseJSON.error))
22
- $(document.body).removeClass('loading');
23
- }
24
- };
25
- Steedos.authRequest(url, options);
26
- },
27
- enableVisible: function (object_name, record_id, permission, data) {
28
- var record = data && data.record;
29
- return record && !record.is_active && !record.is_system
30
- }
31
- }