diff options
author | amadilsons <joao.amado.95@gmail.com> | 2017-10-05 16:46:55 +0200 |
---|---|---|
committer | amadilsons <joao.amado.95@gmail.com> | 2017-10-05 16:46:55 +0200 |
commit | 214fe6a61f60513d3ddfc9eee423c1b932ff8463 (patch) | |
tree | 9dee4e972a60a55f3c9dd18733c664c95520a248 /models/lists.js | |
parent | c865bfe49785181d97b25cb683c0ed37d82c1a69 (diff) | |
download | wekan-214fe6a61f60513d3ddfc9eee423c1b932ff8463.tar.gz wekan-214fe6a61f60513d3ddfc9eee423c1b932ff8463.tar.bz2 wekan-214fe6a61f60513d3ddfc9eee423c1b932ff8463.zip |
feature implemented, known bugs fixed
Diffstat (limited to 'models/lists.js')
-rw-r--r-- | models/lists.js | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/models/lists.js b/models/lists.js index 442b9ee1..877b3d83 100644 --- a/models/lists.js +++ b/models/lists.js @@ -46,16 +46,24 @@ Lists.attachSchema(new SimpleSchema({ type: Object, optional: true, }, - "wipLimit.value": { - type: SimpleSchema.Integer, + 'wipLimit.value': { + type: Number, + decimal: false, + autoValue() { + if(this.isInsert){ + return 0; + } + return this.value; + }, optional: true, }, - "wipLimit.enabled":{ + 'wipLimit.enabled':{ type: Boolean, autoValue() { if(this.isInsert){ return false; } + return this.value; }, optional: true, }, @@ -89,6 +97,17 @@ Lists.helpers({ board() { return Boards.findOne(this.boardId); }, + + getWipLimit(option){ + const list = Lists.findOne({ _id: this._id }); + if(!list.wipLimit) { // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set + return 0; + } else if(!option) { + return list.wipLimit; + } else { + return list.wipLimit[option] ? list.wipLimit[option] : 0; // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set + } + }, }); Lists.mutations({ @@ -105,11 +124,29 @@ Lists.mutations({ }, toggleWipLimit(toggle) { - return { $set: { "wipLimit.enabled": toggle } }; + return { $set: { 'wipLimit.enabled': toggle } }; }, setWipLimit(limit) { - return { $set: { "wipLimit.value": limit } }; + return { $set: { 'wipLimit.value': limit } }; + }, +}); + +Meteor.methods({ + applyWipLimit(listId, limit){ + check(listId, String); + check(limit, Number); + 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.wipLimit.enabled); + } else { + list.toggleWipLimit(true); // First time toggle is always to 'true' because default is 'false' + } }, }); |