diff options
author | amadilsons <joao.amado.95@gmail.com> | 2017-10-31 21:10:36 +0000 |
---|---|---|
committer | amadilsons <joao.amado.95@gmail.com> | 2017-10-31 21:10:36 +0000 |
commit | fdd1aad80de336061d576b99d86fc94694131af6 (patch) | |
tree | 9012a3020cb724d37c7466d650912d9c9afc0cae /models | |
parent | 8bf3f300ad46cf13f17176b0986a72c88191fbb1 (diff) | |
download | wekan-fdd1aad80de336061d576b99d86fc94694131af6.tar.gz wekan-fdd1aad80de336061d576b99d86fc94694131af6.tar.bz2 wekan-fdd1aad80de336061d576b99d86fc94694131af6.zip |
added soft wip limit feature, fixed wipLimit=0 bug (??)
Diffstat (limited to 'models')
-rw-r--r-- | models/lists.js | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/models/lists.js b/models/lists.js index 1b999b07..efda9c3f 100644 --- a/models/lists.js +++ b/models/lists.js @@ -49,23 +49,15 @@ Lists.attachSchema(new SimpleSchema({ 'wipLimit.value': { type: Number, decimal: false, - autoValue() { - if(this.isInsert){ - return 0; - } - return this.value; - }, - optional: true, + defaultValue: 1, }, - 'wipLimit.enabled':{ + 'wipLimit.enabled': { type: Boolean, - autoValue() { - if(this.isInsert){ - return false; - } - return this.value; - }, - optional: true, + defaultValue: false, + }, + 'wipLimit.soft': { + type: Boolean, + defaultValue: false, }, })); @@ -123,6 +115,10 @@ Lists.mutations({ return { $set: { archived: false } }; }, + toggleSoftLimit(toggle) { + return { $set: { 'wipLimit.soft': toggle } }; + }, + toggleWipLimit(toggle) { return { $set: { 'wipLimit.enabled': toggle } }; }, @@ -136,17 +132,25 @@ Meteor.methods({ applyWipLimit(listId, limit){ check(listId, String); check(limit, Number); + if(limit === 0){ + limit = 1; + } Lists.findOne({ _id: listId }).setWipLimit(limit); }, enableWipLimit(listId) { check(listId, String); const list = Lists.findOne({ _id: listId }); - if(list.getWipLimit()){ // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set - list.toggleWipLimit(!list.getWipLimit('enabled')); - } else { - list.toggleWipLimit(true); // First time toggle is always to 'true' because default is 'false' + if(list.getWipLimit('value') === 0){ + list.setWipLimit(1); } + list.toggleWipLimit(!list.getWipLimit('enabled')); + }, + + enableSoftLimit(listId) { + check(listId, String); + const list = Lists.findOne({ _id: listId }); + list.toggleSoftLimit(!list.getWipLimit('soft')); }, }); |