Commit 67741e50 authored by Curtis Adam's avatar Curtis Adam

Merge branch...

Merge branch '283-link-all-badges-on-the-filter-result-pages-with-the-filter-criterion-of-the-badge' into 'staging'

Resolve "Link all badges on the filter result pages with the filter criterion of the badge."

Closes #283

See merge request arsnova/cards!642
parents 75d4ee35 1e6e8947
...@@ -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;
...@@ -136,6 +132,10 @@ export let Filter = class Filter { ...@@ -136,6 +132,10 @@ export let Filter = class Filter {
case "_id": case "_id":
filter._id = content; filter._id = content;
break; break;
case "transcriptBonus":
delete filter.learningActive;
filter['transcriptBonus.enabled'] = true;
break;
} }
} }
switch (FilterNavigation.getRouteId()) { switch (FilterNavigation.getRouteId()) {
...@@ -280,11 +280,9 @@ export let Filter = class Filter { ...@@ -280,11 +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()}; if (FilterNavigation.gotBonusFilter(FilterNavigation.getRouteId()) && activeFilter['transcriptBonus.enabled'] !== undefined) {
} else { query['transcriptBonus.enabled'] = activeFilter['transcriptBonus.enabled'];
query.learningEnd = {$gt: new Date()};
}
} }
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,8 +3,19 @@ import {Session} from "meteor/session"; ...@@ -3,8 +3,19 @@ import {Session} from "meteor/session";
import {Filter} from "./filter"; import {Filter} from "./filter";
import * as config from "../config/filter.js"; import * as config from "../config/filter.js";
import {NavigatorCheck} from "./navigatorCheck"; import {NavigatorCheck} from "./navigatorCheck";
import {MainNavigation} from "./mainNavigation";
export let FilterNavigation = class FilterNavigation { export let FilterNavigation = class FilterNavigation {
static showDropdown (forceOn = true) {
if ($('.navbar-cards-filter-dropdown').hasClass('active') && !forceOn) {
$('.navbar-cards-filter-dropdown').removeClass('active');
} else {
$('.navbar-cards-filter-dropdown').addClass('active');
FilterNavigation.setMaxDropdownHeight();
MainNavigation.closeCollapse();
}
}
static gotAuthorFilter (filterType) { static gotAuthorFilter (filterType) {
return config.filtersWithAuthor.includes(filterType); return config.filtersWithAuthor.includes(filterType);
} }
......
...@@ -385,14 +385,14 @@ Template.registerHelper("getKindText", function (kind, displayType = 0) { ...@@ -385,14 +385,14 @@ Template.registerHelper("getKindText", function (kind, displayType = 0) {
}); });
Template.registerHelper("getCardTypeLabel", function (cardType) { Template.registerHelper("getCardTypeLabel", function (cardType) {
return '<span class="label label-card-type" data-id="difficulty" title="' + TAPi18n.__('card.cardType' + cardType + '.longName') + '">' + TAPi18n.__('card.cardType' + cardType + '.name') + '</span>'; return '<span class="label label-card-type" data-id="' + cardType + '" title="' + TAPi18n.__('card.cardType' + cardType + '.longName') + '">' + TAPi18n.__('card.cardType' + cardType + '.name') + '</span>';
}); });
Template.registerHelper("getDifficultyLabel", function (cardType, difficulty) { Template.registerHelper("getDifficultyLabel", function (cardType, difficulty) {
if (!CardType.gotDifficultyLevel(cardType)) { if (!CardType.gotDifficultyLevel(cardType)) {
return; return;
} }
return '<span class="label label-difficulty' + difficulty + '" data-id="difficulty" title="' + TAPi18n.__('difficulty' + difficulty) + '">' + TAPi18n.__('difficulty' + difficulty) + '</span>'; return '<span class="label label-difficulty label-difficulty' + difficulty + '" data-id="' + difficulty + '" title="' + TAPi18n.__('difficulty' + difficulty) + '">' + TAPi18n.__('difficulty' + difficulty) + '</span>';
}); });
Template.registerHelper("getShuffleLabel", function (shuffled = false) { Template.registerHelper("getShuffleLabel", function (shuffled = false) {
...@@ -407,25 +407,25 @@ Template.registerHelper("isCardsetAndFixedSidebar", function () { ...@@ -407,25 +407,25 @@ Template.registerHelper("isCardsetAndFixedSidebar", function () {
Template.registerHelper("getBonusLabel", function (shuffled = false) { Template.registerHelper("getBonusLabel", function (shuffled = false) {
if (shuffled) { if (shuffled) {
return '<span class="label label-bonus" data-id="bonus" title="' + TAPi18n.__('cardset.bonus.long') + '">' + TAPi18n.__('cardset.bonus.short') + '</span>'; return '<span class="label label-bonus" title="' + TAPi18n.__('cardset.bonus.long') + '">' + TAPi18n.__('cardset.bonus.short') + '</span>';
} }
}); });
Template.registerHelper("getLecturerAuthorizedLabel", function (cardset) { Template.registerHelper("getLecturerAuthorizedLabel", function (cardset) {
if (cardset.lecturerAuthorized !== undefined && cardset.lecturerAuthorized === true) { if (cardset.lecturerAuthorized !== undefined && cardset.lecturerAuthorized === true) {
return '<span class="label label-lecturer-authorized" data-id="lecturer-authorized" title="' + TAPi18n.__('label.lecturerAuthorized.long') + '">' + Icons.labels("lecturerAuthorized") + '</span>'; return '<span class="label label-lecturer-authorized" title="' + TAPi18n.__('label.lecturerAuthorized.long') + '">' + Icons.labels("lecturerAuthorized") + '</span>';
} }
}); });
Template.registerHelper("getWordcloudLabel", function (cardset) { Template.registerHelper("getWordcloudLabel", function (cardset) {
if (cardset.wordcloud !== undefined && cardset.wordcloud === true) { if (cardset.wordcloud !== undefined && cardset.wordcloud === true) {
return '<span class="label label-wordcloud" data-id="wordcloud" title="' + TAPi18n.__('serverStatistics.modal.table.header.wordcloud.default') + '">' + Icons.labels("wordcloud") + '</span>'; return '<span class="label label-wordcloud" title="' + TAPi18n.__('serverStatistics.modal.table.header.wordcloud.default') + '">' + Icons.labels("wordcloud") + '</span>';
} }
}); });
Template.registerHelper("getTranscriptBonusLabel", function (cardset) { Template.registerHelper("getTranscriptBonusLabel", function (cardset) {
if ((cardset.transcriptBonus !== undefined && cardset.transcriptBonus.enabled) || Route.isMyBonusTranscripts() || Route.isTranscriptBonus() || Route.isPresentationTranscriptBonus() || Route.isPresentationTranscriptBonusCardset()) { if ((cardset.transcriptBonus !== undefined && cardset.transcriptBonus.enabled) || Route.isMyBonusTranscripts() || Route.isTranscriptBonus() || Route.isPresentationTranscriptBonus() || Route.isPresentationTranscriptBonusCardset()) {
return '<span class="label label-transcript-bonus" data-id="bonus-transcript" title="' + TAPi18n.__('cardset.transcriptBonus.long') + '">' + TAPi18n.__('cardset.transcriptBonus.short') + '</span>'; return '<span class="label label-transcript-bonus" title="' + TAPi18n.__('cardset.transcriptBonus.long') + '">' + TAPi18n.__('cardset.transcriptBonus.short') + '</span>';
} }
}); });
...@@ -466,30 +466,30 @@ Template.registerHelper("getKind", function (kind, displayType = 0) { ...@@ -466,30 +466,30 @@ Template.registerHelper("getKind", function (kind, displayType = 0) {
if (displayType === 0) { if (displayType === 0) {
switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) { switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) {
case "free": case "free":
return '<span class="label label-free" data-id="free"title="' + TAPi18n.__('access-level.free.long') + '">' + TAPi18n.__('access-level.free.short') + '</span>'; return '<span class="label label-kind label-free" data-id="free" title="' + TAPi18n.__('access-level.free.long') + '">' + TAPi18n.__('access-level.free.short') + '</span>';
case "edu": case "edu":
return '<span class="label label-edu" data-id="edu"title="' + TAPi18n.__('access-level.edu.long') + '">' + TAPi18n.__('access-level.edu.short') + '</span>'; return '<span class="label label-kind label-edu" data-id="edu" title="' + TAPi18n.__('access-level.edu.long') + '">' + TAPi18n.__('access-level.edu.short') + '</span>';
case "pro": case "pro":
return '<span class="label label-pro" data-id="pro"title="' + TAPi18n.__('access-level.pro.long') + '">' + TAPi18n.__('access-level.pro.short') + '</span>'; return '<span class="label label-kind label-pro" data-id="pro" title="' + TAPi18n.__('access-level.pro.long') + '">' + TAPi18n.__('access-level.pro.short') + '</span>';
case "personal": case "personal":
return '<span class="label label-private" data-id="personal"title="' + TAPi18n.__('access-level.private.long') + '">' + TAPi18n.__('access-level.private.short') + '</span>'; return '<span class="label label-kind label-private" data-id="personal" title="' + TAPi18n.__('access-level.private.long') + '">' + TAPi18n.__('access-level.private.short') + '</span>';
case "demo": case "demo":
return '<span class="label label-demo" data-id="demo"title="' + TAPi18n.__('access-level.demo.long') + '">' + TAPi18n.__('access-level.demo.short') + '</span>'; return '<span class="label label-kind label-demo" data-id="demo" title="' + TAPi18n.__('access-level.demo.long') + '">' + TAPi18n.__('access-level.demo.short') + '</span>';
default: default:
return '<span class="label label-default">Undefined!</span>'; return '<span class="label label-default">Undefined!</span>';
} }
} else { } else {
switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) { switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) {
case "free": case "free":
return '<span class="label label-free" data-id="free">' + TAPi18n.__('access-level.free.long') + '</span>'; return '<span class="label label-kind label-free" data-id="free">' + TAPi18n.__('access-level.free.long') + '</span>';
case "edu": case "edu":
return '<span class="label label-edu" data-id="edu">' + TAPi18n.__('access-level.edu.long') + '</span>'; return '<span class="label label-kind label-edu" data-id="edu">' + TAPi18n.__('access-level.edu.long') + '</span>';
case "pro": case "pro":
return '<span class="label label-pro" data-id="pro">' + TAPi18n.__('access-level.pro.long') + '</span>'; return '<span class="label label-kind label-pro" data-id="pro">' + TAPi18n.__('access-level.pro.long') + '</span>';
case "personal": case "personal":
return '<span class="label label-private" data-id="personal">' + TAPi18n.__('access-level.private.long') + '</span>'; return '<span class="label label-kind label-private" data-id="personal">' + TAPi18n.__('access-level.private.long') + '</span>';
case "demo": case "demo":
return '<span class="label label-demo" data-id="demo">' + TAPi18n.__('access-level.demo.long') + '</span>'; return '<span class="label label-kind label-demo" data-id="demo">' + TAPi18n.__('access-level.demo.long') + '</span>';
default: default:
return '<span class="label label-default">Undefined!</span>'; return '<span class="label label-default">Undefined!</span>';
} }
......
...@@ -52,6 +52,42 @@ import "./index.html"; ...@@ -52,6 +52,42 @@ import "./index.html";
Session.setDefault('cardsetId', undefined); Session.setDefault('cardsetId', undefined);
Session.set('moduleActive', true); Session.set('moduleActive', true);
/*
* ############################################################################
* filterIndex
* ############################################################################
*/
Template.filterIndex.events({
'click .label-wordcloud': function () {
Filter.setActiveFilter(true, "wordcloud");
FilterNavigation.showDropdown();
},
'click .label-lecturer-authorized': function () {
Filter.setActiveFilter(true, "lecturerAuthorized");
FilterNavigation.showDropdown();
},
'click .label-kind': function (event) {
Filter.setActiveFilter([$(event.target).data('id')], "kind");
FilterNavigation.showDropdown();
},
'click .label-card-type': function (event) {
Filter.setActiveFilter(Number($(event.target).data('id')), "cardType");
FilterNavigation.showDropdown();
},
'click .label-difficulty': function (event) {
Filter.setActiveFilter(Number($(event.target).data('id')), "difficulty");
FilterNavigation.showDropdown();
},
'click .label-bonus': function () {
Filter.setActiveFilter(true, "bonusActive");
FilterNavigation.showDropdown();
},
'click .label-transcript-bonus': function () {
Filter.setActiveFilter(true, "transcriptBonus");
FilterNavigation.showDropdown();
}
});
/* /*
* ############################################################################ * ############################################################################
......
...@@ -7,6 +7,10 @@ hr { ...@@ -7,6 +7,10 @@ hr {
overflow: auto; overflow: auto;
} }
.resultItemHeaderBottomAreaLabels .label-group > .label:not(:first-child) {
cursor: pointer;
}
.cardsetHeaderTop { .cardsetHeaderTop {
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
......
...@@ -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");
} }
}); });
...@@ -152,7 +152,7 @@ Template.main.onRendered(function () { ...@@ -152,7 +152,7 @@ Template.main.onRendered(function () {
MainNavigation.clearSearch(); MainNavigation.clearSearch();
$('.navbar-cards-search-dropdown').removeClass('active'); $('.navbar-cards-search-dropdown').removeClass('active');
} }
if (!$(event.target).is('.cards-filter-element')) { if (!$(event.target).is('.cards-filter-element') && !$(event.target).parents('.resultItemHeaderBottomAreaLabels').length) {
MainNavigation.clearSearch(); MainNavigation.clearSearch();
$('.navbar-cards-filter-dropdown').removeClass('active'); $('.navbar-cards-filter-dropdown').removeClass('active');
} }
......
import {MainNavigation} from "../../../../../api/mainNavigation";
import {FilterNavigation} from "../../../../../api/filterNavigation"; import {FilterNavigation} from "../../../../../api/filterNavigation";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import "./filter.html"; import "./filter.html";
...@@ -12,13 +11,7 @@ import "./filter.html"; ...@@ -12,13 +11,7 @@ import "./filter.html";
let filterResizeSensor; let filterResizeSensor;
Template.mainNavigationTopItemFilterDropdown.events({ Template.mainNavigationTopItemFilterDropdown.events({
'click .toggle-filter-dropdown': function () { 'click .toggle-filter-dropdown': function () {
if ($('.navbar-cards-filter-dropdown').hasClass('active')) { FilterNavigation.showDropdown(false);
$('.navbar-cards-filter-dropdown').removeClass('active');
} else {
$('.navbar-cards-filter-dropdown').addClass('active');
FilterNavigation.setMaxDropdownHeight();
MainNavigation.closeCollapse();
}
} }
}); });
......
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