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

Update the Bonus filter

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