Refactor the handlebars helpers to namespace using dd instead of dotdungeon because it's so long
This commit is contained in:
parent
d4531f089a
commit
38952c61b4
11 changed files with 52 additions and 39 deletions
|
|
@ -5,10 +5,11 @@ import { objectValue } from "./objectValue.mjs";
|
|||
import { toFriendlyDuration } from "./toFriendlyDuration.mjs";
|
||||
|
||||
export default {
|
||||
"dotdungeon-schemaOptions": schemaOptions,
|
||||
"dotdungeon-array": createArray,
|
||||
"dotdungeon-toFriendlyDuration": toFriendlyDuration,
|
||||
"dotdungeon-objectValue": objectValue,
|
||||
"dotdungeon-stringify": v => JSON.stringify(v, null, ` `),
|
||||
"dotdungeon-expanded": detailsExpanded,
|
||||
"dd-schemaOptions": schemaOptions,
|
||||
"dd-array": createArray,
|
||||
"dd-toFriendlyDuration": toFriendlyDuration,
|
||||
"dd-objectValue": objectValue,
|
||||
"dd-expanded": detailsExpanded,
|
||||
"dd-stringify": v => JSON.stringify(v, null, ` `),
|
||||
"dd-negate": v => !v,
|
||||
};
|
||||
|
|
@ -21,25 +21,42 @@ export class GenericActorSheet extends ActorSheet {
|
|||
|
||||
ctx.meta = {
|
||||
expanded: this._expanded,
|
||||
idp: this.actor.uuid,
|
||||
};
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (this.document.isEmbedded) return;
|
||||
if (!this.isEditable) return;
|
||||
console.debug(`.dungeon | Generic sheet adding listeners`);
|
||||
|
||||
html.find(`.roll`).on(`click`, this._handleRoll);
|
||||
html.find(`summary`).on(`click`, this._handleSummaryToggle);
|
||||
html.find(`summary`).on(`click`, this._handleSummaryToggle.bind(this));
|
||||
html.find(`.roll`).on(`click`, this._handleRoll.bind(this));
|
||||
};
|
||||
|
||||
async _handleRoll($e) {
|
||||
let data = $e.target.dataset;
|
||||
if (!data.roll) return;
|
||||
console.debug(`.dungeon | Attempting to roll with formula "${data.roll}"`);
|
||||
|
||||
game.i18n
|
||||
|
||||
let roll = new Roll(data.roll);
|
||||
await roll.evaluate();
|
||||
await roll.toMessage({
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||
});
|
||||
};
|
||||
|
||||
_handleSummaryToggle($e) {
|
||||
let data = $e.target.dataset;
|
||||
let open = $e.target.parentNode.open;
|
||||
console.debug(`.dungeon | Collapse ID: ${data.collapseId} (open: ${open})`);
|
||||
|
||||
/*
|
||||
This seeming inversion of logic is due to the fact that this handler
|
||||
gets called before the element is updated to include/reflect the
|
||||
|
|
@ -51,12 +68,5 @@ export class GenericActorSheet extends ActorSheet {
|
|||
} else {
|
||||
this._expanded.delete(data.collapseId);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
_handleRoll($e) {
|
||||
let data = $e.target.dataset;
|
||||
if (!data.roll) return;
|
||||
console.debug(`.dungeon | Attempting to roll ${data.roll}`);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
@ -22,9 +22,6 @@ export class PlayerSheet extends GenericActorSheet {
|
|||
/*
|
||||
Toggles the expanded state for the detail elements in the sheet.
|
||||
*/
|
||||
html.find(`summary`).on(`click`, ($e) => {
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
#syncValue() {
|
||||
|
|
@ -47,12 +44,12 @@ export class PlayerSheet extends GenericActorSheet {
|
|||
canChangeGroup: ctx.settings.playersCanChangeGroup || ctx.isGM,
|
||||
};
|
||||
|
||||
ctx.meta.idp = this.actor.uuid;
|
||||
|
||||
console.groupCollapsed(`PlayerSheet.getData`);
|
||||
console.log(`ctx`, ctx);
|
||||
console.log(`actor`, actor);
|
||||
console.groupEnd();
|
||||
return ctx;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { GenericSheet } from "../GenericSheet.mjs";
|
||||
import { GenericActorSheet } from "../GenericActorSheet.mjs";
|
||||
|
||||
export class AbstractSyncSheet extends GenericSheet {
|
||||
export class AbstractSyncSheet extends GenericActorSheet {
|
||||
static get defaultOptions() {
|
||||
let opts = mergeObject(
|
||||
super.defaultOptions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue