Commit bacf3a43 authored by Curtis Adam's avatar Curtis Adam

Add a 'Leave cardset' button for users who aren't editors or owner of a cardset

parent ef5c8e8e
......@@ -101,6 +101,11 @@
"title": "Aktive Lernphase verlassen",
"text": "Willst du die aktive Lernphase wirklich verlassen? Wenn du den Vorgang bestätigst, wird deine Lernstatistik für diesen Kartensatz gelöscht."
},
"confirm-leave-cardset": {
"btn-txt": "Kartensatz verlassen",
"title": "Kartensatz verlassen",
"text": "Willst du diesen Kartensatz verlassen? Wenn du den Vorgang bestätigst, wird deine Lernstatistik für diesen Kartensatz gelöscht."
},
"confirm-leave-editors": {
"btn-txt": "Bearbeitergruppe verlassen",
"title": "Bearbeitergruppe verlassen",
......
......@@ -109,6 +109,11 @@
"title": "Leave the active Learning-Phase",
"text": "Do you really want to leave this active Learning-Phase? If you accept this, then your entire learning progress will be deleted."
},
"confirm-leave-cardset": {
"btn-txt": "Leave Cardset",
"title": "Leave the Cardset",
"text": "Do you really want to leave this Cardset? If you accept this, then your entire learning progress will be deleted."
},
"confirm-leave-editors": {
"btn-txt": "Leave Editor Group",
"title": "Leave Editor Group",
......
......@@ -39,6 +39,7 @@
{{> resetLeitnerForm}}
{{> resetMemoForm}}
{{> leaveLearnPhaseForm}}
{{> leaveCardsetForm}}
{{> leaveEditorsForm}}
{{onEditmodalClose this._id}}
{{/unless}}
......@@ -433,6 +434,19 @@
class="btn btn-raised btn-default btn-block btn-danger flag" href="#"
data-toggle="modal" data-target="#leaveModal">{{_
"confirm-leave-learnphase.btn-txt"}}</button>
{{else}}
{{#if learning}}
<button id="leaveCardsetModalButton"
style="white-space: normal; padding-left: 10px; padding-right: 10px;"
class="btn btn-raised btn-default btn-block btn-danger flag" href="#"
data-toggle="modal" data-target="#leaveCardsetModal">{{_
"confirm-leave-cardset.btn-txt"}}</button>
{{else}}
<button id="leaveCardsetButton"
style="white-space: normal; padding-left: 10px; padding-right: 10px;"
class="btn btn-raised btn-default btn-block btn-danger flag" href="#">{{_
"confirm-leave-cardset.btn-txt"}}</button>
{{/if}}
{{/if}}
{{/unless}}
{{#if isEditor}}
......@@ -630,6 +644,28 @@
</div>
</template>
<template name="leaveCardsetForm">
<div class="modal fade" id="leaveCardsetModal" tabindex="-1" role="dialog" aria-labelledby="leaveCardsetTitle">
<div class="modal-dialog">
<div class="modal-content modal-content-for-buttons xs-12">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<div class="modal-header">
<h4 id="leaveCardsetTitle" class="modal-title">{{_ "confirm-leave-cardset.title"}}</h4>
</div>
<div class="modal-body">
<p>{{_ "confirm-leave-cardset.text"}}</p>
<br>
<hr>
<button id="leaveCardsetConfirm" class="btn btn-block btn-raised btn-default btn-danger">{{_
"confirm-leave-cardset.btn-txt"}}</button>
<button id="leaveCardsetCancel" class="btn btn-default btn-block btn-raised"
data-dismiss="modal">{{_ "modal-dialog.cancel"}}</button>
</div>
</div>
</div>
</div>
</template>
<template name="leaveEditorsForm">
<div class="modal fade" id="leaveEditorsModal" tabindex="-1" role="dialog" aria-labelledby="leaveEditorsTitle">
<div class="modal-dialog">
......
......@@ -692,6 +692,29 @@ Template.leaveLearnPhaseForm.events({
}
});
/*
* ############################################################################
* leaveCardsetForm
* ############################################################################
*/
Template.leaveCardsetForm.events({
'click #leaveCardsetConfirm': function () {
var id = Router.current().params._id;
$('#leaveCardsetModal').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$('#leaveCardsetModal').on('hidden.bs.modal', function () {
Meteor.call("deleteLeitner", id);
Meteor.call("deleteWozniak", id);
Router.go('home');
});
}
});
/*
* ############################################################################
* leaveEditorsForm
......@@ -758,6 +781,9 @@ Template.cardsetSidebar.events({
},
"click #collapseManageButton": function () {
changeCollapseIcon("#collapseMangeIcon");
},
"click #leaveCardsetButton": function () {
Router.go('pool');
}
});
......@@ -768,15 +794,22 @@ Template.cardsetSidebar.helpers({
gotEnoughCards: function () {
return (this.quantity >= 1);
},
'learningLeitner': function () {
learningLeitner: function () {
return Leitner.findOne({cardset_id: Router.current().params._id, user_id: Meteor.userId()});
},
'learningMemo': function () {
learningMemo: function () {
return Wozniak.findOne({
cardset_id: Router.current().params._id,
user_id: Meteor.userId(),
interval: {$ne: 0}
});
},
learning: function () {
return (Leitner.findOne({cardset_id: Router.current().params._id, user_id: Meteor.userId()}) || Wozniak.findOne({
cardset_id: Router.current().params._id,
user_id: Meteor.userId(),
interval: {$ne: 0}
}));
}
});
......
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