summaryrefslogtreecommitdiffstats
path: root/models/lists.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/lists.js')
-rw-r--r--models/lists.js42
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'));
},
});