Files
DeltaGreen/module/base-sheet.js
T
jalensailin 58939386ce initial work to move actor sheets to appv2;
adds a more generic base-sheet from which to extend
2025-07-18 22:47:28 -04:00

53 lines
1.4 KiB
JavaScript

import DG from "./config.js";
const HbsAppMixin = foundry.applications.api.HandlebarsApplicationMixin;
const DGSheetMixin = (Base) => {
return class DGDocumentSheet extends HbsAppMixin(Base) {
/** @inheritdoc */
static DEFAULT_OPTIONS = /** @type {const} */ ({
window: { resizable: true },
classes: [DG.ID, "sheet"],
form: { submitOnChange: true },
});
/** @inheritdoc */
static TEMPLATE_PATH = /** @type {const} */ (`systems/${DG.ID}/templates`);
/** @inheritdoc */
async _prepareContext(options) {
const context = await super._prepareContext(options);
const docName = this.document.documentName.toLowerCase();
// Add the document to the context under a descriptive name (i.e. "actor", "item")
context[docName] = this.document;
return context;
}
/** @inheritdoc */
async _onRender(context, options) {
await super._onRender(context, options);
const html = this.element;
// Double-click resize handle to reset sheet to original size.
html
.querySelector(".window-resize-handle")
.addEventListener("dblclick", () => {
this.resetPosition();
});
}
/**
* Resets the window's position to its default, as specified in the Sheet's options.
* @returns {void}
*/
resetPosition() {
this.setPosition(this.options.position);
}
};
};
export default DGSheetMixin;