Commit f80d30af authored by Curtis Adam's avatar Curtis Adam

Revert "Refactor card editor templates"

This reverts commit 3a8f4eda
parent 3a8f4eda
<template name="btnCard">
<div id="button-row" class="col-xs-12 actionButtons editorElement">
<button id="cardSave"
class="btn btn-success btn-raised saveFirst col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="13">
{{_ "savecard"}}
</button>
<button id="cardSaveReturn"
class="btn btn-default btn-raised save col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="14">
{{_ "savecardReturn"}}
</button>
<button id="cardCancel" class="btn btn-danger btn-raised cancel col-xs-12 col-sm-3 pull-right"
tabindex="15" data-toggle="modal"
data-target="#cancelEditModal">{{_
"declinecard"}}</button>
</div>
</template>
import "./cardEditor.html";
import "../../card.js";
import {Session} from "meteor/session";
import {CardType} from "../../api/cardTypes";
import {Template} from "meteor/templating";
import {Cards} from "../../api/cards";
import {Cardsets} from "../../api/cardsets";
import {CardEditor} from "../../api/cardEditor.js";
import {Route} from "../../api/route.js";
Template.btnCard.helpers({
isEditMode: function () {
return Route.isEditMode();
},
learningActive: function () {
return Cardsets.findOne(Router.current().params._id).learningActive;
}
});
Template.btnCard.events({
"click #cardSave": function () {
CardEditor.saveCard(Router.current().params.card_id, false);
},
"click #cardSaveReturn": function () {
CardEditor.saveCard(Router.current().params.card_id, true);
}
});
<template name="learningGoalLevel">
<div id="learningGoalLevelGroup" class="form-group btn-group col-xs-12" role="group" data-toggle="buttons">
<button id="learningGoalLevel0"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
0}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 0}}active{{/if}}"
data-lvl="0">
{{#if isLearningGoalLevel 0}}
<input type="radio" name="learningGoalLevel" value="0" checked tabindex="4" data-lvl="0">
{{else}}
<input type="radio" name="learningGoalLevel" value="0" data-lvl="0">
{{/if}}
{{_ "learning-goal.level1"}}
</button>
<button id="learningGoalLevel1"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
1}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 1}}active{{/if}}"
data-lvl="1">
{{#if isLearningGoalLevel 1}}
<input type="radio" name="learningGoalLevel" value="1" checked tabindex="4" data-lvl="1">
{{else}}
<input type="radio" name="learningGoalLevel" value="1" data-lvl="1">
{{/if}}
{{_ "learning-goal.level2"}}
</button>
<button id="learningGoalLevel2"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
2}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 2}}active{{/if}}"
data-lvl="2">
{{#if isLearningGoalLevel 2}}
<input type="radio" name="learningGoalLevel" value="2" checked tabindex="4" data-lvl="2">
{{else}}
<input type="radio" name="learningGoalLevel" value="2" data-lvl="2">
{{/if}}
{{_ "learning-goal.level3"}}
</button>
<button id="learningGoalLevel3"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
3}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 3}}active{{/if}}"
data-lvl="3">
{{#if isLearningGoalLevel 3}}
<input type="radio" name="learningGoalLevel" value="3" checked tabindex="4" data-lvl="3">
{{else}}
<input type="radio" name="learningGoalLevel" value="3" data-lvl="3">
{{/if}}
{{_ "learning-goal.level4"}}
</button>
<button id="learningGoalLevel4"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
4}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 4}}active{{/if}}"
data-lvl="4">
{{#if isLearningGoalLevel 4}}
<input type="radio" name="learningGoalLevel" value="4" checked tabindex="4" data-lvl="4">
{{else}}
<input type="radio" name="learningGoalLevel" value="4" data-lvl="4">
{{/if}}
{{_ "learning-goal.level5"}}
</button>
<button id="learningGoalLevel5"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
5}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 5}}active{{/if}}"
data-lvl="5">
{{#if isLearningGoalLevel 5}}
<input type="radio" name="learningGoalLevel" value="5" checked tabindex="4" data-lvl="5">
{{else}}
<input type="radio" name="learningGoalLevel" value="5" data-lvl="5">
{{/if}}
{{_ "learning-goal.level6"}}
</button>
</div>
</template>
<template name="subjectEditor">
{{#if gotLearningUnit}}
<button class="btn btn-raised btn-success col-xs-4 col-sm-3 subjectEditorButton" data-toggle="modal"
data-target="#showSelectLearningUnitModal">{{_ "learningUnit.choose"}}</button>
{{/if}}
<form class="subjectEditor {{#if gotLearningUnit}}col-xs-8 col-sm-9{{/if}}">
<input class="form-control editorBackground" id="subjectEditor" name="content"
placeholder="{{getSubjectPlaceholder}}" value="{{getSubject}}"
tabindex="1" autofocus>
</form>
</template>
<template name="selectLearningUnit">
<div class="modal fade" id="showSelectLearningUnitModal" role="dialog">
<div class="modal-dialog" aria-labelledby="showSelectLearningUnitTitle">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 id="showSelectLearningUnitTitle" class="modal-title">{{_ "learningUnit.chooseIndex"}}</h4>
<div class="modal-body">
<button id="learningUnitCancel"
class="btn btn-danger btn-raised" {{disableIfOffline}}>
{{_ "learningUnit.cancel"}}
</button>
<div class="form-horizontal">
<div class="form-group">
<div class="form-group setdetails name">
<label id="setLearningIndexLabel" class="col-md-3 control-label"
for="setLearningIndex">{{_
"card.cardType0.name"}}</label>
<div class="dropdown">
<div class="btn-group col-xs-12 col-sm-12 col-md-9">
<button id="setLearningIndex" type="button"
class="btn btn-raised btn-default setLearningIndexDropdown longButton"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"
value="{{getCardsetId}}">{{getCardsetName}}
</button>
<button type="button"
class="btn btn-raised dropdown-toggle setLearningIndexDropdown"
data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only"></span>
</button>
<ul class="dropdown-menu btn-raised longButton">
<li class="learningIndex" value="0" data="0">
<a
href="#">{{_ "learningUnit.none"}}</a></li>
{{#each learningIndex}}
<li class="learningIndex" value="{{this._id}}" data="{{this._id}}">
<a
href="#">{{this.name}}</a></li>
{{/each}}
</ul>
<span id="helpSetLearningIndex" class="help-block learningIndex"></span>
</div>
</div>
</div>
{{#if gotLearningIndex}}
<hr>
<h4>{{_ "learningUnit.chooseUnit"}}</h4>
{{> cardsetList}}
{{/if}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<template name="btnCard">
<div id="button-row" class="col-xs-12 actionButtons editorElement">
<button id="cardSave"
class="btn btn-success btn-raised saveFirst col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="13">
{{_ "savecard"}}
</button>
<button id="cardSaveReturn"
class="btn btn-default btn-raised save col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="14">
{{_ "savecardReturn"}}
</button>
<button id="cardCancel" class="btn btn-danger btn-raised cancel col-xs-12 col-sm-3 pull-right"
tabindex="15" data-toggle="modal"
data-target="#cancelEditModal">{{_
"declinecard"}}</button>
</div>
</template>
import "./cardEditor.html";
import "../card/card.js";
import {Session} from "meteor/session";
import {CardType} from "../../api/cardTypes";
import {Template} from "meteor/templating";
import {Cards} from "../../api/cards";
import {Cardsets} from "../../api/cardsets";
import {CardEditor} from "../../api/cardEditor.js";
import {Route} from "../../api/route.js";
/*
* ############################################################################
* selectLearningUnit
* ############################################################################
*/
Template.selectLearningUnit.helpers({
getCardsetId: function () {
return Session.get('tempLearningIndex');
},
getCardsetName: function () {
if (Session.get('tempLearningIndex') === "0") {
return TAPi18n.__('learningUnit.none');
} else if (Session.get('tempLearningIndex') !== undefined) {
return Cardsets.findOne({_id: Session.get('tempLearningIndex')}).name;
}
},
gotLearningIndex: function () {
return Session.get('tempLearningIndex') !== "0";
},
learningIndex: function () {
return Cardsets.find({cardType: 0, visible: true, kind: {$in: ['free', 'edu']}}, {
sort: {name: 1},
fields: {name: 1}
});
}
});
Template.selectLearningUnit.events({
'click .learningIndex': function (evt) {
let learningIndex = $(evt.currentTarget).attr("data");
Session.set('tempLearningIndex', learningIndex);
$('#setLearningIndexLabel').css('color', '');
$('.setLearningIndexDropdown').css('border-color', '');
$('#helpLearningIndexType').html('');
if (learningIndex === "0") {
$('#showSelectLearningUnitModal').modal('hide');
Session.set('learningIndex', "0");
Session.set('learningUnit', "0");
}
},
'click #learningUnitCancel': function () {
$('#showSelectLearningUnitModal').modal('hide');
}
});
Template.btnCard.helpers({
isEditMode: function () {
return Route.isEditMode();
},
learningActive: function () {
return Cardsets.findOne(Router.current().params._id).learningActive;
}
});
Template.btnCard.events({
"click #cardSave": function () {
CardEditor.saveCard(Router.current().params.card_id, false);
},
"click #cardSaveReturn": function () {
CardEditor.saveCard(Router.current().params.card_id, true);
}
});
/*
* ############################################################################
* SubjectEditor
* ############################################################################
*/
Template.subjectEditor.helpers({
getSubject: function () {
if (CardType.gotLearningUnit(Session.get('cardType')) && Session.get('learningUnit') !== "0") {
let card = Cards.findOne({_id: Session.get('learningUnit')});
if (card !== undefined && card.subject !== undefined) {
return card.subject;
} else {
return "";
}
}
return Session.get('subject');
},
getSubjectPlaceholder: function () {
return CardType.getSubjectPlaceholderText(Session.get('cardType'));
},
gotLearningUnit: function () {
return CardType.gotLearningUnit(this.cardType);
}
});
Template.subjectEditor.events({
'click #subjectEditor': function () {
CardEditor.setEditorButtonIndex(0);
},
'input #subjectEditor': function () {
$('#subjectEditor').css('border', 0);
CardEditor.setEditorButtonIndex(0);
Session.set('subject', $('#subjectEditor').val());
},
'click .subjectEditorButton': function () {
Session.set('tempLearningIndex', Session.get('learningIndex'));
Session.set('tempLearningUnit', Session.get('learningUnit'));
}
});
Template.subjectEditor.rendered = function () {
Session.set('subject', $('#subjectEditor').val());
};
/*
* ############################################################################
* learningGoalLevel
* ############################################################################
*/
Template.learningGoalLevel.helpers({
isLearningGoalLevelChecked: function (learningGoalLevel) {
return learningGoalLevel <= Session.get('learningGoalLevel');
},
isLearningGoalLevel: function (learningGoalLevel) {
return learningGoalLevel === Session.get('learningGoalLevel');
}
});
Template.learningGoalLevel.events({
'click #learningGoalLevelGroup': function (event) {
CardEditor.setEditorButtonIndex(1);
Session.set('learningGoalLevel', Number($(event.target).data('lvl')));
}
});
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