@steedos/standard-permission 2.5.8-beta.5 → 2.5.8

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.
@@ -100,6 +100,7 @@ fields:
100
100
  group: Files permissions
101
101
  disabled_list_views:
102
102
  type: lookup
103
+ reference_to: object_listviews
103
104
  label: Disabled ListViews
104
105
  multiple: true
105
106
  depend_on:
@@ -64,7 +64,7 @@ amis_schema: |-
64
64
  "&": "$$",
65
65
  "record": "${record}"
66
66
  },
67
- "adaptor": "const data = payload.data\nconst { permission_tabs, tabs } = data\nconst tableOptions = []\nconst tabNames = [] // 用于存储已经遍历过的选项卡,防止重复\nfor (const pTab of permission_tabs) {\n tableOptions.push({\n tab: {\n _id: pTab.tab__expand._id,\n name: pTab.tab__expand.name,\n label: pTab.tab__expand.label\n },\n permission: pTab.permission\n })\n tabNames.push(pTab.tab__expand.name)\n}\n\nfor (const tab of tabs) {\n if (tabNames.includes(tab.name)) {\n continue\n }\n tableOptions.push({\n tab: {\n _id: tab._id,\n name: tab.name,\n label: tab.label\n },\n permission: 'on'\n })\n}\n\ndata.permission_tabs_list = tableOptions\n\nreturn payload\n",
67
+ "adaptor": "const data = payload.data\nconst { permission_tabs, tabs } = data\nconst tableOptions = []\nconst tabNames = [] // 用于存储已经遍历过的选项卡,防止重复\nfor (const pTab of permission_tabs) {\n tableOptions.push({\n tab: {\n _id: pTab.tab__expand?._id,\n name: pTab.tab__expand?.name,\n label: pTab.tab__expand?.label\n },\n permission: pTab.permission\n })\n tabNames.push(pTab.tab__expand?.name)\n}\n\nfor (const tab of tabs) {\n if (tabNames.includes(tab.name)) {\n continue\n }\n tableOptions.push({\n tab: {\n _id: tab._id,\n name: tab.name,\n label: tab.label\n },\n permission: 'on'\n })\n}\n\ndata.permission_tabs_list = tableOptions\n\nreturn payload\n",
68
68
  "headers": {
69
69
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
70
70
  },
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2022-10-29 16:49:49
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2022-10-29 17:29:38
4
+ * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
+ * @LastEditTime: 2023-07-13 12:03:01
6
6
  * @Description: 权限集详情页中的设置选项卡权限按钮保存接口,批量保存选项卡权限
7
7
  */
8
8
  'use strict';
@@ -39,29 +39,37 @@ router.post('/api/permission/permission_set/batchSavePermissionTabs', core.requi
39
39
  throw new Error("permission_tabs_list is required");
40
40
  }
41
41
  const permissionTabsObj = objectql.getObject('permission_tabs')
42
+ const ptList = await permissionTabsObj.find({
43
+ filters: [
44
+ ['permission_set', '=', permission_set_name],
45
+ ]
46
+ }, userSession)
47
+
48
+ const ptMap = {}
49
+ for (const pt of ptList) {
50
+ ptMap[pt.tab] = pt
51
+ }
52
+
42
53
  for (const { permission, tab } of permission_tabs_list) {
43
- const pTabDoc = (await permissionTabsObj.find({
44
- filters: [
45
- ['permission_set', '=', permission_set_name],
46
- ['tab', '=', tab.name]
47
- ]
48
- }))[0]
54
+ const pTabDoc = ptMap[tab.name]
49
55
 
50
- if (pTabDoc && !pTabDoc.system) {
51
- // 如果存在
52
- // 1、非系统 执行更新
53
- await permissionTabsObj.update(pTabDoc._id, {
54
- 'permission': permission
55
- }, userSession)
56
- } else if (!pTabDoc || pTabDoc.system) {
57
- // 2、系统的执行新增,相当于自定义
58
- // 如果不存在,执行新增
59
- await permissionTabsObj.insert({
60
- 'space': spaceId,
61
- 'permission_set': permission_set_name,
62
- 'tab': tab.name,
63
- 'permission': permission
64
- }, userSession)
56
+ if (pTabDoc && pTabDoc.permission !== permission) {
57
+ if (!pTabDoc.is_system) {
58
+ // 如果存在
59
+ // 1、非系统 执行更新
60
+ await permissionTabsObj.update(pTabDoc._id, {
61
+ 'permission': permission
62
+ }, userSession)
63
+ } else if (pTabDoc.is_system) {
64
+ // 2、系统的执行新增,相当于自定义
65
+ // 如果不存在,执行新增
66
+ await permissionTabsObj.insert({
67
+ 'space': spaceId,
68
+ 'permission_set': permission_set_name,
69
+ 'tab': tab.name,
70
+ 'permission': permission
71
+ }, userSession)
72
+ }
65
73
  }
66
74
 
67
75
  }
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2022-10-26 14:14:51
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-05-30 15:09:54
4
+ * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
+ * @LastEditTime: 2023-07-13 09:56:08
6
6
  * @Description:
7
7
  */
8
8
  const objectql = require('@steedos/objectql');
@@ -11,30 +11,26 @@ const auth = require('@steedos/auth');
11
11
  const _ = require('underscore');
12
12
  async function getAll() {
13
13
  const schema = objectql.getSteedosSchema();
14
- const configs = await register.registerTab.getAll(schema.broker)
14
+ const configs = await register.registerPermissionTabs.getAll(schema.broker)
15
15
  const dataList = _.pluck(configs, 'metadata');
16
16
  let permissionTabs = [];
17
17
  for (const item of dataList) {
18
18
  if (!item._id) {
19
- item._id = `${item.name}`
19
+ item._id = `${item.permission_set}_${item.tab}`
20
20
  }
21
- if (item.permissions) {
22
- for (const permissionTab of item.permissions) {
23
- permissionTabs.push({
24
- _id: `${permissionTab.permission_set}_${item.name}`,
25
- permission: permissionTab.permission,
26
- permission_set: permissionTab.permission_set,
27
- tab: item.name,
21
+ permissionTabs.push({
22
+ _id: item._id,
23
+ permission: item.permission,
24
+ permission_set: item.permission_set,
25
+ tab: item.tab,
28
26
 
29
- is_system: true,
30
- record_permissions: { // 此属性控制记录在前台页面的权限
31
- allowEdit: false,
32
- allowDelete: false,
33
- allowRead: true,
34
- }
35
- });
27
+ is_system: true,
28
+ record_permissions: { // 此属性控制记录在前台页面的权限
29
+ allowEdit: false,
30
+ allowDelete: false,
31
+ allowRead: true,
36
32
  }
37
- }
33
+ });
38
34
  }
39
35
  return permissionTabs;
40
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-permission",
3
- "version": "2.5.8-beta.5",
3
+ "version": "2.5.8",
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": "e078465943a9b320c98d14d44b4f1403931eadf2"
15
+ "gitHead": "f40371af9656414e369dbc28f333546eb14d7ac0"
16
16
  }