@steedos/standard-object-database 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.
|
@@ -42,6 +42,9 @@ fields:
|
|
|
42
42
|
create: false
|
|
43
43
|
reference_to: permission_set
|
|
44
44
|
reference_to_field: name
|
|
45
|
+
defaultValue:
|
|
46
|
+
- admin
|
|
47
|
+
- user
|
|
45
48
|
optionsFunction: !<tag:yaml.org,2002:js/function> |-
|
|
46
49
|
function () {
|
|
47
50
|
var profiles = Creator.odata.query('permission_set', {$filter: "(type eq 'profile')"}, true);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: baozhoutao@steedos.com
|
|
3
3
|
* @Date: 2022-03-28 09:35:34
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: 孙浩林 sunhaolin@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-07-13 13:28:02
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
const _ = require("underscore");
|
|
@@ -91,7 +91,7 @@ Creator.Objects['object_listviews'].triggers = Object.assign(Creator.Objects['ob
|
|
|
91
91
|
on: "server",
|
|
92
92
|
when: "before.remove",
|
|
93
93
|
todo: function (userId, doc) {
|
|
94
|
-
console.log("before.remove");
|
|
94
|
+
// console.log("before.remove");
|
|
95
95
|
if (doc.owner !== userId) {
|
|
96
96
|
throw new Meteor.Error(403, "can only remove own list view");
|
|
97
97
|
}
|
|
@@ -52,8 +52,8 @@ module.exports = {
|
|
|
52
52
|
let views = []
|
|
53
53
|
if(filters._id && !filters._id.$ne){
|
|
54
54
|
let id = filters._id
|
|
55
|
-
id = id.replace(/\\/g, '');
|
|
56
55
|
if(_.isString(id)){
|
|
56
|
+
id = id.replace(/\\/g, ''); // string类型才有replce方法
|
|
57
57
|
let objectName = id.substr(0, id.indexOf("."));
|
|
58
58
|
if(objectName){
|
|
59
59
|
let view = await InternalData.getObjectListView(objectName, this.userId, id);
|
|
@@ -62,6 +62,21 @@ module.exports = {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
else if (id.$in) {
|
|
66
|
+
for (const _id of id.$in) {
|
|
67
|
+
if(_.isString(_id) && _id.indexOf('.') > 0){
|
|
68
|
+
let objectName = _id.split('.')[0];
|
|
69
|
+
let view = await InternalData.getObjectListView(objectName, this.userId, _id);
|
|
70
|
+
if(view){
|
|
71
|
+
if (_.isArray(this.query.fields)) {
|
|
72
|
+
const fields = ["_id"].concat(this.query.fields);
|
|
73
|
+
view = _.pick(view, fields);
|
|
74
|
+
}
|
|
75
|
+
views.push(view);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
65
80
|
}else if(filters.object_name){
|
|
66
81
|
views = await InternalData.getObjectListViews(filters.object_name, this.userId);
|
|
67
82
|
}
|
|
@@ -76,10 +76,35 @@ module.exports = {
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
afterInsert: async function(){
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const object = this.doc;
|
|
80
|
+
const { spaceId , userId } = this;
|
|
81
|
+
if(object.enable_tree){
|
|
82
|
+
await objectTree.insertParentAndChildrenFieldForTreeObject(object)
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
const tabLabel = object.label || object.name;
|
|
86
|
+
const tabName = "object_" + object.name.replace(/__c$/, "");
|
|
87
|
+
const now = new Date();
|
|
88
|
+
const tabDoc = {
|
|
89
|
+
label: tabLabel,
|
|
90
|
+
name: tabName,
|
|
91
|
+
icon: object.icon,
|
|
92
|
+
type: "object",
|
|
93
|
+
mobile: true,
|
|
94
|
+
desktop: true,
|
|
95
|
+
object: object.name,
|
|
96
|
+
space: spaceId,
|
|
97
|
+
owner: userId,
|
|
98
|
+
created_by: userId,
|
|
99
|
+
created: now,
|
|
100
|
+
modified_by: userId,
|
|
101
|
+
modified: now,
|
|
102
|
+
company_id: object.companyId,
|
|
103
|
+
company_ids: object.companyIds
|
|
104
|
+
};
|
|
105
|
+
await objectql.getObject('tabs').insert(tabDoc);
|
|
106
|
+
|
|
107
|
+
|
|
83
108
|
// let spaceProfiles = await objectql.getObject('permission_set').find({space: this.spaceId, type: 'profile'});
|
|
84
109
|
// await objectql.getObject('object_layouts').insert({
|
|
85
110
|
// label: 'default',
|
|
@@ -145,5 +170,13 @@ module.exports = {
|
|
|
145
170
|
*/
|
|
146
171
|
|
|
147
172
|
await sleep(1000 * 2)
|
|
173
|
+
},
|
|
174
|
+
afterDelete: async function(){
|
|
175
|
+
const { previousDoc: object, spaceId } = this;
|
|
176
|
+
const objectTabs = await objectql.getObject('tabs').find({filters: [['type', '=', 'object'], ['object', '=', object.name], ['space', '=', spaceId]]})
|
|
177
|
+
for(const record of objectTabs){
|
|
178
|
+
// console.log(`delete tabs`, record._id, record.name)
|
|
179
|
+
await objectql.getObject('tabs').delete(record._id);
|
|
180
|
+
}
|
|
148
181
|
}
|
|
149
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.5.8
|
|
3
|
+
"version": "2.5.8",
|
|
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": "
|
|
18
|
+
"gitHead": "f40371af9656414e369dbc28f333546eb14d7ac0"
|
|
19
19
|
}
|