@steedos/standard-object-database 2.5.19-beta.3 → 2.5.19-beta.5

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.
@@ -705,7 +705,7 @@ fields:
705
705
  visible_on: "{{['autonumber','summary','formula'].indexOf(formData.type) > -1 ? false: true}}"
706
706
  sort_no: 272
707
707
  amis:
708
- disabledOn: "${is_system == true}"
708
+ # disabledOn: "${is_system == true}"
709
709
  onEvent:
710
710
  change:
711
711
  weight: 0
@@ -818,7 +818,7 @@ fields:
818
818
  enable_enhanced_lookup:
819
819
  type: boolean
820
820
  label: Enable Enhanced Lookup
821
- visible_on: "{{false}}"
821
+ hidden: true # 这里不可以用 visible_on: "{{false}}",否则在界面上新建字段时会被默认设置为false
822
822
  paging:
823
823
  enabled: false
824
824
  list_views:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.5.19-beta.3",
3
+ "version": "2.5.19-beta.5",
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": "35ab575bdc829b2e9280044651d10d1acb0e3108"
18
+ "gitHead": "32cd0c5ebc7aaadcf12488585e62f7f3851ce2d4"
19
19
  }
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 1985-10-26 16:15:00
4
- * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
- * @LastEditTime: 2023-11-04 16:05:25
4
+ * @LastEditors: baozhoutao@steedos.com
5
+ * @LastEditTime: 2023-11-10 16:53:59
6
6
  * @Description:
7
7
  */
8
8
  "use strict";
@@ -10,7 +10,7 @@ const project = require('./package.json');
10
10
  const packageName = project.name;
11
11
  const packageLoader = require('@steedos/service-meteor-package-loader');
12
12
  const serviceObjectMixin = require('@steedos/service-object-mixin');
13
-
13
+ const validator = require('validator');
14
14
  const triggers = require('./src/triggers');
15
15
 
16
16
  /**
@@ -48,48 +48,12 @@ module.exports = {
48
48
  "objects__upsert(id: String, doc: JSON): objects"
49
49
  },
50
50
  async handler(ctx) {
51
+ if(validator.toBoolean(process.env.STEEDOS_TENANT_ENABLE_SAAS || 'false', true) == true){
52
+ throw new Error('No permission')
53
+ }
51
54
  const userSession = ctx.meta.user;
52
55
  let { id, doc } = ctx.params;
53
- let data = '';
54
- if (_.isString(doc)) {
55
- data = JSON.parse(doc);
56
- } else {
57
- data = JSON.parse(JSON.stringify(doc));
58
- }
59
-
60
- if(data.form && _.isString(data.form)){
61
- data.form = JSON.parse(data.form)
62
- }
63
-
64
- delete data.space;
65
-
66
- if(data.is_system){
67
- data = _.pick(data, ['label', 'icon', 'enable_files', 'enable_tasks', 'enable_notes', 'enable_events', 'enable_workflow', 'enable_instances', 'enable_inline_edit', 'enable_tree', 'enable_enhanced_lookup', 'description', 'is_deleted'])
68
- }
69
-
70
- const object = await this.getObject('objects');
71
- const dbRecord = await object.directFind({filters: ['_id','=',id]});
72
- if(dbRecord.length === 0){
73
- // const newId = await object._makeNewID();
74
- const now = new Date();
75
- await object.directInsert(Object.assign({}, data, {
76
- // _id: newId,
77
- _id: id, // saas模式不支持修改对象
78
- owner: userSession.userId,
79
- space: userSession.spaceId,
80
- created: now,
81
- modified: now,
82
- created_by: userSession.userId,
83
- modified_by: userSession.userId,
84
- company_id: userSession.company_id,
85
- company_ids: userSession.company_ids,
86
- extend: data.name,
87
- custom: false,
88
- is_system: true
89
- }));
90
- // id = newId;
91
- }
92
- return object.update(id, data, userSession)
56
+ return this.objectsUpsert(id, doc, userSession)
93
57
  },
94
58
  },
95
59
  object_fields__upsert: {
@@ -98,6 +62,9 @@ module.exports = {
98
62
  "object_fields__upsert(id: String, doc: JSON): object_fields"
99
63
  },
100
64
  async handler(ctx) {
65
+ if(validator.toBoolean(process.env.STEEDOS_TENANT_ENABLE_SAAS || 'false', true) == true){
66
+ throw new Error('No permission')
67
+ }
101
68
  const userSession = ctx.meta.user;
102
69
  let { id, doc } = ctx.params;
103
70
  let data = '';
@@ -108,13 +75,21 @@ module.exports = {
108
75
  }
109
76
  delete data.space;
110
77
 
111
- if(data.is_system){
112
- data = _.pick(data, ['label', 'defaultValue', 'group', 'rows', 'sort_no', 'is_wide', 'index', 'sortable', 'searchable', 'filterable', 'visible_on', 'inlineHelpText', 'description', 'amis'])
113
- }
78
+
114
79
 
115
80
  const object = await this.getObject('object_fields');
116
81
  if(id.indexOf('.') > 0){
117
82
  const [objectName, fieldName] = id.split('.');
83
+
84
+ const dbObj = await this.getObject('objects').directFind({filters: ['name','=', objectName]});
85
+
86
+ if(dbObj.length === 0){
87
+ const records = await this.getObject('objects').find({filters: ['name','=', objectName]});
88
+ if(records.length > 0){
89
+ this.objectsUpsert(objectName, records[0], userSession)
90
+ }
91
+ }
92
+
118
93
  const dbRecord = await object.directFind({filters: [['object','=',objectName], ['name','=',fieldName]]});
119
94
  if(dbRecord.length > 0){
120
95
  id = dbRecord[0]._id;
@@ -138,6 +113,9 @@ module.exports = {
138
113
  id = newId;
139
114
  }
140
115
  }
116
+ if(data.is_system){
117
+ data = _.pick(data, ['label', 'defaultValue', 'group', 'rows', 'sort_no', 'is_wide', 'index', 'sortable', 'searchable', 'filterable', 'visible_on', 'inlineHelpText', 'description', 'amis', 'required'])
118
+ }
141
119
  return object.update(id, data, userSession)
142
120
  },
143
121
  },
@@ -154,7 +132,53 @@ module.exports = {
154
132
  * Methods
155
133
  */
156
134
  methods: {
135
+ objectsUpsert: {
136
+ async handler(id, doc, userSession){
137
+ let data = '';
138
+ if (_.isString(doc)) {
139
+ data = JSON.parse(doc);
140
+ } else {
141
+ data = JSON.parse(JSON.stringify(doc));
142
+ }
157
143
 
144
+ if(data.form && _.isString(data.form)){
145
+ data.form = JSON.parse(data.form)
146
+ }
147
+
148
+ delete data.space;
149
+ const name = data.name;
150
+
151
+ const object = await this.getObject('objects');
152
+ const dbRecord = await object.directFind({filters: ['_id','=',id]});
153
+ if(dbRecord.length === 0){
154
+ // const newId = await object._makeNewID();
155
+ const now = new Date();
156
+ await object.directInsert(Object.assign({}, data, {
157
+ // _id: newId,
158
+ _id: id, // saas模式不支持修改对象
159
+ name: name,
160
+ owner: userSession.userId,
161
+ space: userSession.spaceId,
162
+ created: now,
163
+ modified: now,
164
+ created_by: userSession.userId,
165
+ modified_by: userSession.userId,
166
+ company_id: userSession.company_id,
167
+ company_ids: userSession.company_ids,
168
+ extend: name,
169
+ custom: false,
170
+ is_system: true
171
+ }));
172
+ // id = newId;
173
+ }
174
+
175
+ if(data.is_system){
176
+ data = _.pick(data, ['label', 'icon', 'enable_files', 'enable_tasks', 'enable_notes', 'enable_events', 'enable_workflow', 'enable_instances', 'enable_inline_edit', 'enable_tree', 'enable_enhanced_lookup', 'description', 'is_deleted'])
177
+ }
178
+
179
+ return object.update(id, data, userSession)
180
+ }
181
+ }
158
182
  },
159
183
 
160
184
  /**