Commit 30fb8635 authored by Curtis Adam's avatar Curtis Adam

Refactor cardset templates

parent cd766c9f
......@@ -2615,22 +2615,20 @@ $themes: (
color: $item_author_text !important;
}
.resultItemHeaderRightArea {
.resultItemHeaderBottomArea {
background-color: $item_background !important;
i {
color: $item_icon;
}
i:hover, .resultItemHeaderRightArea i:focus {
color: $item_icon_hover !important;
}
}
.resultItemHeaderLeftArea a {
.resultItemHeaderTopArea a {
color: $hyperlink !important;
}
.resultItemHeaderRightArea i {
color: $item_icon;
}
.resultItemHeaderRightArea i:hover, .resultItemHeaderRightArea i:focus {
color: $item_icon_hover !important;
}
.resultTableContent a {
color: $item_content_link !important;
}
......
......@@ -46,6 +46,11 @@ Template.registerHelper('isCardset', function () {
return Route.isCardset();
});
Template.registerHelper('isWorkloadRoute', function () {
return Route.isWorkload();
});
Template.registerHelper('gotTranscriptsEnabled', function () {
return ServerStyle.gotTranscriptsEnabled();
});
......@@ -704,7 +709,7 @@ Template.registerHelper("getDate", function () {
if (Router.current().route.getName() === "welcome") {
date = Session.get('wordcloudItem')[10];
} else {
date = this.date;
date = this.dateCreated;
}
return moment(date).locale(Session.get('activeLanguage')).format('LL');
});
......@@ -742,7 +747,7 @@ Template.registerHelper("getDateUpdated", function () {
// Returns the locale date with time
Template.registerHelper("getTimestamp", function () {
return moment(this.date).locale(Session.get('activeLanguage')).format('LLLL');
return moment(this.dateCreated).locale(Session.get('activeLanguage')).format('LLLL');
});
// Returns all courses
......@@ -1034,6 +1039,9 @@ const markdeepHelper = new MeteorMathJax.Helper({
});
Template.registerHelper("gotTranscriptBonus", function (cardset_id) {
if (Route.isTranscriptBonus() || Route.isMyBonusTranscripts() || Route.isTranscriptBonus()) {
return true;
}
let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, cardGroups: 1, shuffled: 1, cardType: 1}});
if (cardset !== undefined) {
if (cardset.shuffled) {
......@@ -1051,6 +1059,9 @@ Template.registerHelper("gotTranscriptBonus", function (cardset_id) {
});
Template.registerHelper("gotTranscriptBonusAndIsNotShuffled", function (cardset_id) {
if (Route.isTranscript() || Route.isTranscriptBonus()) {
return true;
}
let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, cardGroups: 1, shuffled: 1, cardType: 1}});
if (cardset !== undefined && !cardset.shuffled) {
return CardType.gotTranscriptBonus(cardset.cardType);
......
<template name="cardsetInfoBoxItemActiveLearners">
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.workload.normal.count"}}:</td>
<td>{{getActiveLearnerCount this}}</td>
</tr>
{{#unless isTranscriptRoute}}
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.workload.normal.count"}}:</td>
<td>{{getActiveLearnerCount this}}</td>
</tr>
{{/unless}}
{{/unless}}
</template>
<template name="cardsetInfoBoxItemCardCount">
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.quantity"}}:</td>
<td class="cardsetCardCount" data-count="{{this.quantity}}">{{this.quantity}}</td>
</tr>
{{#unless isTranscriptRoute}}
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.quantity"}}:</td>
<td class="cardsetCardCount" data-count="{{this.quantity}}">{{this.quantity}}</td>
</tr>
{{/unless}}
{{/unless}}
</template>
<template name="cardsetInfoBoxItemDifficulty">
{{#unless isShuffledCardset this._id}}
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{#if gotNotesForDifficultyLevel}}{{_ "difficultyNotes"}}{{else}}{{_
"difficulty"}}{{/if}}:
</td>
<td>
{{getDifficultyName}}
</td>
</tr>
{{#unless isTranscriptRoute}}
{{#unless isShuffledCardset this._id}}
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{#if gotNotesForDifficultyLevel}}{{_ "difficultyNotes"}}{{else}}{{_
"difficulty"}}{{/if}}:
</td>
<td>
{{getDifficultyName}}
</td>
</tr>
{{/unless}}
{{/unless}}
{{/unless}}
</template>
<template name="cardsetInfoBoxItemKind">
<tr>
<td>{{_ "set-list.category"}}:</td>
<td>
{{{getKindText this.kind 1}}}
</td>
</tr>
{{#unless isTranscriptRoute}}
<tr>
<td>{{_ "set-list.category"}}:</td>
<td>
{{{getKindText this.kind 1}}}
</td>
</tr>
{{/unless}}
</template>
<template name="cardsetInfoBoxItemLicense">
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.license"}}:</td>
<td>
{{#unless isShuffledCardset _id}}
{{#if isActiveRoute "home"}}
<span class="info_license showLicense">{{getLicense this._id this.license}}</span>
{{#unless isTranscriptRoute}}
{{#unless gotTranscriptBonusAndIsNotShuffled this._id}}
<tr>
<td>{{_ "cardset.info.license"}}:</td>
<td>
{{#unless isShuffledCardset _id}}
{{#if isActiveRoute "home"}}
<span class="info_license showLicense">{{getLicense this._id this.license}}</span>
{{else}}
<a class="info_license showLicense" href="#" data-id="{{this._id}}" data-toggle="modal"
data-target="#showLicenseModal">{{getLicense this._id this.license}}</a>
{{/if}}
{{else}}
<a class="info_license showLicense" href="#" data-id="{{this._id}}" data-toggle="modal"
data-target="#showLicenseModal">{{getLicense this._id this.license}}</a>
{{/if}}
{{else}}
{{_ "cardset.info.shuffleLicense"}}
{{/unless}}
</td>
</tr>
{{_ "cardset.info.shuffleLicense"}}
{{/unless}}
</td>
</tr>
{{/unless}}
{{/unless}}
</template>
......@@ -15,6 +15,6 @@ Template.cardsetInfoBoxItemPurchased.helpers({
return Paid.findOne({cardset_id: this._id}) !== undefined;
},
getDateOfPurchase: function () {
return moment(Paid.findOne({cardset_id: this._id}).date).locale(Session.get('activeLanguage')).format('LL');
return moment(Paid.findOne({cardset_id: this._id}).dateCreated).locale(Session.get('activeLanguage')).format('LL');
}
});
......@@ -25,14 +25,14 @@ Template.cardsetInfoBoxItemTranscriptLectureDates.helpers({
}
},
isNewMonth: function (transcriptBonus) {
let currentMonth = moment(transcriptBonus.date).month();
let currentMonth = moment(transcriptBonus.dateCreated).month();
if (currentMonth !== lastMonth) {
lastMonth = currentMonth;
return true;
}
},
isNewYear: function (transcriptBonus) {
let currentYear = moment(transcriptBonus.date).year();
let currentYear = moment(transcriptBonus.dateCreated).year();
if (currentYear !== lastYear) {
lastYear = currentYear;
return true;
......@@ -48,7 +48,7 @@ Template.cardsetInfoBoxItemTranscriptLectureDates.helpers({
//returnMode 1 = Return tooltip
getStatus: function (transcriptBonus, returnMode = 0) {
let current = moment();
let lectureEndDate = TranscriptBonusList.addLectureEndTime(transcriptBonus, transcriptBonus.date);
let lectureEndDate = TranscriptBonusList.addLectureEndTime(transcriptBonus, transcriptBonus.dateCreated);
if (current > lectureEndDate && !TranscriptBonusList.isDeadlineExpired(transcriptBonus)) {
if (returnMode) {
return TAPi18n.__('transcriptForm.info.tooltip.lecture.active');
......
......@@ -11,8 +11,12 @@
{{getTranscriptSubmissions this}}
</span>
{{/if}}
{{{getKind this.kind 0}}}
{{{getShuffleLabel this.shuffled}}}
{{#unless isTranscriptRoute}}
{{#unless isBonusTranscriptsRoute}}
{{{getKind this.kind 0}}}
{{{getShuffleLabel this.shuffled}}}
{{/unless}}
{{/unless}}
{{#unless this.shuffled}}
{{{getCardTypeLabel this.cardType}}}
{{{getDifficultyLabel this.cardType this.difficulty}}}
......
<template name="filterIndex">
{{> showLicense}}
{{> filterItemSelectCardsetToLearnCallout}}
{{#if gotBackendAccess}}
{{> cardsetFormAdmin}}
{{/if}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
<div id="set-list-region">
{{#if isActiveRoute regex='alldecks|create|allRepetitorien|personalRepetitorien'}}
{{> cardsetFormAdmin}}
{{/if}}
{{#if isActiveRoute regex='alldecks|create'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexCreate}}
{{/if}}
{{#if isActiveRoute regex='repetitorium|allRepetitorien|personalRepetitorien'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexRepetitorium}}
{{/if}}
......@@ -24,12 +22,10 @@
{{/if}}
{{#if isActiveRoute 'shuffle'}}
{{> cardsetForm}}
{{> filterIndexShuffle}}
{{/if}}
{{#if isActiveRoute 'pool'}}
{{> cardsetForm}}
{{> filterIndexPool}}
{{/if}}
......
......@@ -21,6 +21,28 @@ import "./item/selectCardsetButton.js";
import "./item/selectRepetitoriumButton.js";
import "./item/shuffleRepetitoriumCallout.js";
import "./item/selectCardsetToLearnCallout.js";
import "./item/bottom/bonusStats.js";
import "./item/bottom/collapse.js";
import "./item/bottom/deadline.js";
import "./item/bottom/delete.js";
import "./item/bottom/deleteTranscript.js";
import "./item/bottom/edit.js";
import "./item/bottom/editTranscript.js";
import "./item/bottom/export.js";
import "./item/bottom/leaveWorkload.js";
import "./item/bottom/shuffle.js";
import "./item/bottom/workloadProgress.js";
import "./item/collapse/collapse.js";
import "./item/titleRow/author.js";
import "./item/titleRow/dateCreated.js";
import "./item/titleRow/dateModified.js";
import "./item/titleRow/topic.js";
import "./item/titleRow/workload.js";
import "./item/top/author.js";
import "./item/top/dateCreated.js";
import "./item/top/dateModified.js";
import "./item/top/topic.js";
import "./item/top/workload.js";
import "../modal/deleteWorkload.js";
import "../modal/deleteCardset.js";
import "../modal/deleteTranscript.js";
......
<template name="filterIndexItemBottomBonusStats">
{{#if this.learningActive}}
{{#if isCardsetOwner this._id}}
<a class="resultNavigationElement bonusLeitnerProgress" data-id="{{this._id}}"
title="{{_
"admin.myProgress"}}">
<i class="glyphicon glyphicon glyphicon-stats" data-id="{{this._id}}"></i>
</a>
{{/if}}
{{/if}}
{{#if gotTranscriptBonus this._id}}
{{#if isCardsetOwner this._id}}
<a class="resultNavigationElement bonusTranscriptProgress" data-id="{{this._id}}"
title="{{_
"transcriptForm.bonus.form.button.list"}}">
<i class="fa fa-clipboard" data-id="{{this._id}}"></i>
</a>
{{/if}}
{{/if}}
</template>
import "./bonusStats.html";
import {Template} from "meteor/templating";
/*
* ############################################################################
* filterIndexItemBottomBonusStats
* ############################################################################
*/
Template.filterIndexItemBottomBonusStats.events({
'click .bonusLeitnerProgress': function (event) {
Router.go('cardsetstats', {
_id: $(event.target).data('id')
});
},
'click .bonusTranscriptProgress': function (event) {
Router.go('transcriptBonus', {
_id: $(event.target).data('id')
});
}
});
<template name="filterIndexItemBottomCollapse">
<a class="collapseCardsetInfoButton pull-right" data-id="#collapseCardsetInfo{{this.index}}">
<i class="glyphicon glyphicon-collapse-down pull-right collapseCardsetInfoIcon"
data-id="#collapseCardsetInfo{{this.index}}"></i>
</a>
</template>
import "./collapse.html";
import {Template} from "meteor/templating";
/*
* ############################################################################
* filterIndexItemBottomCollapse
* ############################################################################
*/
Template.filterIndexItemBottomCollapse.events({
'click .collapseCardsetInfoButton': function (event) {
if ($(event.target).hasClass('glyphicon-collapse-up')) {
$(event.target).addClass('glyphicon-collapse-down').removeClass('glyphicon-collapse-up');
$($(event.target).data('id')).hide('slide', {direction: "up"}, 'slow');
} else {
$("[id^=collapseCardsetInfo]").hide('slide', {direction: "up"}, 'fast');
$(".collapseCardsetInfoIcon").addClass('glyphicon-collapse-down').removeClass('glyphicon-collapse-up');
$(event.target).addClass('glyphicon-collapse-up').removeClass('glyphicon-collapse-down');
$($(event.target).data('id')).show('slide', {direction: "up"}, 'slow', function () {
$('body, html').animate({scrollTop: ($(event.target).offset().top - ($('.resultItemHeaderWrapper').height() + $('.thm-header').height() - 25))}, 'slow');
});
}
}
});
<template name="filterIndexItemBottomDeadline">
{{#if isBonusTranscriptsRoute}}
<span class="hidden-xs hidden-sm label transcript-info-text">
{{getBonusLectureDeadline}}
</span>
{{/if}}
</template>
import "./deadline.html";
import {Template} from "meteor/templating";
import {TranscriptBonus, TranscriptBonusList} from "../../../../../api/transcriptBonus";
/*
* ############################################################################
* filterIndexItemBottomDeadline
* ############################################################################
*/
Template.filterIndexItemBottomDeadline.helpers({
getBonusLectureDeadline: function () {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.dateCreated);
}
}
});
<template name="filterIndexItemBottomDelete">
{{#if isCardsetOwner this._id}}
<a class="resultNavigationElement deleteCardset hidden-xs" {{disableIfOffline}}
title='{{_ "courseIteration.confirm-form-delete.title"}}' data-toggle="modal"
data-target="#confirmDeleteCardsetModal"
data-id="{{this._id}}">
<i class="result fa fa-trash" data-id="{{this._id}}"></i>
</a>
{{/if}}
</template>
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import "./delete.html";
/*
* ############################################################################
* filterIndexItemBottomDelete
* ############################################################################
*/
Template.filterIndexItemBottomDelete.events({
'click .deleteCourseIteration': function (event) {
Session.set('courseIterationId', $(event.target).data('id'));
},
'click .deleteCardset': function (event) {
Session.set('cardsetId', $(event.target).data('id'));
}
});
<template name="filterIndexItemBottomDeleteTranscript">
{{#unless isCardsetTranscriptBonusRoute}}
<a class="resultNavigationElement deleteCard" {{disableIfOffline}}
title='{{_ "transcriptForm.index.tooltip.delete"}}' data-toggle="modal" data-target="#deleteTranscriptModal" data-id="{{this._id}}">
<i class="result fa fa-trash" data-id="{{this._id}}"></i>
</a>
{{/unless}}
</template>
import "./deleteTranscript.html";
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
/*
* ############################################################################
* filterIndexItemBottomDeleteTranscript
* ############################################################################
*/
Template.filterIndexItemBottomDeleteTranscript.events({
'click .deleteCard': function (event) {
Session.set('activeCard', $(event.target).data('id'));
}
});
<template name="filterIndexItemBottomEdit">
{{#if isCardsetOwner this._id}}
<a class="resultNavigationElement editCardset hidden-xs" {{disableIfOffline}}
title='{{#if isRepetitorienFilterIndex}}{{_
"cardset.tooltip.editRepetitorium"}}{{else}}{{_
"cardset.tooltip.editCardset"}}{{/if}}' data-id="{{this._id}}"
data-toggle="modal"
data-target="#setCardsetFormModal">
<i class="glyphicon glyphicon-edit" data-id="{{this._id}}"></i>
</a>
{{#unless isTranscriptRoute}}
{{#if gotBackendAccess}}
<a class="resultNavigationElement editAdminCardset hidden-xs"
title='{{_ "cardset.tooltip.editAdminSettings"}}' data-id="{{this._id}}"
data-toggle="modal"
data-target="#setCardsetFormAdminModal">
<i class="fa fa-cog fa-spin editAdminCardset" data-id="{{this._id}}"></i>
</a>
{{/if}}
{{#if isRepetitorienFilterIndex}}
<a class="resultNavigationElement editShuffle"
title='{{_ "set-list.shuffleCardsets"}}' data-id="{{this._id}}">
<i class="glyphicon glyphicon-plus editShuffle" data-id="{{this._id}}"></i>
</a>
{{/if}}
{{/unless}}
{{/if}}
</template>
import "./edit.html";
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import {Cardsets} from "../../../../../api/cardsets";
/*
* ############################################################################
* filterIndexItemBottomEdit
* ############################################################################
*/
Template.filterIndexItemBottomEdit.events({
'click .editShuffle': function (event) {
event.preventDefault();
Router.go('editshuffle', {
_id: $(event.target).data('id')
});
},
'click .editCardset, click .editAdminCardset': function (event) {
Session.set('isNewCardset', false);
Session.set('activeCardset', Cardsets.findOne($(event.target).data('id')));
Session.set('previousCardsetData', Cardsets.findOne($(event.target).data('id')));
}
});
<template name="filterIndexItemBottomEditTranscript">
{{#unless isCardsetTranscriptBonusRoute}}
{{#unless isBonusTranscriptsRouteAndDeadlineExpired}}
<a class="resultNavigationElement editCard hidden-xs" {{disableIfOffline}}
title='{{_ "transcriptForm.index.tooltip.edit"}}' data-id="{{this._id}}">
<i class="glyphicon glyphicon-edit" data-id="{{this._id}}"></i>
</a>
{{/unless}}
{{/unless}}
</template>
import "./editTranscript.html";
import {Template} from "meteor/templating";
import {Route} from "../../../../../api/route";
import {TranscriptBonus, TranscriptBonusList} from "../../../../../api/transcriptBonus";
/*
* ############################################################################
* filterIndexItemBottomEditTranscript
* ############################################################################
*/
Template.filterIndexItemBottomEditTranscript.helpers({
isBonusTranscriptsRouteAndDeadlineExpired: function () {
if (Route.isMyBonusTranscripts() || Route.isTranscriptBonus()) {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.isDeadlineExpired(bonusTranscript, true);
}
}
}
});
Template.filterIndexItemBottomEditTranscript.events({
'click .editCard': function (event) {
Router.go('editTranscript', {card_id: $(event.target).data('id')});
}
});
<template name="filterIndexItemBottomExport">
{{#unless isIOS}}
{{#unless this.shuffled}}
{{#if isCardsetOwner this._id}}
<a class="resultNavigationElement exportCardset" data-id="{{this._id}}"
data-name="{{this.name}}" title='{{_ "admin.cardset.export"}}'><i
class="result fa fa-cloud-download hidden-xs" data-id="{{this._id}}"
data-name="{{this.name}}"></i></a>
{{/if}}
{{/unless}}
{{/unless}}
</template>
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {BertAlertVisuals} from "../../../../../api/bertAlertVisuals";
import "./export.html";
/*
* ############################################################################
* filterIndexItemBottomExport
* ############################################################################
*/
Template.filterIndexItemBottomExport.events({
'click .exportCardset': function (event) {
let name = $(event.target).data('name');
Meteor.call('exportCardset', $(event.target).data('id'), function (error, result) {
if (error) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('export.failure.cardset'), 'danger', 'growl-top-left');
} else {
let exportData = new Blob([result], {
type: "application/json"
});
saveAs(exportData, TAPi18n.__('export.filename.export') + "_" + TAPi18n.__('export.filename.cardset') + "_" + name + moment().format('_YYYY_MM_DD') + ".json");
}
});
}
});
<template name="filterIndexItemBottomLeaveWorkload">
<a class="resultNavigationElement deleteLearned" {{disableIfOffline}}
title='{{_ "confirm-form-learn.title"}}' data-toggle="modal" data-target="#bonusFormModal"
data-id="{{this._id}}">
<i class="glyphicon glyphicon-log-out" data-id="{{this._id}}"></i>
</a>
</template>
<template name="filterIndexItemBottomShuffle">
{{#if inShuffleSelection this._id}}
<a class="btn btn-xs btn-raised btn-danger shuffleButton removeShuffleCardset"
data-id="{{this._id}}">
<span class="flex-content" data-id="{{this._id}}"><i class="fa fa-minus"
data-id="{{this._id}}"></i></span>
</a>
{{else}}
<a class="btn btn-xs btn-raised btn-success shuffleButton addShuffleCardset"
data-id="{{this._id}}">
<span class="flex-content" data-id="{{this._id}}"><i class="fa fa-plus"
data-id="{{this._id}}"></i></span>
</a>
{{/if}}
</template>
import "./shuffle.html";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {Cardsets} from "../../../../../api/cardsets";
/*
* ############################################################################
* filterIndexItemBottomShuffle
* ############################################################################
*/
Template.filterIndexItemBottomShuffle.events({
"click .addShuffleCardset": function (event) {
let array = Session.get("ShuffledCardsets");
let arrayExclude = Session.get("ShuffledCardsetsExclude");
let cardset = Cardsets.findOne({_id: $(event.target).data('id')}, {shuffled: 1, cardGroups: 1});
if (cardset.shuffled) {
for (let i = 0; i < cardset.cardGroups.length; i++) {
if (!array.includes(cardset.cardGroups[i])) {
array.push(cardset.cardGroups[i]);
}
}
arrayExclude.push($(event.target).data('id'));
Session.set("ShuffledCardsetsExclude", arrayExclude);
} else {
array.push($(event.target).data('id'));
}
Session.set("ShuffledCardsets", array);
},
"click .removeShuffleCardset": function (event) {
let array = Session.get("ShuffledCardsets");
let arrayExclude = Session.get("ShuffledCardsetsExclude");
let cardset = Cardsets.findOne({_id: $(event.target).data('id')}, {shuffled: 1, cardGroups: 1});
if (cardset.shuffled) {
array = jQuery.grep(array, function (value) {
for (let i = 0; i < cardset.cardGroups.length; i++) {
if (value === cardset.cardGroups[i]) {
return false;
}
}
return true;
});
arrayExclude = jQuery.grep(arrayExclude, function (value) {
return value !== $(event.target).data('id');
});
Session.set("ShuffledCardsetsExclude", arrayExclude);
} else {
array = jQuery.grep(array, function (value) {