Commit 8e53b5f3 authored by Curtis Adam's avatar Curtis Adam

Convert bonus notifications to bert alert messages

parent ddde7e02
......@@ -85,6 +85,7 @@
{{#if isActiveRoute 'memo'}}
<h4>{{_ "wozniak.empty.text"}}</h4>
{{/if}}
{{> learnBackButton}}
</div>
</div>
</div>
......@@ -106,6 +107,7 @@
{{#if isActiveRoute 'memo'}}
<h4>{{_ "wozniak.endscreen.text"}}</h4>
{{/if}}
{{> learnBackButton}}
</div>
</div>
</div>
......
......@@ -49,9 +49,7 @@
{{selectedForLearning}}
{{/unless}}
{{#if isActiveRoute regex='cardsetdetailsid|cardsetcard'}}
{{#if learningActiveAndNotEditor}}
{{> leitnerLearning}}
{{else}}
{{#unless learningActiveAndNotEditor}}
{{#if this.quantity}}
<div class="col-xs-12">
{{> cardNavigation}}
......@@ -60,7 +58,7 @@
{{> flashcards cardset=this}}
</div>
{{/if}}
{{/if}}
{{/unless}}
{{/if}}
{{#if isActiveRoute 'cardsetlistid'}}
<div class="col-xs-12">
......@@ -336,7 +334,8 @@
<div class="row markdeepCardset">
<div class="col-xs-12 {{#if
learningActive}}col-md-4{{else}}col-sm-6 col-md-8{{/if}} markdeepCardsetContent">
<div class="cardsetLabels">{{{getKind kind 0}}} {{{getShuffleLabel this.shuffled}}} {{{getBonusLabel this.learningActive}}}</div>
<div class="cardsetLabels">{{{getKind kind 0}}} {{{getShuffleLabel
this.shuffled}}} {{{getBonusLabel this.learningActive}}}</div>
<h4 id="cardsetTitle">{{name}}</h4>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 infoBox">
......@@ -370,6 +369,9 @@
<div class="panel-footer">
{{#if hasCardsetPermission}}
{{#if learningActive}}
{{> leitnerLearning}}
{{/if}}
{{#unless learningActive}}
{{#if this.quantity}}
{{#if gotPresentation}}
......@@ -1448,46 +1450,11 @@
</template>
<template name="leitnerLearning">
<div class="col-xs-12 flip-container" id="set-details-region">
{{addToLeitner}}
<div id="cardCarousel" class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="empty-item">
<div class="box">
<div class="block">
{{#unless learningEnded}}
<div class="bs-callout bs-callout-info" id="callout-alerts-no-default">
<h4><strong>{{_ "learnPhaseActiveHeader"}}</strong></h4>
<p>{{_ "learnPhaseActiveBody"}}</p>
</div>
{{#if notEmpty}}
<div class="alert alert-warning leitner-text" role="alert">{{Deadline}}</div>
<br><br>
<button id="learnBoxActive"
class="btn btn-raised btn-success learn btn-block btn-learn">{{_
"cardsToLearn"}}</button>
{{else}}
{{#if allLearned}}
<br><br>
<div class="alert alert-success leitner-text" role="alert">{{_
"learnedEverything"}}</div>
{{else}}
<br><br>
<button id="learnBoxDisabled"
class="btn btn-warning learn btn-block btn-learn"
disabled>{{getNextCardTime}}</button>
{{/if}}
{{/if}}
{{else}}
<div class="alert alert-danger leitner-header" role="alert">{{_
"learnPhaseEnded"}}</div>
{{/unless}}
</div>
</div>
</div>
</div>
</div>
</div>
{{#if notEmpty}}
<button id="learnBoxActive"
class="btn btn-sm btn-raised btn-success learn btn-learn">{{_
"cardsToLearn"}}</button>
{{/if}}
</template>
<template name="cardsetLearnActivityStatistic">
......
......@@ -1660,26 +1660,6 @@ Template.learningPhaseInfoBox.events({
*/
Template.leitnerLearning.helpers({
addToLeitner: function () {
if (this.owner !== Meteor.userId() && !this.editors.includes(Meteor.userId())) {
addToLeitner(this._id);
}
},
learningEnded: function () {
return (this.learningEnd.getTime() < new Date().getTime());
},
allLearned: function () {
return (Leitner.find({cardset_id: this._id, user_id: Meteor.userId(), box: {$ne: 6}}).count() === 0);
},
Deadline: function () {
var active = Leitner.findOne({cardset_id: this._id, user_id: Meteor.userId(), active: true});
var deadline = new Date(active.currentDate.getTime() + this.daysBeforeReset * 86400000);
if (deadline.getTime() > this.learningEnd.getTime()) {
return (TAPi18n.__('deadlinePrologue') + this.learningEnd.toLocaleDateString() + TAPi18n.__('deadlineEpilogue1'));
} else {
return (TAPi18n.__('deadlinePrologue') + deadline.toLocaleDateString() + TAPi18n.__('deadlineEpilogue2'));
}
},
notEmpty: function () {
return Leitner.find({
cardset_id: this._id,
......@@ -1696,3 +1676,71 @@ Template.leitnerLearning.events({
});
}
});
Template.leitnerLearning.onCreated(function () {
if (Session.get('activeCardset').owner !== Meteor.userId() && !Session.get('activeCardset').editors.includes(Meteor.userId())) {
addToLeitner(Session.get('activeCardset')._id);
}
});
Template.leitnerLearning.onRendered(function () {
setTimeout(function () {
Bert.defaults.hideDelay = 97200;
let bertType = "success";
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'));
}
bertType = "warning";
} else {
if (Leitner.find({
cardset_id: Session.get('activeCardset')._id,
user_id: Meteor.userId(),
box: {$ne: 6}
}).count() === 0) {
text += TAPi18n.__('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');
}
}
Bert.alert(text, bertType, 'growl-top-left');
} else {
Bert.alert(TAPi18n.__('learnPhaseEnded'), bertType, 'growl-top-left');
}
Bert.defaults.hideDelay = 7;
}, 2000);
});
......@@ -57,11 +57,13 @@
<div id="learn-navigation" class="btn-group btn-group-justified">
{{#if isActiveRoute 'box'}}
<div class="btn-group" role="group">
<button class="btn btn-raised btn-warning answer card-fail" id="notknown" title="{{_ "notknow"}}">{{_
<button class="btn btn-raised btn-warning answer card-fail" id="notknown"
title="{{_ "notknow"}}">{{_
"notknow"}} {{#if fullscreenActive}}( {{_ "key" key='n'}} ){{/if}}</button>
</div>
<div class="btn-group" role="group">
<button class="btn btn-raised btn-success answer card-success" id="known" title="{{_ "know"}}">{{_
<button class="btn btn-raised btn-success answer card-success" id="known"
title="{{_ "know"}}">{{_
"know"}} {{#if fullscreenActive}}( {{_ "key" key='y'}} ){{/if}}</button>
</div>
{{/if}}
......@@ -124,3 +126,10 @@
<br>
<br>
</template>
<template name="learnBackButton">
<br>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<span class="pull-left">{{_ "backbutton"}}</span>
</button>
</template>
......@@ -125,3 +125,17 @@ Template.learnAnswerOptions.events({
CardNavigation.rateWozniak(event);
}
});
/*
* ############################################################################
* learnAnswerOptions
* ############################################################################
*/
Template.learnBackButton.events({
"click #backButton": function () {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
});
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