Commit 97b8b441 authored by Curtis Adam's avatar Curtis Adam

Move the change owner and wordcloud functions to the frontend

parent 024e2edd
......@@ -245,6 +245,7 @@
"missingFields": "Bitte fülle die folgenden Felder aus",
"newcarddeck": "Kartei anlegen",
"editcard": "Beschreibung editieren",
"adminEditCardset": "Admin-Einstellungen",
"editreferences": "Repetitorium neu zusammenstellen",
"name": "Thema",
"nameplaceholder": "Das Thema der Kartei mit einem Wort",
......
......@@ -255,6 +255,7 @@
"missingFields": "Missing Fields",
"newcarddeck": "Create a new deck of cards",
"editcard": "Edit deck of cards",
"adminEditCardset": "Admin-Settings",
"editreferences": "Edit references",
"name": "Title",
"nameplaceholder": "Title of the cardset",
......
......@@ -6,6 +6,9 @@
{{> access_denied_content_only}}
{{else}}
{{> showLicense}}
{{#if isActiveRoute regex='alldecks|repetitorium'}}
{{> cardsetFormAdmin}}
{{/if}}
{{#if isActiveRoute regex='alldecks|create'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
......
......@@ -137,6 +137,13 @@
data-target="#setCardsetFormModal">
<i class="glyphicon glyphicon-pencil" data-id="{{this._id}}"></i>
</a>
{{#if isActiveRoute regex="alldecks|repetitorium"}}
<a class="resultNavigationElement editAdminCardset"
title='{{_ "courseIteration.manage"}}' data-id="{{this._id}}" data-toggle="modal"
data-target="#setCardsetFormAdminModal">
<i class="fa fa-cog editAdminCardset" data-id="{{this._id}}"></i>
</a>
{{/if}}
{{#if isActiveRoute regex="repetitorium"}}
<a class="resultNavigationElement editShuffle"
title='{{_ "set-list.shuffleCardsets"}}' data-id="{{this._id}}">
......
......@@ -136,7 +136,7 @@ Template.cardsetCourseIterationResultRow.events({
_id: $(event.target).data('id')
});
},
'click .editCardset': function (event) {
'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')));
......
......@@ -25,6 +25,55 @@
</div>
</template>
<template name="cardsetFormAdmin">
<div class="modal fade" id="setCardsetFormAdminModal" tabindex="-1" data-backdrop="static" role="dialog"
aria-labelledby="setCardsetFormAdminModalTitle">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 id="setCardsetFormAdminModalTitle" class="modal-title">
{{_ "modal-dialog.adminEditCardset"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label id="editCardsetUserLabelAdmin">{{_ "admin.cardset.username"}}</label>
{{#if userExists}}
<a href="/admin/user/{{getOwnerId}}" target="_blank">{{getAuthorName getOwnerId}}</a>
{{else}}
{{username}} ({{_ "admin.deleted"}})
{{/if}}
</div>
<div class="form-group">
<label id="cardsetOwnerAdminLabel">{{_ "admin.cardset.userID"}}</label>
{{#if userExists}}
<input class="form-control" type="text" id="editOwnerAdmin"
value="{{getOwnerId}}">
{{else}}
{{username}} ({{_ "admin.deleted"}})
{{/if}}
<a id="cardsetChangeOwnerAdmin" class="btn btn-raised btn-success">
{{_ "admin.cardset.changeOwner"}}</a>
<label id="cardsetChangeOwnerAdminLabel" for="cardsetChangeOwnerAdmin"
style="visibility: hidden;"></label>
</div>
<div class="form-group">
<label id="cardsetWordcloud">{{_ "admin.cardset.wordcloud"}}</label>
{{#if isInWordcloud}}
<a id="cardsetRemoveFromWordcloude" class="btn btn-raised btn-danger">
{{_ "admin.cardset.removeFromWordcloud"}}</a>
{{else}}
<a id="cardsetAddToWordcloude" class="btn btn-raised btn-success">
{{_ "admin.cardset.addToWordcloud"}}</a>
{{/if}}
</div>
</div>
</div>
</div>
</div>
</template>
<template name="cardsetFormContent">
<div class="modal-body">
<div class="form-horizontal">
......@@ -101,7 +150,8 @@
{{/unless}}
{{/unless}}
<button id="cardSetCancel" class="btn btn-raised {{#unless
isNew}}{{#if isActiveRoute regex='cardsetdetailsid|cardsetlistid'}}cardSetCancel{{/if}}{{/unless}} btn-default btn-block col-xs-12 col-sm-3"
isNew}}{{#if isActiveRoute
regex='cardsetdetailsid|cardsetlistid'}}cardSetCancel{{/if}}{{/unless}} btn-default btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
<button id="cardSetSave"
......
......@@ -165,6 +165,53 @@ Template.cardsetForm.helpers({
return isNewCardset();
}
});
/*
* ############################################################################
* cardsetFormAdmin
* ############################################################################
*/
Template.cardsetFormAdmin.onRendered(function () {
$('#setCardsetFormAdminModal').on('show.bs.modal', function () {
$('#cardsetChangeOwnerAdminLabel').html("");
});
$('#setCardsetFormAdminModal').on('hidden.bs.modal', function () {
Session.get('activeCardset', undefined);
});
});
Template.cardsetFormAdmin.helpers({
isInWordcloud: function () {
return Session.get('activeCardset').wordcloud;
},
getOwnerId: function () {
return Session.get('activeCardset').owner;
}
});
Template.cardsetFormAdmin.events({
'click #cardsetChangeOwnerAdmin': function (evt, tmpl) {
let owner = tmpl.find('#editOwnerAdmin').value;
Meteor.call('changeOwner', Session.get('activeCardset')._id, owner, function (error, result) {
if (error || result === false) {
$('#cardsetChangeOwnerAdminLabel').css({'visibility': 'visible', 'color': '#b94a48'});
$('#cardsetChangeOwnerAdminLabel').html(TAPi18n.__('admin.cardset.changeOwnerFailure'));
} else {
$('#cardsetChangeOwnerAdminLabel').css({'visibility': 'visible', 'color': '#4ab948'});
$('#cardsetChangeOwnerAdminLabel').html(TAPi18n.__('admin.cardset.changeOwnerSuccess'));
Session.set('activeCardset', Cardsets.findOne(Session.get('activeCardset')._id));
}
});
},
'click #cardsetAddToWordcloude': function () {
Meteor.call('updateWordcloudStatus', Session.get('activeCardset')._id, true);
Session.set('activeCardset', Cardsets.findOne(Session.get('activeCardset')._id));
},
'click #cardsetRemoveFromWordcloude': function () {
Meteor.call('updateWordcloudStatus', Session.get('activeCardset')._id, false);
Session.set('activeCardset', Cardsets.findOne(Session.get('activeCardset')._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