Commit 1e6e8947 authored by Curtis Adam's avatar Curtis Adam

Update the Bonus filter

parent cbe6092b
......@@ -1252,7 +1252,13 @@
"from": "Ab",
"noResults": "Keine Kartei oder Repetitorium ausgewählt oder Filtern liefert kein Ergebnis.",
"sort": "Sortieren ",
"reset": "Filter zurücksetzen"
"reset": "Filter zurücksetzen",
"bonus": {
"title": "Bonus",
"all": "Alle",
"bonus": "Mit Lern-Bonus",
"transcriptBonus": "Mit Mitschreib-Bonus"
}
},
"infinite-scroll": {
"remainingShort": "__current__ von __total__",
......
......@@ -1254,7 +1254,13 @@
"from": "Ab",
"noResults": "Keine Kartei oder Repetitorium ausgewählt oder Filtern liefert kein Ergebnis.",
"sort": "Sortieren ",
"reset": "Filter zurücksetzen"
"reset": "Filter zurücksetzen",
"bonus": {
"title": "Bonus",
"all": "Alle",
"bonus": "Mit Lern-Bonus",
"transcriptBonus": "Mit Mitschreib-Bonus"
}
},
"infinite-scroll": {
"remainingShort": "__current__ von __total__",
......
......@@ -119,16 +119,12 @@ export let Filter = class Filter {
filter.lecturerAuthorized = content;
break;
case "noBonus":
filter.learningActive = undefined;
filter.learningEnd = undefined;
delete filter.learningActive;
delete filter['transcriptBonus.enabled'];
break;
case "bonusActive":
filter.learningActive = true;
filter.learningEnd = {$gt: true};
break;
case "bonusFinished":
filter.learningActive = true;
filter.learningEnd = {$lte: true};
delete filter['transcriptBonus.enabled'];
break;
case "kind":
filter.kind = content;
......@@ -137,12 +133,8 @@ export let Filter = class Filter {
filter._id = content;
break;
case "transcriptBonus":
let transcriptBonus = {
transcriptBonus: {
enabled: true
}
};
Object.assign(filter, transcriptBonus);
delete filter.learningActive;
filter['transcriptBonus.enabled'] = true;
break;
}
}
......@@ -288,14 +280,9 @@ 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.gotBonusFilter(FilterNavigation.getRouteId()) && activeFilter.transcriptBonus !== undefined && activeFilter.transcriptBonus.enabled !== undefined) {
query['transcriptBonus.enabled'] = activeFilter.transcriptBonus.enabled;
if (FilterNavigation.gotBonusFilter(FilterNavigation.getRouteId()) && activeFilter['transcriptBonus.enabled'] !== undefined) {
query['transcriptBonus.enabled'] = activeFilter['transcriptBonus.enabled'];
}
if (FilterNavigation.gotWordCloudFilter(FilterNavigation.getRouteId()) && activeFilter.wordcloud !== undefined) {
query.wordcloud = activeFilter.wordcloud;
......
......@@ -3,7 +3,7 @@
<a href="#" class="dropdown-toggle bonusFilter cards-filter-element" data-toggle="dropdown"
role="button"
aria-haspopup="true" aria-expanded="false">
{{_ "set-list.learnphase"}}
{{_ "filter-pool.bonus.title"}}
{{#if hasBonusFilter}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
......@@ -11,19 +11,19 @@
<ul class="dropdown-menu cards-filter-element">
<li class="cards-filter-element">
<a href="#" class="noFilterBonus active cards-filter-element" data-id="reset">{{_
"set-list.everything"}}</a>
"filter-pool.bonus.all"}}</a>
</li>
{{#if gotBonusCardsets}}
<li class="cards-filter-element"><a href="#" class="filterActiveBonus cards-filter-element">
{{_ "set-list.activeLearnphase"}}
{{_ "filter-pool.bonus.bonus"}}
{{#if resultsFilterBonus 0}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotFinishedBonusCardsets}}
<li class="cards-filter-element"><a href="#" class="filterFinishedBonus cards-filter-element">
{{_ "set-list.inactiveLearnphase"}}
{{#if gotTranscriptBonusCardsets}}
<li class="cards-filter-element"><a href="#" class="filterTranscriptBonus cards-filter-element">
{{_ "filter-pool.bonus.transcriptBonus"}}
{{#if resultsFilterBonus 1}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
......
......@@ -11,27 +11,28 @@ import {Cardsets} from "../../../../api/cardsets";
Template.filterItemFilterBonus.helpers({
hasBonusFilter: function () {
return Filter.getFilterQuery().learningActive !== undefined;
let query = Filter.getFilterQuery();
return (query.learningActive !== undefined) || (query['transcriptBonus.enabled'] === true);
},
resultsFilterBonus: function (bonusType) {
let query = Filter.getFilterQuery();
switch (bonusType) {
case 0:
return (query.learningActive !== undefined && query.learningEnd.$gt !== undefined);
return (query.learningActive !== undefined);
case 1:
return (query.learningActive !== undefined && query.learningEnd.$lte !== undefined);
return (query['transcriptBonus.enabled'] === true);
}
},
gotBonusCardsets: function () {
let query = Filter.getFilterQuery();
query.learningActive = true;
query.learningEnd = {$gt: new Date()};
delete query['transcriptBonus.enabled'];
return Cardsets.findOne(query);
},
gotFinishedBonusCardsets: function () {
gotTranscriptBonusCardsets: function () {
let query = Filter.getFilterQuery();
query.learningActive = true;
query.learningEnd = {$lte: new Date()};
delete query.learningActive;
query['transcriptBonus.enabled'] = true;
return Cardsets.findOne(query);
}
});
......@@ -43,7 +44,7 @@ Template.filterItemFilterBonus.events({
'click .filterActiveBonus': function () {
Filter.setActiveFilter(undefined, "bonusActive");
},
'click .filterFinishedBonus': function () {
Filter.setActiveFilter(undefined, "bonusFinished");
'click .filterTranscriptBonus': function () {
Filter.setActiveFilter(true, "transcriptBonus");
}
});
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