Added ability to add/edit buffs

This commit is contained in:
Jacob
2017-08-09 15:01:20 +01:00
parent bce1b85600
commit 08735ea4f7
18 changed files with 308 additions and 26 deletions

View File

@@ -0,0 +1,15 @@
<template name="customBuffEdit">
{{#with buff}}
{{#baseEditDialog title=name hideColor=true}}
<!--name-->
<paper-input id="buffNameInput" class="fullwidth" label="Name" value={{name}}></paper-input>
<!--description-->
<paper-textarea label="Description" id="buffDescriptionInput" value={{description}}></paper-textarea>
{{> effectsEditList parentId=_id parentCollection="Buffs" charId=charId name=name enabled=false}}
{{> attackEditList parentId=_id parentCollection="Buffs" charId=charId name=name enabled=false}}
{{> proficiencyEditList parentId=_id parentCollection="Buffs" charId=charId enabled=false}}
{{/baseEditDialog}}
{{/with}}
</template>

View File

@@ -0,0 +1,35 @@
Template.customBuffEdit.helpers({
buff: function(){
return CustomBuffs.findOne(this.buffId);
},
});
const debounce = (f) => _.debounce(f, 300);
Template.customBuffEdit.events({
"input #buffNameInput": debounce(function(event){
const input = event.currentTarget;
var name = input.value;
if (!name){
input.invalid = true;
input.errorMessage = "Name is required";
} else {
input.invalid = false;
CustomBuffs.update(this._id, {
$set: {name: name}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}
}),
"input #buffDescriptionInput": debounce(function(event){
var description = event.currentTarget.value;
CustomBuffs.update(this._id, {
$set: {description: description}
}, {
removeEmptyStrings: false,
trimStrings: false,
});
}),
});