@steedos/standard-object-database 2.5.0-beta.18 → 2.5.0-beta.20

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.
@@ -1,13 +1,46 @@
1
- var permissionCore = require('./permission_objects.core.js');
1
+ /*
2
+ * @Author: baozhoutao@steedos.com
3
+ * @Date: 2022-08-05 14:17:44
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2023-05-06 18:58:32
6
+ * @Description:
7
+ */
2
8
 
9
+ const cachers = require('@steedos/cachers');
10
+ const objectql = require("@steedos/objectql");
11
+ const _ = require('lodash');
12
+ let permissionObjectsLoadSetTimeoutId = null;
3
13
  Meteor.startup(function () {
4
14
  var _change, _remove;
5
15
  _change = function (document) {
6
- permissionCore.loadObjectPermission(document)
7
- };
8
- _remove = function (document) {
9
- permissionCore.removeObjectPermission(document);
16
+ if(permissionObjectsLoadSetTimeoutId){
17
+ clearTimeout(permissionObjectsLoadSetTimeoutId);
18
+ permissionObjectsLoadSetTimeoutId = null;
19
+ }
20
+ permissionObjectsLoadSetTimeoutId = setTimeout(()=>{
21
+ objectql.getObject("permission_set").find({}).then((permissionSets)=>{
22
+ objectql.getObject("permission_objects").directFind({}).then((records)=>{
23
+ records = _.map(records, (doc)=>{
24
+ if(_.includes(['admin', 'user', 'customer', 'supplier'], doc.permission_set_id)){
25
+ doc.name = doc.permission_set_id
26
+ }else{
27
+ const record = _.find(permissionSets, (item)=>{
28
+ return doc.permission_set_id == item._id
29
+ })
30
+ if(record){
31
+ doc.name = record.name;
32
+ }else{
33
+ doc.name = _.last(doc.name.split('.')) || doc.permission_set_id;
34
+ }
35
+ }
36
+ return doc;
37
+ })
38
+ cachers.getCacher('permission_objects').set('permission_objects', _.groupBy(records, 'space'));
39
+ })
40
+ })
41
+ }, 1000 * 3)
10
42
  };
43
+
11
44
  Creator.getCollection("permission_objects").find({}, {
12
45
  fields: {
13
46
  created: 0,
@@ -23,7 +56,7 @@ Meteor.startup(function () {
23
56
  return _change(newDocument);
24
57
  },
25
58
  removed: function (oldDocument) {
26
- return _remove(oldDocument);
59
+ return _change(oldDocument);
27
60
  }
28
61
  });
29
62
  });
@@ -1,4 +1,5 @@
1
1
  const _ = require("underscore");
2
+ const lodash = require("lodash");
2
3
  var objectql = require('@steedos/objectql');
3
4
  var schema = objectql.getSteedosSchema();
4
5
  const datasourceCore = require('./datasources.core');
@@ -20,6 +21,9 @@ Creator.Objects['datasources'].methods = {
20
21
  testConnection: async function (req, res) {
21
22
  var userSession = req.user
22
23
  var recordId = req.params._id;
24
+ if(lodash.includes(defaultDatasourceName, recordId)){
25
+ return res.send({ok: 1});
26
+ }
23
27
  var spaceId = userSession.spaceId
24
28
  let doc = await objectql.getObject('datasources').findOne(recordId, {filters: `(space eq \'${spaceId}\')`});
25
29
  if(doc){
@@ -82,6 +82,15 @@ fields:
82
82
  is_enable:
83
83
  type: boolean
84
84
  label: Enable
85
+ record_permissions:
86
+ type: object
87
+ visible_on: "{{global.mode ==='read' ? true : false}}"
88
+ is_system:
89
+ type: boolean
90
+ label: System
91
+ readonly: true
92
+ visible_on: "{{global.mode ==='read' ? true : false}}"
93
+ disabled: true
85
94
  list_views:
86
95
  all:
87
96
  columns:
@@ -89,6 +98,7 @@ list_views:
89
98
  - name
90
99
  - is_enable
91
100
  - driver
101
+ - is_system
92
102
  label: All
93
103
  filter_scope: space
94
104
  actions:
@@ -9,23 +9,30 @@ const auth = require('@steedos/auth');
9
9
  const _ = require('underscore');
10
10
  //由于新版lookup 组件限制。需编写trigger处理在只读页面不显示已选中项的问题
11
11
  //由于lookup组件强依赖_id 字段,所以必须返回_id
12
+
13
+ const PERMISSIONS = {
14
+ allowEdit: false,
15
+ allowDelete: false,
16
+ allowRead: true,
17
+ };
18
+
19
+ const BASERECORD = {
20
+ is_system: true,
21
+ record_permissions: PERMISSIONS
22
+ };
23
+
12
24
  module.exports = {
13
25
 
14
26
  beforeFind: async function () {
15
27
  delete this.query.fields;
16
28
  },
17
-
18
- beforeAggregate: async function () {
19
- delete this.query.fields;
20
- },
21
-
22
29
  afterFind: async function(){
23
30
  const { spaceId } = this;
24
31
  let lng = Steedos.locale(this.userId, true);
25
- let dataList = [{_id: 'default', name: 'default', label: TAPi18n.__(`objects_field_datasource_defaultValue`, {}, lng)}];
32
+ let dataList = [{_id: 'default', name: 'default', label: TAPi18n.__(`objects_field_datasource_defaultValue`, {}, lng), ...BASERECORD}];
26
33
  let filters = InternalData.parserFilters(this.query.filters)
27
34
  if(filters._id === 'meteor'){
28
- dataList.push({_id: 'meteor', name: 'meteor', label: TAPi18n.__(`objects_field_datasource_meteor`, {}, lng)})
35
+ dataList.push({_id: 'meteor', name: 'meteor', label: TAPi18n.__(`objects_field_datasource_meteor`, {}, lng), ...BASERECORD})
29
36
  }
30
37
  if (!_.isEmpty(dataList)) {
31
38
  dataList.forEach((doc) => {
@@ -44,26 +51,6 @@ module.exports = {
44
51
  }
45
52
 
46
53
  },
47
- afterAggregate: async function(){
48
- const { spaceId } = this;
49
- let lng = Steedos.locale(this.userId, true)
50
- let dataList = [{_id: 'default', name: 'default', label: TAPi18n.__(`objects_field_datasource_defaultValue`, {}, lng)}];
51
- if (!_.isEmpty(dataList)) {
52
- dataList.forEach((doc) => {
53
- if (!_.find(this.data.values, (value) => {
54
- return value.name === doc.name
55
- })) {
56
- this.data.values.push(doc);
57
- }
58
- })
59
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
60
- if (records.length > 0) {
61
- this.data.values = records;
62
- } else {
63
- this.data.values.length = 0;
64
- }
65
- }
66
- },
67
54
  afterCount: async function(){
68
55
  delete this.query.fields;
69
56
  let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId))
@@ -74,7 +61,7 @@ module.exports = {
74
61
  if(this.id === 'default'){
75
62
  try {
76
63
  let lng = Steedos.locale(this.userId, true)
77
- this.data.values = {_id: 'default', name: 'default', label: TAPi18n.__(`objects_field_datasource_defaultValue`, {}, lng)};
64
+ this.data.values = {_id: 'default', name: 'default', label: TAPi18n.__(`objects_field_datasource_defaultValue`, {}, lng), ...BASERECORD};
78
65
  } catch (error) {
79
66
 
80
67
  }
@@ -82,7 +69,7 @@ module.exports = {
82
69
  if(this.id === 'meteor'){
83
70
  try {
84
71
  let lng = Steedos.locale(this.userId, true)
85
- this.data.values = {_id: 'meteor', name: 'meteor', label: TAPi18n.__(`objects_field_datasource_meteor`, {}, lng)};
72
+ this.data.values = {_id: 'meteor', name: 'meteor', label: TAPi18n.__(`objects_field_datasource_meteor`, {}, lng), ...BASERECORD};
86
73
  } catch (error) {
87
74
 
88
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.5.0-beta.18",
3
+ "version": "2.5.0-beta.20",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,5 +15,5 @@
15
15
  },
16
16
  "repository": {},
17
17
  "license": "MIT",
18
- "gitHead": "5567aff68a838502b3e7bb9cab229a3575d1c3ed"
18
+ "gitHead": "830af95dcc46ba3ac1abf237943d23e627feabaf"
19
19
  }