Commit b7937d7e authored by Curtis Adam's avatar Curtis Adam Committed by Tom Käsler

Update the cardset navigation for users which are in a bonus

parent b4439da7
...@@ -16,11 +16,15 @@ export let Bonus = class Bonus { ...@@ -16,11 +16,15 @@ export let Bonus = class Bonus {
} }
static canJoinBonus (cardset_id) { static canJoinBonus (cardset_id) {
let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, registrationPeriod: 1, owner: 1}}); let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, registrationPeriod: 1, owner: 1, kind: 1}});
if (Roles.userIsInRole(Meteor.userId(), ['firstLogin', 'blocked']) || cardset.owner === Meteor.userId()) { if (Roles.userIsInRole(Meteor.userId(), ['firstLogin', 'blocked'])) {
return false; return false;
} }
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'editor', 'lecturer', 'university', 'pro'])) { let roles = ['admin', 'editor', 'lecturer', 'university', 'pro'];
if (cardset.kind === "free") {
roles.push('standard');
}
if (Roles.userIsInRole(Meteor.userId(), roles)) {
return !this.isInBonus(cardset._id) && moment(cardset.registrationPeriod).endOf('day') > new Date(); return !this.isInBonus(cardset._id) && moment(cardset.registrationPeriod).endOf('day') > new Date();
} else { } else {
return false; return false;
......
...@@ -32,6 +32,14 @@ Template.registerHelper('getLastAppTitle', function () { ...@@ -32,6 +32,14 @@ Template.registerHelper('getLastAppTitle', function () {
return Meteor.settings.public.welcome.title.last; return Meteor.settings.public.welcome.title.last;
}); });
Template.registerHelper('isInBonus', function () {
return Bonus.isInBonus(Router.current().params._id, Meteor.userId());
});
Template.registerHelper('isInBonusAndNotOwner', function () {
return Bonus.isInBonus(Router.current().params._id) && (!UserPermissions.isOwner(Cardsets.findOne({_id: Router.current().params._id}).owner) && !UserPermissions.isAdmin());
});
Template.registerHelper('extendContext', function (key, value) { Template.registerHelper('extendContext', function (key, value) {
let result = _.clone(this); let result = _.clone(this);
result[key] = value; result[key] = value;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
{{selectedForLearning}} {{selectedForLearning}}
{{/unless}} {{/unless}}
{{#if isActiveRoute regex='cardsetdetailsid|cardsetcard'}} {{#if isActiveRoute regex='cardsetdetailsid|cardsetcard'}}
{{#unless isInBonus}} {{#unless isInBonusAndNotOwner}}
{{#if this.quantity}} {{#if this.quantity}}
<div class="hidden-xs col-xs-12"> <div class="hidden-xs col-xs-12">
{{> cardNavigation}} {{> cardNavigation}}
......
<template name="cardsetNavigationDeleteAllCards"> <template name="cardsetNavigationDeleteAllCards">
{{#unless isInBonus}} {{#unless isShuffledCardset this._id}}
{{#unless isShuffledCardset this._id}} {{#if this.quantity}}
{{#if this.quantity}} {{#if isCardsetOwner _id}}
{{#if isCardsetOwner _id}} <div class="hidden-xs btn-group">
<div class="hidden-xs btn-group"> <button id="delete_cards" class="btn btn-sm btn-raised deleteAllCardsBtn"
<button id="delete_cards" class="btn btn-sm btn-raised deleteAllCardsBtn" data-toggle="modal"
data-toggle="modal" data-target="#deleteCardsModal" {{disableIfOffline}}>
data-target="#deleteCardsModal" {{disableIfOffline}}> <i class="fa fa-trash"></i> {{_ "deleteCards"}}
<i class="fa fa-trash"></i> {{_ "deleteCards"}} </button>
</button> </div>
</div>
{{/if}}
{{/if}} {{/if}}
{{/unless}} {{/if}}
{{/unless}} {{/unless}}
</template> </template>
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {Bonus} from "../../../../api/bonus";
import "../modal/deleteAllCards.js"; import "../modal/deleteAllCards.js";
import "./deleteAllCards.html"; import "./deleteAllCards.html";
/*
* ############################################################################
* cardsetNavigationExport
* ############################################################################
*/
Template.cardsetNavigationDeleteAllCards.helpers({
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
}
});
<template name="cardsetNavigationExport"> <template name="cardsetNavigationExport">
{{#unless isInBonus}} {{#unless isShuffledCardset this._id}}
{{#unless isShuffledCardset this._id}} {{#if this.quantity}}
{{#if this.quantity}} {{#if isCardsetOwner _id}}
{{#if isCardsetOwner _id}} <div class="hidden-xs btn-group">
<div class="hidden-xs btn-group"> <button id="exportCardsBtn" class="btn btn-sm btn-raised exportCardsBtn"><i
<button id="exportCardsBtn" class="btn btn-sm btn-raised exportCardsBtn"><i class="fa fa-cloud-download"></i> {{_ "sidebar-nav.exportcard"}}
class="fa fa-cloud-download"></i> {{_ "sidebar-nav.exportcard"}} </button>
</button> </div>
</div>
{{/if}}
{{/if}} {{/if}}
{{/unless}} {{/if}}
{{/unless}} {{/unless}}
</template> </template>
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {Bonus} from "../../../../api/bonus";
import {BertAlertVisuals} from "../../../../api/bertAlertVisuals"; import {BertAlertVisuals} from "../../../../api/bertAlertVisuals";
import "./export.html"; import "./export.html";
...@@ -12,12 +10,6 @@ import "./export.html"; ...@@ -12,12 +10,6 @@ import "./export.html";
* ############################################################################ * ############################################################################
*/ */
Template.cardsetNavigationExport.helpers({
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
}
});
Template.cardsetNavigationExport.events({ Template.cardsetNavigationExport.events({
'click #exportCardsBtn': function () { 'click #exportCardsBtn': function () {
let name = this.name; let name = this.name;
......
<template name="cardsetNavigationImport"> <template name="cardsetNavigationImport">
{{#unless isInBonus}} {{#if isCardsetOwner _id}}
{{#if isCardsetOwner _id}} {{#unless isShuffledCardset _id}}
{{#unless isShuffledCardset _id}} <div class="hidden-xs btn-group">
<div class="hidden-xs btn-group"> <a href="#" id="importCardsBtn" class="btn btn-sm btn-raised importCardBtn"
<a href="#" id="importCardsBtn" class="btn btn-sm btn-raised importCardBtn" data-toggle="modal"
data-toggle="modal" data-target="#importModal"><i
data-target="#importModal"><i class="fa fa-cloud-upload"></i> {{_ "sidebar-nav.importcard"}}</a>
class="fa fa-cloud-upload"></i> {{_ "sidebar-nav.importcard"}}</a> </div>
</div> {{/unless}}
{{/unless}} {{/if}}
{{/if}}
{{/unless}}
</template> </template>
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session"; import {Session} from "meteor/session";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {Bonus} from "../../../../api/bonus";
import "../modal/import.js"; import "../modal/import.js";
import "./import.html"; import "./import.html";
...@@ -12,12 +10,6 @@ import "./import.html"; ...@@ -12,12 +10,6 @@ import "./import.html";
* ############################################################################ * ############################################################################
*/ */
Template.cardsetNavigationImport.helpers({
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
}
});
Template.cardsetNavigationImport.events({ Template.cardsetNavigationImport.events({
'click #importCardsBtn': function () { 'click #importCardsBtn': function () {
Session.set('importType', 1); Session.set('importType', 1);
......
<template name="cardsetNavigationLearning"> <template name="cardsetNavigationLearning">
{{#if isInBonus}} {{#if notEmpty}}
{{#if notEmpty}} <button id="learnBoxActive"
<button id="learnBoxActive" class="btn btn-sm btn-raised btn-success learn btn-learn"><i class="fa fa-graduation-cap"></i> {{_
class="btn btn-sm btn-raised btn-success learn btn-learn">{{_ "cardsToLearn"}}</button>
"cardsToLearn"}}</button>
{{/if}}
{{/if}} {{/if}}
</template> </template>
...@@ -6,7 +6,6 @@ import {Leitner} from "../../../../api/learned"; ...@@ -6,7 +6,6 @@ import {Leitner} from "../../../../api/learned";
import {Cardsets} from "../../../../api/cardsets"; import {Cardsets} from "../../../../api/cardsets";
import {CardsetNavigation} from "../../../../api/cardsetNavigation"; import {CardsetNavigation} from "../../../../api/cardsetNavigation";
import {BertAlertVisuals} from "../../../../api/bertAlertVisuals"; import {BertAlertVisuals} from "../../../../api/bertAlertVisuals";
import {Bonus} from "../../../../api/bonus";
import "./learning.html"; import "./learning.html";
/* /*
...@@ -18,13 +17,10 @@ import "./learning.html"; ...@@ -18,13 +17,10 @@ import "./learning.html";
Template.cardsetNavigationLearning.helpers({ Template.cardsetNavigationLearning.helpers({
notEmpty: function () { notEmpty: function () {
return Leitner.find({ return Leitner.find({
cardset_id: this._id, cardset_id: Router.current().params._id,
user_id: Meteor.userId(), user_id: Meteor.userId(),
active: true active: true
}).count(); }).count();
},
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
} }
}); });
...@@ -37,82 +33,77 @@ Template.cardsetNavigationLearning.events({ ...@@ -37,82 +33,77 @@ Template.cardsetNavigationLearning.events({
}); });
Template.cardsetNavigationLearning.onCreated(function () { Template.cardsetNavigationLearning.onCreated(function () {
if (!Roles.userIsInRole(Meteor.userId(), ["admin", "editor"])) { CardsetNavigation.addToLeitner(Session.get('activeCardset')._id);
if (Session.get('activeCardset').owner !== Meteor.userId() && !Session.get('activeCardset').editors.includes(Meteor.userId())) {
CardsetNavigation.addToLeitner(Session.get('activeCardset')._id);
}
}
}); });
Template.cardsetNavigationLearning.onRendered(function () { Template.cardsetNavigationLearning.onRendered(function () {
if (!Roles.userIsInRole(Meteor.userId(), ["admin", "editor"])) { setTimeout(function () {
if (Meteor.userId() !== Session.get('activeCardset').owner && !Session.get('activeCardset').editors.includes(Meteor.userId())) { Bert.defaults.hideDelay = 97200;
setTimeout(function () { let bertType = "success";
Bert.defaults.hideDelay = 97200; if (Session.get('activeCardset').registrationPeriod.getTime() < new Date()) {
let bertType = "success"; if (Leitner.findOne({
if (Session.get('activeCardset').registrationPeriod.getTime() < new Date()) { cardset_id: Session.get('activeCardset')._id,
if (Leitner.findOne({cardset_id: Session.get('activeCardset')._id, user_id: Meteor.userId()}, {fields: {_id: 1}}) === undefined) { user_id: Meteor.userId()
bertType = "warning"; }, {fields: {_id: 1}}) === undefined) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('bonus.message.registrationPeriodExpired'), bertType, 'growl-top-left'); bertType = "warning";
return; BertAlertVisuals.displayBertAlert(TAPi18n.__('bonus.message.registrationPeriodExpired'), bertType, 'growl-top-left');
} return;
}
}
if (Session.get('activeCardset').learningEnd.getTime() > new Date().getTime()) {
let text = "";
if (Leitner.find({
cardset_id: Session.get('activeCardset')._id,
user_id: Meteor.userId(),
active: true
}).count()) {
var active = Leitner.findOne({
cardset_id: Session.get('activeCardset')._id,
user_id: Meteor.userId(),
active: true
});
var deadline = new Date(active.currentDate.getTime() + Session.get('activeCardset').daysBeforeReset * 86400000);
if (deadline.getTime() > Session.get('activeCardset').learningEnd.getTime()) {
text += (TAPi18n.__('deadlinePrologue') + moment(Session.get('activeCardset').learningEnd).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue1'));
} else {
text += (TAPi18n.__('deadlinePrologue') + moment(deadline).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue2'));
} }
if (Session.get('activeCardset').learningEnd.getTime() > new Date().getTime()) { bertType = "warning";
let text = ""; } else {
if (Leitner.find({ if (Leitner.find({
cardset_id: Session.get('activeCardset')._id, cardset_id: Session.get('activeCardset')._id,
user_id: Meteor.userId(),
box: {$ne: 6}
}).count() === 0) {
text += TAPi18n.__('bonus.message.learnedEverything');
} else {
let nextCardDate = Leitner.findOne({
cardset_id: Router.current().params._id,
user_id: Meteor.userId(), user_id: Meteor.userId(),
active: true box: {$ne: 6}
}).count()) { }, {sort: {nextDate: 1}}).nextDate;
var active = Leitner.findOne({ let learningEnd = Cardsets.findOne({_id: Router.current().params._id}).learningEnd;
cardset_id: Session.get('activeCardset')._id, if (nextCardDate.getTime() > learningEnd.getTime()) {
user_id: Meteor.userId(), text += TAPi18n.__('noMoreCardsBeforeEnd');
active: true }
}); let nextDate;
var deadline = new Date(active.currentDate.getTime() + Session.get('activeCardset').daysBeforeReset * 86400000); if (nextCardDate.getTime() < new Date().getTime()) {
if (deadline.getTime() > Session.get('activeCardset').learningEnd.getTime()) { nextDate = moment(new Date());
text += (TAPi18n.__('deadlinePrologue') + moment(Session.get('activeCardset').learningEnd).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue1'));
} else {
text += (TAPi18n.__('deadlinePrologue') + moment(deadline).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue2'));
}
bertType = "warning";
} else { } else {
if (Leitner.find({ nextDate = moment(nextCardDate);
cardset_id: Session.get('activeCardset')._id,
user_id: Meteor.userId(),
box: {$ne: 6}
}).count() === 0) {
text += TAPi18n.__('bonus.message.learnedEverything');
} else {
let nextCardDate = Leitner.findOne({
cardset_id: Router.current().params._id,
user_id: Meteor.userId(),
box: {$ne: 6}
}, {sort: {nextDate: 1}}).nextDate;
let learningEnd = Cardsets.findOne({_id: Router.current().params._id}).learningEnd;
if (nextCardDate.getTime() > learningEnd.getTime()) {
text += TAPi18n.__('noMoreCardsBeforeEnd');
}
let nextDate;
if (nextCardDate.getTime() < new Date().getTime()) {
nextDate = moment(new Date());
} else {
nextDate = moment(nextCardDate);
}
if (nextDate.get('hour') >= Meteor.settings.public.leitner.dayIntervalHour) {
nextDate.add(1, 'day');
}
nextDate.hour(Meteor.settings.public.leitner.dayIntervalHour);
nextDate.minute(0);
text += TAPi18n.__('noCardsToLearn') + nextDate.format("DD.MM.YYYY") + TAPi18n.__('at') + nextDate.format("HH:mm") + TAPi18n.__('released');
}
} }
BertAlertVisuals.displayBertAlert(text, bertType, 'growl-top-left'); if (nextDate.get('hour') >= Meteor.settings.public.leitner.dayIntervalHour) {
} else { nextDate.add(1, 'day');
BertAlertVisuals.displayBertAlert(TAPi18n.__('bonus.message.bonusEnded'), bertType, 'growl-top-left'); }
nextDate.hour(Meteor.settings.public.leitner.dayIntervalHour);
nextDate.minute(0);
text += TAPi18n.__('noCardsToLearn') + nextDate.format("DD.MM.YYYY") + TAPi18n.__('at') + nextDate.format("HH:mm") + TAPi18n.__('released');
} }
Bert.defaults.hideDelay = 7; }
}, 2000); BertAlertVisuals.displayBertAlert(text, bertType, 'growl-top-left');
} else {
BertAlertVisuals.displayBertAlert(TAPi18n.__('bonus.message.bonusEnded'), bertType, 'growl-top-left');
} }
} Bert.defaults.hideDelay = 7;
}, 2000);
}); });
...@@ -12,16 +12,14 @@ ...@@ -12,16 +12,14 @@
<li id="report_button" class="reportList" data-toggle="modal" <li id="report_button" class="reportList" data-toggle="modal"
data-target="#reportModal">{{_ data-target="#reportModal">{{_
"report"}}</li> "report"}}</li>
{{#unless isInBonus}} {{#if learning}}
{{#if learning}} <li id="leaveCardsetModalButton" class="leaveCardsetList"
<li id="leaveCardsetModalButton" class="leaveCardsetList" data-toggle="modal" data-target="#leaveCardsetModal">{{_
data-toggle="modal" data-target="#leaveCardsetModal">{{_ "confirm-leave-cardset.btn-txt"}}</li>
"confirm-leave-cardset.btn-txt"}}</li> {{else}}
{{else}} <li id="leaveCardsetButton" class="leaveCardsetList">{{_
<li id="leaveCardsetButton" class="leaveCardsetList">{{_ "confirm-leave-cardset.btn-txt"}}</li>
"confirm-leave-cardset.btn-txt"}}</li> {{/if}}
{{/if}}
{{/unless}}
{{/unless}} {{/unless}}
{{#if isEditor}} {{#if isEditor}}
{{#unless isCardsetOwner _id}} {{#unless isCardsetOwner _id}}
......
<template name="cardsetNavigationNewCard"> <template name="cardsetNavigationNewCard">
{{#unless isInBonus}} {{#if isCardsetOwner _id}}
{{#if isCardsetOwner _id}} {{#unless isShuffledCardset _id}}
{{#unless isShuffledCardset _id}} <div class="hidden-xs btn-group">
<div class="hidden-xs btn-group"> <a type="button" id="newCardBtn" class="btn btn-sm btn-raised newCardBtn"
<a type="button" id="newCardBtn" class="btn btn-sm btn-raised newCardBtn" href="{{pathFor 'newCard'}}"
href="{{pathFor 'newCard'}}" {{disableIfOffline}}><i class="fa fa-plus"></i> {{_ "sidebar-nav.createcard"}}
{{disableIfOffline}}><i class="fa fa-plus"></i> {{_ "sidebar-nav.createcard"}} </a>
</a> </div>
</div> {{/unless}}
{{/unless}} {{/if}}
{{/if}}
{{/unless}}
</template> </template>
\ No newline at end of file
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {Bonus} from "../../../../api/bonus";
import "./newCard.html"; import "./newCard.html";
/*
* ############################################################################
* cardsetNavigationNewCard
* ############################################################################
*/
Template.cardsetNavigationNewCard.helpers({
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
}
});
<template name="cardsetNavigationPresentation"> <template name="cardsetNavigationPresentation">
{{#unless isInBonus}} {{#if this.quantity}}
{{#if this.quantity}} {{#if gotPresentation}}
{{#if gotPresentation}} <div class="btn-group">
<div class="btn-group"> <button id="startPresentation"
<button id="startPresentation" class="btn btn-sm btn-raised presentationBtn" {{disableIfOffline}}><img
class="btn btn-sm btn-raised presentationBtn" {{disableIfOffline}}><img src="/img/projector_white.png" class="projectorIconButton"
src="/img/projector_white.png" class="projectorIconButton" title="{{_ "presentation.create"}}"> {{_ "presentation.create"}}
title="{{_ "presentation.create"}}"> {{_ "presentation.create"}} </button>
</button> </div>
</div>
{{/if}}
{{/if}} {{/if}}
{{/unless}} {{/if}}
</template> </template>
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {CardType} from "../../../../api/cardTypes"; import {CardType} from "../../../../api/cardTypes";
import {Bonus} from "../../../../api/bonus";
import "./presentation.html"; import "./presentation.html";
/* /*
...@@ -19,9 +16,6 @@ Template.cardsetNavigationPresentation.helpers({ ...@@ -19,9 +16,6 @@ Template.cardsetNavigationPresentation.helpers({
} else { } else {
return CardType.gotPresentationMode(this.cardType); return CardType.gotPresentationMode(this.cardType);
} }
},
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
} }
}); });
......
<template name="cardsetNavigationWorkload"> <template name="cardsetNavigationWorkload">
{{#unless isInBonus}} {{#if this.quantity}}
{{#if this.quantity}} {{#if gotLearningModes}}
{{#if gotLearningModes}} <div class="btn-group">
<div class="btn-group"> <button type="button" class="btn btn-sm btn-raised learnBtn"
<button type="button" class="btn btn-sm btn-raised learnBtn" data-toggle="dropdown"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
aria-haspopup="true" aria-expanded="false"> <i class="fa fa-graduation-cap"></i> {{_ "learn"}} <span class="caret"></span>
<i class="fa fa-graduation-cap"></i> {{_ "learn"}} <span class="caret"></span> </button>
</button> <ul class="dropdown-menu">
<ul class="dropdown-menu"> <li id="learnBox" class="leitnerList" {{disableIfOffline}}>{{_
<li id="learnBox" class="leitnerList" {{disableIfOffline}}>{{_ "learnfile"}}</li>
"learnfile"}}</li> <li id="learnMemo" class="wozniakList" {{disableIfOffline}}>{{_
<li id="learnMemo" class="wozniakList" {{disableIfOffline}}>{{_ "memo"}}</li>
"memo"}}</li> {{#if learningLeitner}}
{{#if learningLeitner}} <li id="leitnerProgress" class="progressList" {{disableIfOffline}}>{{_
<li id="leitnerProgress" class="progressList" {{disableIfOffline}}>{{_ "admin.myProgress"}}</li>
"admin.myProgress"}}</li> {{/if}}
{{/if}} {{#if learningLeitner}}
{{#if learningLeitner}} <li id="resetLeitner" class="resetLeitnerList"
<li id="resetLeitner" class="resetLeitnerList" data-toggle="modal"
data-toggle="modal" data-target="#resetLeitnerModal" {{disableIfOffline}}>{{_
data-target="#resetLeitnerModal" {{disableIfOffline}}>{{_ "resetLearnfile"}}</li>
"resetLearnfile"}}</li> {{/if}}
{{/if}} {{#if learningMemo}}
{{#if learningMemo}} <li id="resetMemo" class="resetWozniakList"
<li id="resetMemo" class="resetWozniakList" data-toggle="modal"
data-toggle="modal" data-target="#resetMemoModal" {{disableIfOffline}}>{{_
data-target="#resetMemoModal" {{disableIfOffline}}>{{_ "resetWozniak"}}</li>
"resetWozniak"}}</li> {{/if}}
{{/if}} </ul>
</ul> </div>
</div>
{{/if}}
{{/if}} {{/if}}
{{/unless}} {{/if}}
</template> </template>
//------------------------ IMPORTS //------------------------ IMPORTS
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {CardType} from "../../../../api/cardTypes"; import {CardType} from "../../../../api/cardTypes";
import {Leitner, Wozniak} from "../../../../api/learned"; import {Leitner, Wozniak} from "../../../../api/learned";
import {Cardsets} from "../../../../api/cardsets"; import {Cardsets} from "../../../../api/cardsets";
import {CardsetNavigation} from "../../../../api/cardsetNavigation"; import {CardsetNavigation} from "../../../../api/cardsetNavigation";
import {Bonus} from "../../../../api/bonus";
import "../modal/leitner.js"; import "../modal/leitner.js";
import "../modal/wozniak.js"; import "../modal/wozniak.js";
import "../modal/chooseFlashcards.js"; import "../modal/chooseFlashcards.js";
...@@ -37,9 +35,6 @@ Template.cardsetNavigationWorkload.helpers({ ...@@ -37,9 +35,6 @@ Template.cardsetNavigationWorkload.helpers({
return Wozniak.findOne({ return Wozniak.findOne({
cardset_id: Router.current().params._id, cardset_id: Router.current().params._id,
user_id: Meteor.userId()}); user_id: Meteor.userId()});
},
isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
} }
}); });
......
<template name="cardsetNavigation"> <template name="cardsetNavigation">
<div class="cardsetInfoFooter panel-footer"> <div class="cardsetInfoFooter panel-footer">
{{#if hasCardsetPermission}} {{#if hasCardsetPermission}}
{{> cardsetNavigationLearning}} {{#unless isInBonusAndNotOwner}}
{{> cardsetNavigationPresentation}} {{> cardsetNavigationPresentation}}
{{> cardsetNavigationWorkload}} {{/unless}}
{{#if isInBonus}}
{{> cardsetNavigationLearning}}
{{else}}
{{> cardsetNavigationWorkload}}
{{/if}}
{{> cardsetNaviga