Skip to content

Commit

Permalink
清理picklist相关动作.
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Dec 4, 2024
1 parent e92ca6f commit 3dcfdb8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
34 changes: 0 additions & 34 deletions packages/standard-objects/picklist_options.trigger.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
const _ = require('underscore');

const getFilters = function (spaceId, doc, id) {
let filter = [];
if (doc.name) {
filter.push(['name', '=', doc.name])
}
if (doc.value) {
if (filter.length > 0) {
filter.push('or');
}
filter.push(['value', '=', doc.value])
}

let filter2 = [['space', '=', spaceId], ['picklist', '=', doc.picklist]]
if (id) {
filter2.push(['_id', '<>', id])
}
return { filters: [filter2, 'and', filter] }
}

const getDefaultCount = async function(getObject, spaceId, picklist, id){
let filters = [['space', '=', spaceId], ['picklist', '=', picklist], ['default', '=', true]]
if(id){
Expand All @@ -42,12 +23,6 @@ module.exports = {

beforeInsert: async function () {
var doc = this.doc
if (doc.name) {
let count = await this.getObject('picklist_options').count(getFilters(doc.space, doc))
if (count > 0) {
throw new Error("选项名称或选项值不能重复");
}
}

if(_.has(doc, 'default') && doc.default){
let dCount = await getDefaultCount(this.getObject, doc.space, doc.picklist);
Expand All @@ -67,15 +42,6 @@ module.exports = {
dbDoc = await this.getObject('picklist_options').findOne(id, { fields: { space: 1, picklist: 1 } });
}

if (_.has(doc, 'name') || _.has(doc, 'value')) {
if (dbDoc) {
let count = await this.getObject('picklist_options').count(getFilters(dbDoc.space, Object.assign({ picklist: dbDoc.picklist }, doc), id))
if (count > 0) {
throw new Error("选项名称或选项值不能重复");
}
}
}

if(_.has(doc, 'default') && doc.default){
let dCount = await getDefaultCount(this.getObject, dbDoc.space, dbDoc.picklist, id);
if(dCount > 0){
Expand Down
68 changes: 0 additions & 68 deletions packages/standard-objects/picklists.object.js

This file was deleted.

0 comments on commit 3dcfdb8

Please sign in to comment.