Upgraded spells page to Polymer 1

This commit is contained in:
Stefan Zermatten
2017-01-30 13:02:22 +02:00
parent fd21f4f7d7
commit 7af3b8e06e
12 changed files with 435 additions and 376 deletions

View File

@@ -1,48 +1,80 @@
Template.spellListDialog.onRendered(function(){
updatePolymerInputs(this);
Template.spellListDialog.helpers({
spellList: function(){
return SpellLists.findOne(this.spellListId);
}
});
const debounce = (f) => _.debounce(f, 300);
Template.spellListDialog.events({
"color-change": function(event, instance){
SpellLists.update(instance.data.spellListId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
"click #deleteButton": function(event, instance){
SpellLists.softRemoveNode(instance.data.spellListId);
GlobalUI.deletedToast(
instance.data.spellListId,
"SpellLists",
"Spell list and contents"
);
GlobalUI.closeDetail();
popDialogStack();
},
//TODO clean up String -> num here so they don't need casting by Schema.clean
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
"change #spellListNameInput, input #spellListNameInput": function(event){
"change #spellListNameInput, input #spellListNameInput":
debounce(function(event){
const input = event.currentTarget;
var value = input.value;
if (!value){
input.invalid = true;
input.errorMessage = "Name is required";
} else {
input.invalid = false;
SpellLists.update(this._id, {
$set: {name: value}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}
}),
"change #spellListSaveDCInput, input #spellListSaveDCInput":
debounce(function(event){
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {name: value}});
},
"change #spellListSaveDCInput, input #spellListSaveDCInput": function(event){
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {saveDC: value}});
},
SpellLists.update(this._id, {
$set: {saveDC: value}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}),
"change #spellListAttackBonusInput, input #spellListAttackBonusInput":
function(event){
debounce(function(event){
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {attackBonus: value}});
},
SpellLists.update(this._id, {
$set: {attackBonus: value}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}),
"change #spellListMaxPreparedInput, input #spellListMaxPreparedInput":
function(event){
debounce(function(event){
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {maxPrepared: value}});
},
"change #spellListDescriptionInput": function(event){
SpellLists.update(this._id, {
$set: {maxPrepared: value}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}),
"input #spellListDescriptionInput": debounce(function(event){
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {description: value}});
},
});
Template.spellListDialog.helpers({
spellList: function(){
return SpellLists.findOne(this.spellListId);
}
SpellLists.update(this._id, {
$set: {description: value}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}),
});