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 @@
"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;
......@@ -136,6 +132,10 @@ export let Filter = class Filter {
case "_id":
filter._id = content;
break;
case "transcriptBonus":
delete filter.learningActive;
filter['transcriptBonus.enabled'] = true;
break;
}
}
switch (FilterNavigation.getRouteId()) {
......@@ -280,11 +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.enabled'] !== undefined) {
query['transcriptBonus.enabled'] = activeFilter['transcriptBonus.enabled'];
}
if (FilterNavigation.gotWordCloudFilter(FilterNavigation.getRouteId()) && activeFilter.wordcloud !== undefined) {
query.wordcloud = activeFilter.wordcloud;
......
......@@ -3,8 +3,19 @@ import {Session} from "meteor/session";
import {Filter} from "./filter";
import * as config from "../config/filter.js";
import {NavigatorCheck} from "./navigatorCheck";
import {MainNavigation} from "./mainNavigation";
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) {
return config.filtersWithAuthor.includes(filterType);
}
......
......@@ -385,14 +385,14 @@ Template.registerHelper("getKindText", function (kind, displayType = 0) {
});
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) {
if (!CardType.gotDifficultyLevel(cardType)) {
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) {
......@@ -407,25 +407,25 @@ Template.registerHelper("isCardsetAndFixedSidebar", function () {
Template.registerHelper("getBonusLabel", function (shuffled = false) {
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) {
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) {
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) {
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) {
if (displayType === 0) {
switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) {
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":
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":
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":
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":
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:
return '<span class="label label-default">Undefined!</span>';
}
} else {
switch (DOMPurify.sanitize(kind, DOMPurifyConfig)) {
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":
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":
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":
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":
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:
return '<span class="label label-default">Undefined!</span>';
}
......
......@@ -52,6 +52,42 @@ import "./index.html";
Session.setDefault('cardsetId', undefined);
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 {
overflow: auto;
}
.resultItemHeaderBottomAreaLabels .label-group > .label:not(:first-child) {
cursor: pointer;
}
.cardsetHeaderTop {
padding-top: 10px;
padding-bottom: 10px;
......
......@@ -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");
}
});
......@@ -152,7 +152,7 @@ Template.main.onRendered(function () {
MainNavigation.clearSearch();
$('.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();
$('.navbar-cards-filter-dropdown').removeClass('active');
}
......
import {MainNavigation} from "../../../../../api/mainNavigation";
import {FilterNavigation} from "../../../../../api/filterNavigation";
import {Template} from "meteor/templating";
import "./filter.html";
......@@ -12,13 +11,7 @@ import "./filter.html";
let filterResizeSensor;
Template.mainNavigationTopItemFilterDropdown.events({
'click .toggle-filter-dropdown': function () {
if ($('.navbar-cards-filter-dropdown').hasClass('active')) {
$('.navbar-cards-filter-dropdown').removeClass('active');
} else {
$('.navbar-cards-filter-dropdown').addClass('active');
FilterNavigation.setMaxDropdownHeight();
MainNavigation.closeCollapse();
}
FilterNavigation.showDropdown(false);
}
});
......
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