Commit ec9e0e1c authored by Curtis Adam's avatar Curtis Adam

Add an option to edit an active bonus

parent a38c9959
......@@ -287,6 +287,10 @@ $themes: (
$cardset_footer_navigation_bonus_list_start_learning_text: map-get($map, "cardset_footer_navigation_bonus_list_start_learning_text");
$cardset_footer_navigation_bonus_list_start_learning_background_hover: map-get($map, "cardset_footer_navigation_bonus_list_start_learning_background_hover");
$cardset_footer_navigation_bonus_list_start_learning_text_hover: map-get($map, "cardset_footer_navigation_bonus_list_start_learning_text_hover");
$cardset_footer_navigation_bonus_list_manage_learning_background: map-get($map, "cardset_footer_navigation_bonus_list_manage_learning_background");
$cardset_footer_navigation_bonus_list_manage_learning_text: map-get($map, "cardset_footer_navigation_bonus_list_manage_learning_text");
$cardset_footer_navigation_bonus_list_manage_learning_background_hover: map-get($map, "cardset_footer_navigation_bonus_list_manage_learning_background_hover");
$cardset_footer_navigation_bonus_list_manage_learning_text_hover: map-get($map, "cardset_footer_navigation_bonus_list_manage_learning_text_hover");
$cardset_footer_navigation_bonus_list_stop_learning_background: map-get($map, "cardset_footer_navigation_bonus_list_stop_learning_background");
$cardset_footer_navigation_bonus_list_stop_learning_text: map-get($map, "cardset_footer_navigation_bonus_list_stop_learning_text");
$cardset_footer_navigation_bonus_list_stop_learning_background_hover: map-get($map, "cardset_footer_navigation_bonus_list_stop_learning_background_hover");
......@@ -1008,6 +1012,16 @@ $themes: (
color: $cardset_footer_navigation_bonus_list_start_learning_text_hover !important;
}
.manageLearningList {
background-color: $cardset_footer_navigation_bonus_list_manage_learning_background !important;
color: $cardset_footer_navigation_bonus_list_manage_learning_text !important;
}
.manageLearningList:hover {
background-color: $cardset_footer_navigation_bonus_list_manage_learning_background_hover !important;
color: $cardset_footer_navigation_bonus_list_manage_learning_text_hover !important;
}
.stopLearningList {
background-color: $cardset_footer_navigation_bonus_list_stop_learning_background !important;
color: $cardset_footer_navigation_bonus_list_stop_learning_text !important;
......
......@@ -331,6 +331,10 @@
"cardset_footer_navigation_bonus_list_start_learning_text": white,
"cardset_footer_navigation_bonus_list_start_learning_background_hover": $thm_green,
"cardset_footer_navigation_bonus_list_start_learning_text_hover": white,
"cardset_footer_navigation_bonus_list_manage_learning_background": none,
"cardset_footer_navigation_bonus_list_manage_learning_text": black,
"cardset_footer_navigation_bonus_list_manage_learning_background_hover": $thm_gray,
"cardset_footer_navigation_bonus_list_manage_learning_text_hover": white,
"cardset_footer_navigation_bonus_list_stop_learning_background": $thm_orange,
"cardset_footer_navigation_bonus_list_stop_learning_text": white,
"cardset_footer_navigation_bonus_list_stop_learning_background_hover": $thm_orange,
......
......@@ -333,6 +333,10 @@
"cardset_footer_navigation_bonus_list_start_learning_text": white,
"cardset_footer_navigation_bonus_list_start_learning_background_hover": white,
"cardset_footer_navigation_bonus_list_start_learning_text_hover": $thm_green,
"cardset_footer_navigation_bonus_list_manage_learning_background": none,
"cardset_footer_navigation_bonus_list_manage_learning_text": black,
"cardset_footer_navigation_bonus_list_manage_learning_background_hover": $thm_gray,
"cardset_footer_navigation_bonus_list_manage_learning_text_hover": white,
"cardset_footer_navigation_bonus_list_stop_learning_background": $thm_orange,
"cardset_footer_navigation_bonus_list_stop_learning_text": white,
"cardset_footer_navigation_bonus_list_stop_learning_background_hover": white,
......
......@@ -521,7 +521,12 @@
},
"bonus": {
"form": {
"title": "Bonus-Lernphase starten",
"new": {
"title": "Bonus-Lernphase starten"
},
"edit": {
"title": "Bonus-Lernphase verwalten"
},
"maxWorkload": {
"label": "Tagespensum",
"placeholder": "Maximal an einem Tag zu lernende Karten"
......@@ -544,7 +549,8 @@
},
"button": {
"start": "Starten",
"cancel": "Abbrechen"
"cancel": "Abbrechen",
"update": "Aktualisieren"
}
}
},
......@@ -606,8 +612,7 @@
},
"bonus": {
"long": "Bonus-Lernphase",
"short": "Bonus",
"manage": "Bonus-Lernphase verwalten"
"short": "Bonus"
},
"list": {
"back": "Zurück zur Karte"
......
......@@ -524,7 +524,7 @@
"create": "Start a presentation",
"start": "Start",
"list": {
"back":"Back to the presentation",
"back": "Back to the presentation",
"backDemo": "Back to the demo cardset"
}
},
......@@ -544,7 +544,12 @@
},
"bonus": {
"form": {
"title": "",
"new": {
"title": ""
},
"edit": {
"title": ""
},
"maxWorkload": {
"label": "",
"placeholder": ""
......@@ -567,7 +572,8 @@
},
"button": {
"start": "",
"cancel": ""
"cancel": "",
"update": ""
}
}
},
......@@ -1521,17 +1527,82 @@
"firstLogin": {
"title": "Welcome to __firstAppTitle__.__lastAppTitle__ !",
"message": "Take a look around the platform.
Here you can learn cards on a specific topic or create sets of cards for your studies.
Here
you
can
learn
cards
on
a
specific
topic
or
create
sets
of
cards
for
your
studies.
</br>
</br>
The
help
above
in
the
middle
explains
why
this
platform
is
so
unique
!
</br>
The help above in the middle explains why this platform is so unique !
</br>
Search
the
topic
pool
for
a
topic
that
interests
you.
Click
on
the
small
arrow
to
the
far
right
of
the
topic
to
see
the
description
of
the
card
index.
Click
on
the
topic
to
see
the
cards.
</br>
Search the topic pool for a topic that interests you.
Click on the small arrow to the far right of the topic to see the description of the card index.
Click on the topic to see the cards.
</br>
</br>"
"
},
"publishBonus": {
"message": ""
......
import {Session} from "meteor/session";
let defaultMaxWorkload = null;
let defaultDaysBeforeReset = null;
let defaultIntervals = [1, 3, 7, 28, 84];
export let BonusForm = class BonusForm {
static cleanModal () {
let start = moment().format("YYYY-MM-DD");
let nextDay = moment().add(1, 'day').format("YYYY-MM-DD");
let end = moment().add(3, 'months').format("YYYY-MM-DD");
let dateBonusStart = $('#bonusFormModal #dateBonusStart');
let dateBonusEnd = $('#bonusFormModal #dateBonusEnd');
let start, nextDay, end, dateBonusStart, dateBonusEnd, intervals, maxWorkload, daysBeforeReset;
if (Session.get('isNewBonus')) {
start = moment().format("YYYY-MM-DD");
nextDay = moment().add(1, 'day').format("YYYY-MM-DD");
end = moment().add(3, 'months').format("YYYY-MM-DD");
maxWorkload = defaultMaxWorkload;
daysBeforeReset = defaultDaysBeforeReset;
intervals = defaultIntervals;
} else {
start = moment(Session.get('activeCardset').learningStart).format("YYYY-MM-DD");
nextDay = moment(Session.get('activeCardset').learningStart).add(1, 'day').format("YYYY-MM-DD");
end = moment(Session.get('activeCardset').learningEnd).format("YYYY-MM-DD");
maxWorkload = Session.get('activeCardset').maxCards;
daysBeforeReset = Session.get('activeCardset').daysBeforeReset;
intervals = Session.get('activeCardset').learningInterval;
}
dateBonusStart = $('#bonusFormModal #dateBonusStart');
dateBonusEnd = $('#bonusFormModal #dateBonusEnd');
$('#bonusFormModal #maxWorkload').val(maxWorkload);
$('#bonusFormModal #daysBeforeReset').val(daysBeforeReset);
$('#bonusFormModal #interval1').val(intervals[0]);
$('#bonusFormModal #interval2').val(intervals[1]);
$('#bonusFormModal #interval3').val(intervals[2]);
$('#bonusFormModal #interval4').val(intervals[3]);
$('#bonusFormModal #interval5').val(intervals[4]);
dateBonusStart.attr("min", start);
dateBonusStart.attr("max", end);
dateBonusStart.val(start);
dateBonusEnd.attr("min", nextDay);
dateBonusEnd.val(end);
$('#bonusFormModal #maxWorkload').val(defaultMaxWorkload);
$('#bonusFormModal #daysBeforeReset').val(defaultDaysBeforeReset);
$('#bonusFormModal #interval1').val(defaultIntervals[0]);
$('#bonusFormModal #interval2').val(defaultIntervals[1]);
$('#bonusFormModal #interval3').val(defaultIntervals[2]);
$('#bonusFormModal #interval4').val(defaultIntervals[3]);
$('#bonusFormModal #interval5').val(defaultIntervals[4]);
}
};
......@@ -397,7 +397,7 @@ Meteor.methods({
* Deactivate the learning phase for the selected cardset.
* @param {String} id - ID of the cardset for which the learning phase is to be deactivated.
*/
deactivateLearning: function (id) {
deactivateBonus: function (id) {
check(id, String);
let cardset = Cardsets.findOne(id);
......@@ -421,7 +421,7 @@ Meteor.methods({
* @param {Date} learningEnd - End date of the learning phase
* @param {String} learningInterval - Learning interval in days
*/
activateLearning: function (id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval) {
activateBonus: function (id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval) {
check(id, String);
check(maxCards, String);
check(daysBeforeReset, String);
......@@ -477,7 +477,7 @@ Meteor.methods({
* @param {Date} learningEnd - End date of the learning phase
* @param {String} learningInterval - Learning interval in days
*/
updateLearning: function (id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval) {
updateBonus: function (id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval) {
check(id, String);
check(maxCards, String);
check(daysBeforeReset, String);
......@@ -501,10 +501,10 @@ Meteor.methods({
learningInterval: learningInterval
}
});
return cardset._id;
} else {
throw new Meteor.Error("not-authorized");
}
return true;
},
/**
* Updates the selected cardset if user is authorized.
......
......@@ -419,7 +419,7 @@
class="startLearn startLearningList"
data-toggle="modal"
data-target="#bonusFormModal">
{{_ "sidebar-nav.startLearning"}}
{{_ "bonus.form.new.title"}}
</li>
{{/unless}}
{{/if}}
......@@ -433,6 +433,12 @@
{{#if isCardsetOwner _id}}
{{#if isInRole 'admin, editor, lecturer'}}
{{#if learningActive}}
<li id="manageBonus"
class="manageLearn manageLearningList learnBoxActive"
data-toggle="modal"
data-target="#bonusFormModal">
{{_ "bonus.form.edit.title"}}
</li>
<li id="stopBonus"
class="stopLearn stopLearningList learnBoxActive"
data-toggle="modal"
......
......@@ -563,6 +563,12 @@ Template.cardsetInfo.events({
"click #manageEditors": function () {
Router.go('cardseteditors', {_id: Router.current().params._id});
},
"click #startBonus": function () {
Session.set('isNewBonus', true);
},
"click #manageBonus": function () {
Session.set('isNewBonus', false);
},
"click #collapseManageButton": function () {
changeCollapseIcon("#collapseMangeIcon");
},
......@@ -1172,7 +1178,7 @@ Template.cardsetManageEditors.created = function () {
Template.cardsetEndLearnForm.events({
"click #confirmEndLearn": function () {
if (Cardsets.findOne(Router.current().params._id).learningActive) {
Meteor.call("deactivateLearning", Router.current().params._id);
Meteor.call("deactivateBonus", Router.current().params._id);
}
$('#confirmEndLearnModal').modal('hide');
$('body').removeClass('modal-open');
......
......@@ -4,7 +4,8 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 id="bonusFormModalTitle" class="modal-title">{{_ "bonus.form.title"}}
<h4 id="bonusFormModalTitle" class="modal-title">{{#if isNewBonus}}{{_
"bonus.form.new.title"}}{{else}}{{_ "bonus.form.edit.title"}}{{/if}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
......@@ -19,8 +20,11 @@
<div class="modal-footer">
<button id="cancelBonus" class="btn btn-default btn-raised btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_ "bonus.form.button.cancel"}}</button>
<button id="startBonus" class="btn btn-success btn-raised btn-block col-xs-12 col-sm-3 pull-right"
data-dismiss="modal">{{_ "bonus.form.button.start"}}</button>
<button id="startBonus"
class="btn btn-success btn-raised btn-block col-xs-12 col-sm-3 pull-right"
data-dismiss="modal">{{#if isNewBonus}}{{_ "bonus.form.button.start"}}{{else}}{{_
"bonus.form.button.update"}}{{/if}}</button>
</div>
</div>
</div>
......
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {BonusForm} from "../../api/bonusForm";
import {Cardsets} from "../../api/cardsets";
import "./bonusForm.html";
/*
......@@ -17,6 +19,12 @@ Template.bonusForm.onRendered(function () {
});
});
Template.bonusForm.helpers({
isNewBonus: function () {
return Session.get('isNewBonus');
}
});
Template.bonusForm.events({
"click #startBonus": function () {
let maxCards = $('#bonusFormModal #maxWorkload').val();
......@@ -36,7 +44,15 @@ Template.bonusForm.events({
}
}
Meteor.call("activateLearning", Router.current().params._id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval);
if (Session.get('isNewBonus')) {
Meteor.call("activateBonus", Router.current().params._id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval);
} else {
Meteor.call("updateBonus", Router.current().params._id, maxCards, daysBeforeReset, learningStart, learningEnd, learningInterval, function (error, result) {
if (result) {
Session.set('activeCardset', Cardsets.findOne(result));
}
});
}
$('#bonusFormModal').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
......
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