Fixed some editing bugs on new buffs, improved style
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
Template.customBuffEdit.helpers({
|
||||
buff(){
|
||||
return CustomBuffs.findOne(this.customBuffId);
|
||||
},
|
||||
});
|
||||
|
||||
const debounce = (f) => _.debounce(f, 300);
|
||||
|
||||
Template.customBuffEdit.events({
|
||||
@@ -9,7 +15,7 @@ Template.customBuffEdit.events({
|
||||
input.errorMessage = "Name is required";
|
||||
} else {
|
||||
input.invalid = false;
|
||||
CustomBuffs.update(this.buff._id, {
|
||||
CustomBuffs.update(this.customBuffId, {
|
||||
$set: {name: name}
|
||||
}, {
|
||||
removeEmptyStrings: false,
|
||||
@@ -19,7 +25,7 @@ Template.customBuffEdit.events({
|
||||
}),
|
||||
"input #buffDescriptionInput": debounce(function(event){
|
||||
var description = event.currentTarget.value;
|
||||
CustomBuffs.update(this.buff._id, {
|
||||
CustomBuffs.update(this.customBuffId, {
|
||||
$set: {description: description}
|
||||
}, {
|
||||
removeEmptyStrings: false,
|
||||
@@ -29,7 +35,13 @@ Template.customBuffEdit.events({
|
||||
"iron-select .target-dropdown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
var value = detail.item.getAttribute("name");
|
||||
if (value === this.buff.target) return;
|
||||
CustomBuffs.update(this.buff._id, {$set: {target: value}});
|
||||
const buff = CustomBuffs.findOne(this.customBuffId);
|
||||
if (value === buff.target) return;
|
||||
CustomBuffs.update(this.customBuffId, {$set: {target: value}});
|
||||
},
|
||||
"click #deleteButton": function(event, instance){
|
||||
CustomBuffs.softRemoveNode(instance.data.customBuffId);
|
||||
GlobalUI.deletedToast(instance.data.customBuffId, "Buffs", "Buff");
|
||||
popDialogStack();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
</template>
|
||||
|
||||
<template name="customBuffEditListItem">
|
||||
<tr class="buff" data-id={{buff._id}}>
|
||||
<div class="buff layout horizontal center" data-id={{buff._id}}>
|
||||
{{> customBuffView buff=buff}}
|
||||
<td>
|
||||
<div>
|
||||
<paper-icon-button class="edit-buff" icon="create">
|
||||
</paper-icon-button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -14,7 +14,7 @@ Template.customBuffEditList.events({
|
||||
this.enabled = true;
|
||||
}
|
||||
const customBuffId = CustomBuffs.insert({
|
||||
name: "New Buff",
|
||||
name: this.name || "New Buff",
|
||||
charId: this.charId,
|
||||
parent: {
|
||||
id: this.parentId,
|
||||
@@ -23,7 +23,7 @@ Template.customBuffEditList.events({
|
||||
});
|
||||
pushDialogStack({
|
||||
template: "customBuffEdit",
|
||||
data: {id: customBuffId},
|
||||
data: {customBuffId},
|
||||
element: event.currentTarget,
|
||||
returnElement: () => instance.find(`tr.buff[data-id='${customBuffId}']`),
|
||||
});
|
||||
@@ -34,8 +34,8 @@ Template.customBuffEditListItem.events({
|
||||
"tap .edit-buff": function(event, template){
|
||||
pushDialogStack({
|
||||
template: "customBuffEdit",
|
||||
data: {buff: this.buff},
|
||||
data: {customBuffId: this.buff._id},
|
||||
element: event.currentTarget.parentElement.parentElement,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template name="customBuffView">
|
||||
<td>{{buff.name}}</td>
|
||||
<td>
|
||||
<div class="flex">{{buff.name}}</div>
|
||||
<div class="flex">
|
||||
{{#if canEditCharacter buff.charId}}
|
||||
<paper-button class="apply-buff-button">Apply{{toSelf}}</paper-button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -41,7 +41,16 @@ const applyBuff = function(targetId, buff) {
|
||||
|
||||
Proficiencies.insert(temp);
|
||||
});
|
||||
}
|
||||
|
||||
let target;
|
||||
if (targetId == buff.charId) {
|
||||
target = "self";
|
||||
} else {
|
||||
target = Characters.findOne(targetId) || {};
|
||||
target = target && target.name || "target"
|
||||
}
|
||||
GlobalUI.toast(`${buff.name || "Buff"} applied to ${target}`);
|
||||
};
|
||||
|
||||
Template.customBuffView.helpers({
|
||||
toSelf: function() {
|
||||
@@ -65,10 +74,9 @@ Template.customBuffView.events({
|
||||
applyBuff(targetId, this.buff);
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var targetId = this.buff.charId;
|
||||
applyBuff(targetId, this.buff);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
Buffs
|
||||
</div>
|
||||
{{#each buff in buffs}}
|
||||
{{> customBuffView buff=buff}}
|
||||
<div class="layout horizontal center">
|
||||
{{> customBuffView buff=buff}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
{{#if description}}
|
||||
<div class="bottom flex">
|
||||
{{#markdown}}{{evaluateShortString charId description}}{{/markdown}}
|
||||
{{> customBuffViewList charId=charId parentId=_id}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if hasUses}}
|
||||
@@ -159,4 +160,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -34,7 +34,6 @@ Template.characterSideList.helpers({
|
||||
},
|
||||
isOpen(id) {
|
||||
var openedParties = Template.instance().openedParties.get();
|
||||
console.log(openedParties);
|
||||
return openedParties.has(id);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user