Commit 4ac68361 authored by Curtis Adam's avatar Curtis Adam

Add a filter option for the lecture date and deadline

parent a704a185
......@@ -1290,6 +1290,10 @@
"notRated": "Nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
},
"transcriptLecture": {
"title": "Vorlesungen",
"all": "Alle"
}
},
"infinite-scroll": {
......
......@@ -1292,6 +1292,10 @@
"notRated": "Nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
},
"transcriptLecture": {
"title": "Vorlesungen",
"all": "Alle"
}
},
"infinite-scroll": {
......
......@@ -147,6 +147,9 @@ export let Filter = class Filter {
delete filter.learningActive;
filter['transcriptBonus.enabled'] = true;
break;
case "transcriptLecture":
filter.transcriptDate = content;
break;
case "rating":
if (content === undefined) {
delete filter.rating;
......@@ -314,7 +317,7 @@ export let Filter = class Filter {
if (!Route.isWorkload() && activeFilter !== undefined && !Route.isTranscript() && !Route.isTranscriptBonus()) {
query.shuffled = activeFilter.shuffled;
}
if (FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId())) {
if (FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId()) || FilterNavigation.gotTranscriptLectureFilter(FilterNavigation.getRouteId())) {
let ratingQuery = {};
if (activeFilter.rating !== undefined) {
ratingQuery.rating = activeFilter.rating;
......@@ -325,12 +328,17 @@ export let Filter = class Filter {
if (activeFilter.cardset_id !== undefined) {
ratingQuery.cardset_id = activeFilter.cardset_id;
}
if (activeFilter.transcriptDate !== undefined) {
ratingQuery.date = new Date(activeFilter.transcriptDate);
}
let cardsWithRating = _.uniq(TranscriptBonus.find(ratingQuery, {
fields: {card_id: 1}
}).fetch().map(function (x) {
return x.card_id;
}), true);
query._id = {$in: cardsWithRating};
if (cardsWithRating.length) {
query._id = {$in: cardsWithRating};
}
}
return query;
}
......
......@@ -48,6 +48,10 @@ export let FilterNavigation = class FilterNavigation {
return config.filtersWithDifficulty.includes(filterType);
}
static gotTranscriptLectureFilter (filterType) {
return config.filtersWithTranscriptLecture.includes(filterType);
}
static gotRatingFilter (filterType) {
return config.filtersWithRating.includes(filterType);
}
......
......@@ -24,6 +24,7 @@ let filtersWithDefaultSortDateCreated = [];
let filtersWithAuthor = [0, 2, 3, 4, 5, 10];
let filtersWithCardType = [0, 1, 3, 4, 5];
let filtersWithDifficulty = [0, 1, 3, 4, 5];
let filtersWithTranscriptLecture = [9, 10];
let filtersWithRating = [9, 10];
let filtersWithTargetAudience = [];
let filtersWithSemester = [];
......@@ -64,5 +65,6 @@ module.exports = {
filtersWithFreeKind,
filtersWithEduKind,
filtersWithProKind,
filtersWithRating
filtersWithRating,
filtersWithTranscriptLecture
};
......@@ -125,6 +125,9 @@ Template.registerHelper('gotKindFilter', function () {
return FilterNavigation.gotKindFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('gotTranscriptLectureFilter', function () {
return FilterNavigation.gotTranscriptLectureFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('gotRatingFilter', function () {
return FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId());
......
<template name="cardsetIndexTranscriptStatisticsItemInfo">
<div class="col-xs-12 col-sm-6 {{#if isCardsetTranscriptBonusRoute}}col-md-4 col-lg-3{{/if}} transcript-bonus-statistics-info">
<div class="col-xs-12 col-sm-6 transcript-bonus-statistics-info">
<table class="table">
<thead>
{{#if isCardsetTranscriptBonusRoute}}
......
......@@ -91,12 +91,21 @@ Template.filterIndex.events({
FilterNavigation.showDropdown();
},
'click .resultItemHeaderAuthor a': function (event) {
Filter.setActiveFilter($(event.target).data('id'), "author");
if (Route.isTranscript() || Route.isTranscriptBonus()) {
Filter.setActiveFilter($(event.target).data('id'), "user_id");
} else {
Filter.setActiveFilter($(event.target).data('id'), "author");
}
FilterNavigation.showDropdown();
},
'click .resultItemHeaderBottomAreaLabels .label-transcript-rating': function (event) {
Filter.setActiveFilter($(event.target).data('rating'), "rating");
FilterNavigation.showDropdown();
},
'click .resultItemHeaderBottomAreaLabels .label-transcript-info': function (event) {
Filter.setActiveFilter($(event.target).data('id'), "transcriptLecture");
Filter.setActiveFilter($(event.target).data('cardset'), "cardset_id");
FilterNavigation.showDropdown();
}
});
......
<template name="filterIndexItemBottomDeadline">
{{#if isBonusTranscriptsRoute}}
<span class="hidden-xs hidden-sm label label-transcript-info">
<span class="hidden-xs hidden-sm label label-transcript-info" data-id="{{getLectureDate}}" data-cardset="{{getCardset}}">
{{getBonusLectureDeadline}}
</span>
{{/if}}
......
......@@ -14,5 +14,17 @@ Template.filterIndexItemBottomDeadline.helpers({
if (bonusTranscript !== undefined) {
return TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.date);
}
},
getLectureDate: function () {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return bonusTranscript.date.getTime();
}
},
getCardset: function () {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return bonusTranscript.cardset_id;
}
}
});
import "./filterRating.html";
import {FilterNavigation} from "../../../../api/filterNavigation";
import {Filter} from "../../../../api/filter";
import {TranscriptBonus} from "../../../../api/transcriptBonus";
......@@ -11,20 +10,22 @@ import {TranscriptBonus} from "../../../../api/transcriptBonus";
Template.filterItemFilterRating.helpers({
hasRatingFilter: function () {
return Filter.getActiveFilter(FilterNavigation.getRouteId()).rating !== undefined;
return Filter.getActiveFilter().rating !== undefined;
},
gotRating: function (rating) {
let query = Filter.getFilterQuery(FilterNavigation.getRouteId());
delete query._id;
let activeFilter = Filter.getActiveFilter();
let query = {};
query.rating = rating;
if (query.owner !== undefined) {
query.user_id = query.owner;
delete query.owner;
if (activeFilter.user_id !== undefined) {
query.user_id = activeFilter.user_id;
}
if (activeFilter.transcriptDate !== undefined) {
query.date = new Date(activeFilter.transcriptDate);
}
return TranscriptBonus.findOne(query);
},
resultsFilterRating: function (rating) {
let activeFilter = Filter.getActiveFilter(FilterNavigation.getRouteId());
let activeFilter = Filter.getActiveFilter();
if (activeFilter.rating !== undefined) {
return rating === activeFilter.rating;
}
......
<template name="filterItemFilterTranscriptLecture">
<li class="dropdown cards-filter-element">
<a href="#" class="dropdown-toggle transcriptLectureBtn cards-filter-element" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false">
{{_ "filter-pool.transcriptLecture.title"}}
{{#if hasTranscriptLectureFilter}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a>
<ul class="dropdown-menu cards-filter-element">
<li class="cards-filter-element">
<a href="#" class="noFilterTranscriptLecture active cards-filter-element" data-id="">{{_ "filter-pool.transcriptLecture.all"}}</a>
</li>
{{#each getTranscriptLectures}}
<li class="cards-filter-element">
<a href="#" class="filterTranscriptLecture cards-filter-element"
data-id="{{this}}"> {{getLectureName this}}
{{#if resultsFilterTranscriptLecture this}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a>
</li>
{{/each}}
</ul>
</li>
</template>
import "./filterTranscriptLecture.html";
import {Template} from "meteor/templating";
import {Filter} from "../../../../api/filter";
import {TranscriptBonus, TranscriptBonusList} from "../../../../api/transcriptBonus";
/*
* ############################################################################
* filterItemFilterTranscriptLecture
* ############################################################################
*/
Template.filterItemFilterTranscriptLecture.helpers({
hasTranscriptLectureFilter: function () {
return Filter.getActiveFilter().transcriptDate !== undefined;
},
getTranscriptLectures: function () {
let activeFilter = Filter.getActiveFilter();
let query = {};
if (activeFilter.user_id !== undefined) {
query.user_id = activeFilter.user_id;
}
if (activeFilter.rating !== undefined) {
query.rating = activeFilter.rating;
}
return _.uniq(TranscriptBonus.find(query, {
fields: {date: 1}, sort: {date: -1}
}).fetch().map(function (x) {
return x.date.getTime();
}), true);
},
getLectureName: function (date) {
let transcriptBonus = {date: new Date(date), lectureEnd: "00:00"};
return TranscriptBonusList.getLectureName(transcriptBonus, false);
},
resultsFilterTranscriptLecture: function (date) {
return Filter.getActiveFilter().transcriptDate === date;
}
});
Template.filterItemFilterTranscriptLecture.events({
'click .noFilterTranscriptLecture': function () {
Filter.setActiveFilter(undefined, "transcriptLecture");
},
'click .filterTranscriptLecture': function (event) {
Filter.setActiveFilter($(event.target).data('id'), "transcriptLecture");
}
});
......@@ -29,6 +29,9 @@
{{#if gotBonusFilter}}
{{> filterItemFilterBonus}}
{{/if}}
{{#if gotTranscriptLectureFilter}}
{{> filterItemFilterTranscriptLecture}}
{{/if}}
{{#if gotRatingFilter}}
{{> filterItemFilterRating}}
{{/if}}
......
......@@ -18,6 +18,7 @@ import './item/filterLecturerAuthorized.js';
import './item/filterRating.js';
import './item/filterWordcloud.js';
import './item/filterKind.js';
import './item/filterTranscriptLecture.js';
/*
* ############################################################################
......
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