Add incrementer button support for item sheets
This commit is contained in:
parent
96b24d6445
commit
d8b676535f
1 changed files with 31 additions and 7 deletions
|
|
@ -10,13 +10,6 @@ export class GenericItemSheet extends ItemSheet {
|
||||||
`resourcesOrSupplies`,
|
`resourcesOrSupplies`,
|
||||||
];
|
];
|
||||||
|
|
||||||
activateListeners(html) {
|
|
||||||
super.activateListeners(html);
|
|
||||||
|
|
||||||
if (!this.isEditable) return;
|
|
||||||
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const ctx = {};
|
const ctx = {};
|
||||||
|
|
||||||
|
|
@ -42,4 +35,35 @@ export class GenericItemSheet extends ItemSheet {
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
if (!this.isEditable) return;
|
||||||
|
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
|
||||||
|
html.find(`button[data-increment]`)
|
||||||
|
.on(`click`, this._incrementValue.bind(this));
|
||||||
|
html.find(`button[data-decrement]`)
|
||||||
|
.on(`click`, this._decrementValue.bind(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
async _incrementValue($e) {
|
||||||
|
const target = $e.currentTarget;
|
||||||
|
const data = target.dataset;
|
||||||
|
const value = getProperty(this.actor, data.increment);
|
||||||
|
if (typeof value != "number") {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
this.actor.update({ [data.increment]: value + 1 });
|
||||||
|
};
|
||||||
|
|
||||||
|
async _decrementValue($e) {
|
||||||
|
const target = $e.currentTarget;
|
||||||
|
const data = target.dataset;
|
||||||
|
const value = getProperty(this.actor, data.decrement);
|
||||||
|
if (typeof value != "number") {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
this.actor.update({ [data.decrement]: value - 1 });
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue