From fdd1aad80de336061d576b99d86fc94694131af6 Mon Sep 17 00:00:00 2001 From: amadilsons Date: Tue, 31 Oct 2017 21:10:36 +0000 Subject: added soft wip limit feature, fixed wipLimit=0 bug (??) --- models/lists.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'models') 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')); }, }); -- cgit v1.2.3-1-g7c22 From c17f26f6ba793f5f251ccf27f1b26c15f938a788 Mon Sep 17 00:00:00 2001 From: amadilsons Date: Tue, 31 Oct 2017 21:20:53 +0000 Subject: fix: always restore archived cards if wip limit is soft --- models/cards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'models') diff --git a/models/cards.js b/models/cards.js index 5b752ec3..5de17c6f 100644 --- a/models/cards.js +++ b/models/cards.js @@ -182,7 +182,7 @@ Cards.helpers({ canBeRestored() { const list = Lists.findOne({_id: this.listId}); - if(list.getWipLimit() && list.getWipLimit('enabled') && list.getWipLimit('value') === list.cards().count()){ + if(!list.getWipLimit('soft') && list.getWipLimit('enabled') && list.getWipLimit('value') === list.cards().count()){ return false; } return true; -- cgit v1.2.3-1-g7c22