mirror of
https://github.com/steedos/steedos-platform
synced 2024-11-22 17:06:42 +00:00
fix 新建对象时,不要自动新建“系统信息”分组
https://github.com/steedos/steedos-platform/issues/6980
This commit is contained in:
parent
db8a4e6a8a
commit
a2e20f08f6
@ -5,7 +5,7 @@ var objectCore = require('./objects.core.js');
|
||||
|
||||
const objectFieldsFind = function (filter) {
|
||||
return objectql.wrapAsync(async function () {
|
||||
return await objectql.getObject('object_fields').find(this.filter);
|
||||
return await objectql.getObject('object_fields').directFind(this.filter);
|
||||
}, { filter: filter })
|
||||
}
|
||||
|
||||
|
@ -318,6 +318,59 @@ let objectTriggers = {
|
||||
filterable: true,
|
||||
sort_no: 10
|
||||
});
|
||||
Creator.getCollection("object_fields").insert({
|
||||
object: doc.name,
|
||||
owner: userId,
|
||||
_name: "created",
|
||||
label: "创建时间",
|
||||
space: doc.space,
|
||||
type: "datetime",
|
||||
group: '',
|
||||
sort_no: 9999,
|
||||
readonly: true,
|
||||
disabled: true,
|
||||
sortable: true
|
||||
});
|
||||
Creator.getCollection("object_fields").insert({
|
||||
object: doc.name,
|
||||
owner: userId,
|
||||
_name: "created_by",
|
||||
label: "创建人",
|
||||
space: doc.space,
|
||||
type: "lookup",
|
||||
reference_to: 'users',
|
||||
group: '',
|
||||
sort_no: 9999,
|
||||
readonly: true,
|
||||
disabled: true,
|
||||
});
|
||||
Creator.getCollection("object_fields").insert({
|
||||
object: doc.name,
|
||||
owner: userId,
|
||||
_name: "modified",
|
||||
label: "修改时间",
|
||||
space: doc.space,
|
||||
type: "datetime",
|
||||
group: '',
|
||||
sort_no: 9999,
|
||||
readonly: true,
|
||||
disabled: true,
|
||||
sortable: true
|
||||
});
|
||||
Creator.getCollection("object_fields").insert({
|
||||
object: doc.name,
|
||||
owner: userId,
|
||||
_name: "modified_by",
|
||||
label: "修改人",
|
||||
space: doc.space,
|
||||
space: doc.space,
|
||||
type: "lookup",
|
||||
reference_to: 'users',
|
||||
group: '',
|
||||
sort_no: 9999,
|
||||
readonly: true,
|
||||
disabled: true,
|
||||
});
|
||||
// Creator.getCollection("object_fields").insert({
|
||||
// object: doc.name,
|
||||
// owner: userId,
|
||||
|
@ -7,7 +7,30 @@ const steedosI18n = require("@steedos/i18n");
|
||||
const _ = require("lodash");
|
||||
const clone = require("clone");
|
||||
const serviceObjectMixin = require('@steedos/service-object-mixin');
|
||||
const objectql = require('@steedos/objectql');
|
||||
// 默认值字段代码:services/standard-object-database/main/default/services/object_fields.service.js
|
||||
|
||||
const initSummaryDoc = async (doc) => {
|
||||
if (!doc.summary_object) {
|
||||
throw new Error("object_fields_error_summary_object_required");
|
||||
}
|
||||
let summaryObject = register.getObjectConfig(doc.summary_object);
|
||||
let summaryConfig = {
|
||||
summary_object: doc.summary_object,
|
||||
summary_type: doc.summary_type,
|
||||
summary_field: doc.summary_field,
|
||||
field_name: doc.name,
|
||||
object_name: doc.object
|
||||
};
|
||||
const dataType = await objectql.getSummaryDataType(summaryConfig, summaryObject);
|
||||
if (!dataType) {
|
||||
throw new Error("object_fields_error_summary_data_type_not_found");
|
||||
}
|
||||
doc.data_type = dataType;
|
||||
// objectql.validateFilters(doc.summary_filters, summaryObject.fields);
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: "object_fields",
|
||||
mixins: [serviceObjectMixin],
|
||||
@ -291,7 +314,7 @@ module.exports = {
|
||||
|
||||
_.map(objectFields, (objectField)=>{
|
||||
if(!objectField.group){
|
||||
objectField.group = '基本信息'
|
||||
objectField.group = '通用'
|
||||
}
|
||||
})
|
||||
|
||||
@ -404,7 +427,7 @@ module.exports = {
|
||||
const newId = await object_fields._makeNewID();
|
||||
const now = new Date();
|
||||
const field = _.find(fields, { name: fieldName });
|
||||
await object_fields.directInsert(Object.assign({}, field, {
|
||||
const doc = Object.assign({}, field, {
|
||||
_id: newId,
|
||||
owner: userSession.userId,
|
||||
space: userSession.spaceId,
|
||||
@ -415,7 +438,11 @@ module.exports = {
|
||||
modified_by: userSession.userId,
|
||||
company_id: userSession.company_id,
|
||||
company_ids: userSession.company_ids
|
||||
}));
|
||||
});
|
||||
if(doc.type === "summary"){
|
||||
await initSummaryDoc(doc);
|
||||
}
|
||||
await object_fields.directInsert(doc);
|
||||
log.insert.success.push(fieldName);
|
||||
} catch (e) {
|
||||
log.insert.error.push(fieldName);
|
||||
@ -430,6 +457,10 @@ module.exports = {
|
||||
const field = _.find(fields, { name: fieldName });
|
||||
const id = _.find(dbFields, { name: fieldName })._id;
|
||||
const submitField = _.omit(field, ['name', '_name']);
|
||||
|
||||
if(submitField.type === "summary"){
|
||||
await initSummaryDoc(submitField);
|
||||
}
|
||||
await object_fields.directUpdate(id, Object.assign({}, submitField, {
|
||||
modified: now,
|
||||
modified_by: userSession.userId
|
||||
|
Loading…
Reference in New Issue
Block a user