Commit 2f70f876 authored by Curtis Adam's avatar Curtis Adam

Update the bonus filter to match the current descriptions

parent 9eff83a1
......@@ -85,8 +85,17 @@ export let Filter = class Filter {
case "wordcloud":
filter.wordcloud = content;
break;
case "bonus":
filter.learningActive = content;
case "noBonus":
filter.learningActive = undefined;
filter.learningEnd = undefined;
break;
case "bonusActive":
filter.learningActive = true;
filter.learningEnd = {$gt: true};
break;
case "bonusFinished":
filter.learningActive = true;
filter.learningEnd = {$lte: true};
break;
case "kind":
filter.kind = content;
......@@ -231,6 +240,11 @@ export let Filter = class Filter {
}
if (FilterNavigation.gotBonusFilter(FilterNavigation.getRouteId()) && activeFilter.learningActive !== undefined) {
query.learningActive = activeFilter.learningActive;
if (activeFilter.learningEnd.$lte !== undefined) {
query.learningEnd = {$lte: new Date()};
} else {
query.learningEnd = {$gt: new Date()};
}
}
if (FilterNavigation.gotWordCloudFilter(FilterNavigation.getRouteId()) && activeFilter.wordcloud !== undefined) {
query.wordcloud = activeFilter.wordcloud;
......
......@@ -14,17 +14,17 @@
"set-list.everything"}}</a>
</li>
{{#if gotBonusCardsets}}
<li><a href="#" class="filterBonus" data-id="true">
<li><a href="#" class="filterActiveBonus">
{{_ "set-list.activeLearnphase"}}
{{#if resultsFilterBonus true}}
{{#if resultsFilterBonus 0}}
<span class="glyphicon glyphicon-filter"></span>
{{/if}}
</a></li>
{{/if}}
{{#if gotNoBonusCardsets}}
<li><a href="#" class="filterBonus" data-id="false">
{{#if gotFinishedBonusCardsets}}
<li><a href="#" class="filterFinishedBonus">
{{_ "set-list.inactiveLearnphase"}}
{{#if resultsFilterBonus false}}
{{#if resultsFilterBonus 1}}
<span class="glyphicon glyphicon-filter"></span>
{{/if}}
</a></li>
......
......@@ -13,26 +13,37 @@ Template.filterItemFilterBonus.helpers({
hasBonusFilter: function () {
return Filter.getFilterQuery().learningActive !== undefined;
},
resultsFilterBonus: function (bonus) {
return Filter.getFilterQuery().learningActive === bonus;
resultsFilterBonus: function (bonusType) {
let query = Filter.getFilterQuery();
switch (bonusType) {
case 0:
return (query.learningActive !== undefined && query.learningEnd.$gt !== undefined);
case 1:
return (query.learningActive !== undefined && query.learningEnd.$lte !== undefined);
}
},
gotBonusCardsets: function () {
let query = Filter.getFilterQuery();
query.learningActive = true;
query.learningEnd = {$gt: new Date()};
return Cardsets.findOne(query);
},
gotNoBonusCardsets: function () {
gotFinishedBonusCardsets: function () {
let query = Filter.getFilterQuery();
query.learningActive = false;
query.learningActive = true;
query.learningEnd = {$lte: new Date()};
return Cardsets.findOne(query);
}
});
Template.filterItemFilterBonus.events({
'click .noFilterBonus': function () {
Filter.setActiveFilter(undefined, "bonus");
Filter.setActiveFilter(undefined, "noBonus");
},
'click .filterActiveBonus': function () {
Filter.setActiveFilter(undefined, "bonusActive");
},
'click .filterBonus': function (event) {
Filter.setActiveFilter($(event.target).data('id'), "bonus");
'click .filterFinishedBonus': function () {
Filter.setActiveFilter(undefined, "bonusFinished");
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment