From c9c650664fd92f0924afb4548a50c7bca167d955 Mon Sep 17 00:00:00 2001 From: amadilsons Date: Thu, 28 Sep 2017 16:59:53 +0200 Subject: basic frontend setup, List model updated with wipLimit field --- client/components/lists/listHeader.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 7fe42884..47fddd27 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -21,6 +21,11 @@ BlazeComponent.extendComponent({ return count > this.limitToShowCardsCount(); }, + hasWipLimit() { + return null; + //return this.currentData().wipLimit ? true : false; + }, + events() { return [{ 'click .js-open-list-menu': Popup.open('listAction'), @@ -61,6 +66,7 @@ Template.listActionPopup.events({ this.archive(); Popup.close(); }, + 'click .js-set-wip-limit': Popup.open('setWipLimit'), 'click .js-more': Popup.open('listMore'), }); -- cgit v1.2.3-1-g7c22 From a918d36533bd61765f954f60c0e3af78b014907a Mon Sep 17 00:00:00 2001 From: amadilsons Date: Fri, 29 Sep 2017 16:52:53 +0200 Subject: mostly frontend work, lists coll update with wipLimit field --- client/components/lists/listHeader.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 47fddd27..0dc15315 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -8,6 +8,10 @@ BlazeComponent.extendComponent({ } }, + hasWipLimit() { + return this.currentData().wipLimit > 0 ? true : false; + }, + isWatching() { const list = this.currentData(); return list.findWatcher(Meteor.userId()); @@ -21,11 +25,6 @@ BlazeComponent.extendComponent({ return count > this.limitToShowCardsCount(); }, - hasWipLimit() { - return null; - //return this.currentData().wipLimit ? true : false; - }, - events() { return [{ 'click .js-open-list-menu': Popup.open('listAction'), @@ -42,6 +41,10 @@ BlazeComponent.extendComponent({ }).register('listHeader'); Template.listActionPopup.helpers({ + hasWipLimit() { + return this.wipLimit > 0 ? true : false; + }, + isWatching() { return this.findWatcher(Meteor.userId()); }, @@ -70,6 +73,13 @@ Template.listActionPopup.events({ 'click .js-more': Popup.open('listMore'), }); +Template.setWipLimitPopup.events({ + 'click .wip-limit-apply'(_, instance) { + const limit = instance.$('.wip-limit-value').val(); + this.setWipLimit(limit); + }, +}); + Template.listMorePopup.events({ 'click .js-delete': Popup.afterConfirm('listDelete', function () { Popup.close(); -- cgit v1.2.3-1-g7c22 From 089dbf0cf6a3e144d0271a8666d58e689f8c8dba Mon Sep 17 00:00:00 2001 From: amadilsons Date: Wed, 4 Oct 2017 11:12:52 +0200 Subject: on its way --- client/components/lists/listHeader.js | 77 ++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 6 deletions(-) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 0dc15315..9ae2c1fe 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -8,8 +8,9 @@ BlazeComponent.extendComponent({ } }, - hasWipLimit() { - return this.currentData().wipLimit > 0 ? true : false; + isWipLimitEnabled() { + const limit = this.currentData().wipLimit + return limit.enabled && limit.value > 0; }, isWatching() { @@ -41,10 +42,9 @@ BlazeComponent.extendComponent({ }).register('listHeader'); Template.listActionPopup.helpers({ - hasWipLimit() { - return this.wipLimit > 0 ? true : false; + isWipLimitEnabled() { + return Lists.findOne(this.data()._id, { 'wipLimit.enabled': 1 }).wipLimit.enabled; }, - isWatching() { return this.findWatcher(Meteor.userId()); }, @@ -73,12 +73,77 @@ Template.listActionPopup.events({ 'click .js-more': Popup.open('listMore'), }); +Template.setWipLimitPopup.helpers({ + one() { + //console.log(this) + //console.log(Template.instance()) + } +}); + +BlazeComponent.extendComponent({ + onCreated() { + this.wipEnabled = new ReactiveVar(Template.currentData().wipLimit.enabled); + }, + + toggleWipEnabled() { + const list = Lists.findOne(this.data()._id); + list.wipLimit.enabled ? list.setWipLimitDisabled() : list.setWipLimitEnabled() + }, + + isWipLimitEnabled() { + return Lists.findOne(this.data()._id, { 'wipLimit.enabled': 1 }).wipLimit.enabled; + }, + events() { + return [{ + 'click .js-enable-wip-limit'(_, instance) { + //By default wipLimit.enabled is false or undefined. First click will always be to enable wip limiting + this.wipEnabled.set(!this.wipEnabled.get()); + //console.log(Template.parentData(2)) + //Template.parentData(2).data.toggleWipLimit(!Template.currentData().wipLimit.enabled); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" + this.toggleWipEnabled() + }, + 'click .wip-limit-apply'(_, instance) { + const list = Template.currentData(); + const limit = Template.instance().$('.wip-limit-value').val(); + + if(limit < list.allCards().count()){ + Template.instance().$('.wip-limit-error').click(); + } else { + list.setWipLimit(limit); + } + }, + 'click .wip-limit-error': Popup.open('wipLimitError'), + }]; + }, +}).register('setWipLimitPopup'); + + +/* +Template.setWipLimitPopup.helpers({ + isWipLimitEnabled(instance) { + console.log(this); + console.log(Template.currentData()); + console.log(instance); + return Template.currentData().wipLimit.enabled; + }, +}); + Template.setWipLimitPopup.events({ + 'click .js-enable-wip-limit'(_, instance) { + //By default wipLimit.enabled is false or undefined. First click will always be to enable wip limiting + instance.wipEnabled.set(!instance.wipEnabled.get()) + // list.toggleWipLimit(!list.wipLimit.enabled); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" + }, 'click .wip-limit-apply'(_, instance) { const limit = instance.$('.wip-limit-value').val(); + if(limit < this.allCards().count()){ + instance.$('.wip-limit-error').click(); //open popup with invisible button click + return; + } this.setWipLimit(limit); }, -}); + 'click .wip-limit-error': Popup.open('wipLimitError'), +});*/ Template.listMorePopup.events({ 'click .js-delete': Popup.afterConfirm('listDelete', function () { -- cgit v1.2.3-1-g7c22 From c865bfe49785181d97b25cb683c0ed37d82c1a69 Mon Sep 17 00:00:00 2001 From: amadilsons Date: Wed, 4 Oct 2017 17:48:37 +0200 Subject: most work concluded, code needs clean up, further testing required --- client/components/lists/listHeader.js | 101 ++++++++++++++-------------------- 1 file changed, 42 insertions(+), 59 deletions(-) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 9ae2c1fe..94b70f2b 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -43,8 +43,14 @@ BlazeComponent.extendComponent({ Template.listActionPopup.helpers({ isWipLimitEnabled() { - return Lists.findOne(this.data()._id, { 'wipLimit.enabled': 1 }).wipLimit.enabled; + const prevState = Template.parentData(4).stack[0].dataContext.wipEnableState; + // If user was already inside setWipLimitPopup, return previous state. Popup stack not reacting to database mutations + if(typeof prevState !== "undefined") { + return prevState; + } + return Template.currentData().wipLimit.enabled; }, + isWatching() { return this.findWatcher(Meteor.userId()); }, @@ -73,78 +79,55 @@ Template.listActionPopup.events({ 'click .js-more': Popup.open('listMore'), }); -Template.setWipLimitPopup.helpers({ - one() { - //console.log(this) - //console.log(Template.instance()) - } -}); - BlazeComponent.extendComponent({ onCreated() { - this.wipEnabled = new ReactiveVar(Template.currentData().wipLimit.enabled); + const prevState = Template.parentData(4).stack[0].dataContext.wipEnableState; + // Check if the user as already opened this popup before and retrieve previous state + // This check is necessary due to the fact that database mutations inside popups are not reactive inside the popup stack. + //The use of ReactiveVar is due to the same reason. + if(typeof prevState !== "undefined") { + this.wipEnabled = new ReactiveVar(prevState) + } else { + this.wipEnabled = new ReactiveVar(Template.currentData().wipLimit.enabled); + } }, - toggleWipEnabled() { - const list = Lists.findOne(this.data()._id); - list.wipLimit.enabled ? list.setWipLimitDisabled() : list.setWipLimitEnabled() + onDestroyed() { + // Save current wipEnabled state in the first element of the popup stack to maintain UI coherence if user returns to popup + Template.parentData(4).stack[0].dataContext.wipEnableState = this.wipEnabled.get(); }, - isWipLimitEnabled() { - return Lists.findOne(this.data()._id, { 'wipLimit.enabled': 1 }).wipLimit.enabled; + applyWipLimit() { + const list = Template.currentData(); + const limit = Template.instance().$('.wip-limit-value').val(); + + if(limit < list.cards().count()){ + Template.instance().$('.wip-limit-error').click(); + } else { + list.setWipLimit(limit); + } + }, + + enableWipLimit() { + const list = Template.currentData(); + // Prevent user from using previously stored wipLimit.value if it is less than the current number of cards in the list + if(!list.wipLimit.enabled && list.wipLimit.value < list.cards().count()){ + list.setWipLimit(list.cards().count()); + } + + this.wipEnabled.set(!this.wipEnabled.get()); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" + list.toggleWipLimit(this.wipEnabled.get()); }, + events() { return [{ - 'click .js-enable-wip-limit'(_, instance) { - //By default wipLimit.enabled is false or undefined. First click will always be to enable wip limiting - this.wipEnabled.set(!this.wipEnabled.get()); - //console.log(Template.parentData(2)) - //Template.parentData(2).data.toggleWipLimit(!Template.currentData().wipLimit.enabled); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" - this.toggleWipEnabled() - }, - 'click .wip-limit-apply'(_, instance) { - const list = Template.currentData(); - const limit = Template.instance().$('.wip-limit-value').val(); - - if(limit < list.allCards().count()){ - Template.instance().$('.wip-limit-error').click(); - } else { - list.setWipLimit(limit); - } - }, + 'click .js-enable-wip-limit': this.enableWipLimit, + 'click .wip-limit-apply': this.applyWipLimit, 'click .wip-limit-error': Popup.open('wipLimitError'), }]; }, }).register('setWipLimitPopup'); - -/* -Template.setWipLimitPopup.helpers({ - isWipLimitEnabled(instance) { - console.log(this); - console.log(Template.currentData()); - console.log(instance); - return Template.currentData().wipLimit.enabled; - }, -}); - -Template.setWipLimitPopup.events({ - 'click .js-enable-wip-limit'(_, instance) { - //By default wipLimit.enabled is false or undefined. First click will always be to enable wip limiting - instance.wipEnabled.set(!instance.wipEnabled.get()) - // list.toggleWipLimit(!list.wipLimit.enabled); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" - }, - 'click .wip-limit-apply'(_, instance) { - const limit = instance.$('.wip-limit-value').val(); - if(limit < this.allCards().count()){ - instance.$('.wip-limit-error').click(); //open popup with invisible button click - return; - } - this.setWipLimit(limit); - }, - 'click .wip-limit-error': Popup.open('wipLimitError'), -});*/ - Template.listMorePopup.events({ 'click .js-delete': Popup.afterConfirm('listDelete', function () { Popup.close(); -- cgit v1.2.3-1-g7c22 From 214fe6a61f60513d3ddfc9eee423c1b932ff8463 Mon Sep 17 00:00:00 2001 From: amadilsons Date: Thu, 5 Oct 2017 16:46:55 +0200 Subject: feature implemented, known bugs fixed --- client/components/lists/listHeader.js | 54 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 33 deletions(-) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 94b70f2b..361f69cf 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -8,16 +8,19 @@ BlazeComponent.extendComponent({ } }, - isWipLimitEnabled() { - const limit = this.currentData().wipLimit - return limit.enabled && limit.value > 0; - }, - isWatching() { const list = this.currentData(); return list.findWatcher(Meteor.userId()); }, + isWipLimitEnabled() { + const wipLimit = this.currentData().getWipLimit(); + if(!wipLimit) { + return 0; + } + return wipLimit.enabled && wipLimit.value > 0; + }, + limitToShowCardsCount() { return Meteor.user().getLimitToShowCardsCount(); }, @@ -43,12 +46,7 @@ BlazeComponent.extendComponent({ Template.listActionPopup.helpers({ isWipLimitEnabled() { - const prevState = Template.parentData(4).stack[0].dataContext.wipEnableState; - // If user was already inside setWipLimitPopup, return previous state. Popup stack not reacting to database mutations - if(typeof prevState !== "undefined") { - return prevState; - } - return Template.currentData().wipLimit.enabled; + return Template.currentData().getWipLimit('enabled'); }, isWatching() { @@ -80,43 +78,33 @@ Template.listActionPopup.events({ }); BlazeComponent.extendComponent({ - onCreated() { - const prevState = Template.parentData(4).stack[0].dataContext.wipEnableState; - // Check if the user as already opened this popup before and retrieve previous state - // This check is necessary due to the fact that database mutations inside popups are not reactive inside the popup stack. - //The use of ReactiveVar is due to the same reason. - if(typeof prevState !== "undefined") { - this.wipEnabled = new ReactiveVar(prevState) - } else { - this.wipEnabled = new ReactiveVar(Template.currentData().wipLimit.enabled); - } - }, - - onDestroyed() { - // Save current wipEnabled state in the first element of the popup stack to maintain UI coherence if user returns to popup - Template.parentData(4).stack[0].dataContext.wipEnableState = this.wipEnabled.get(); - }, - applyWipLimit() { const list = Template.currentData(); - const limit = Template.instance().$('.wip-limit-value').val(); + const limit = parseInt(Template.instance().$('.wip-limit-value').val(), 10); if(limit < list.cards().count()){ Template.instance().$('.wip-limit-error').click(); } else { - list.setWipLimit(limit); + Meteor.call('applyWipLimit', list._id, limit); + Popup.back(); } }, enableWipLimit() { const list = Template.currentData(); // Prevent user from using previously stored wipLimit.value if it is less than the current number of cards in the list - if(!list.wipLimit.enabled && list.wipLimit.value < list.cards().count()){ + if(list.getWipLimit() && !list.wipLimit.enabled && list.wipLimit.value < list.cards().count()){ list.setWipLimit(list.cards().count()); } + Meteor.call('enableWipLimit', Template.currentData()._id); + }, + + isWipLimitEnabled() { + return Template.currentData().getWipLimit('enabled'); + }, - this.wipEnabled.set(!this.wipEnabled.get()); //If wipLimit.enabled is not yet definied, the negation of "undefined" is "true" - list.toggleWipLimit(this.wipEnabled.get()); + wipLimitValue(){ + return Template.currentData().getWipLimit('value'); }, events() { -- cgit v1.2.3-1-g7c22 From f77da76c682ec7ad1b5e141d113d4b74371f46ae Mon Sep 17 00:00:00 2001 From: amadilsons Date: Thu, 5 Oct 2017 17:22:03 +0200 Subject: added i18n translation, minor fix --- client/components/lists/listHeader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client/components/lists/listHeader.js') diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 361f69cf..9974c788 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -93,10 +93,10 @@ BlazeComponent.extendComponent({ enableWipLimit() { const list = Template.currentData(); // Prevent user from using previously stored wipLimit.value if it is less than the current number of cards in the list - if(list.getWipLimit() && !list.wipLimit.enabled && list.wipLimit.value < list.cards().count()){ + if(list.getWipLimit() && !list.getWipLimit('enabled') && list.getWipLimit('value') < list.cards().count()){ list.setWipLimit(list.cards().count()); } - Meteor.call('enableWipLimit', Template.currentData()._id); + Meteor.call('enableWipLimit', list._id); }, isWipLimitEnabled() { -- cgit v1.2.3-1-g7c22