From c354c01f8d57b021f21c4c85d02cf2f2452379ac Mon Sep 17 00:00:00 2001 From: cadowtin Date: Tue, 6 Aug 2024 02:38:10 -0500 Subject: [PATCH] uncommented issues --- scripts/helpers/misc.js | 240 ++++++++++++++++++++-------------------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/scripts/helpers/misc.js b/scripts/helpers/misc.js index 835a3c6..0ff46c0 100644 --- a/scripts/helpers/misc.js +++ b/scripts/helpers/misc.js @@ -93,127 +93,127 @@ function transformData(dataArray) { return { settings: result }; } -// export class FinisherDialog extends ApplicationV2 { -// static DEFAULT_OPTIONS = { -// id: "pf2e-rpg-numbers-actor", -// tag: "form", //use for form -// form: { -// handler: FinisherDialog.myFormHandler, -// submitOnChange: false, -// closeOnSubmit: true, -// }, -// position: { -// width: 640, -// height: "auto", -// }, -// window: { -// icon: "fas fa-gear", // You can now add an icon to the header -// title: "FOO.form.title", -// contentClasses: ["standard-form"], -// }, -// }; -// static PARTS = { -// foo: { -// template: "modules/pf2e-rpg-numbers/templates/actor-finisher.html", -// }, -// footer: { -// template: "templates/generic/form-footer.hbs", -// }, -// }; +export class FinisherDialog extends ApplicationV2 { + static DEFAULT_OPTIONS = { + id: "pf2e-rpg-numbers-actor", + tag: "form", //use for form + form: { + handler: FinisherDialog.myFormHandler, + submitOnChange: false, + closeOnSubmit: true, + }, + position: { + width: 640, + height: "auto", + }, + window: { + icon: "fas fa-gear", // You can now add an icon to the header + title: "FOO.form.title", + contentClasses: ["standard-form"], + }, + }; + static PARTS = { + foo: { + template: "modules/pf2e-rpg-numbers/templates/actor-finisher.html", + }, + footer: { + template: "templates/generic/form-footer.hbs", + }, + }; -// get title() { -// return `PF2e RPG #s: Actor Config`; -// } - -// /** -// * Process form submission for the sheet -// * @this {MyApplication} The handler is called with the application as its bound scope -// * @param {SubmitEvent} event The originating form submission event -// * @param {HTMLFormElement} form The form element that was submitted -// * @param {FormDataExtended} formData Processed data for the submitted form -// * @returns {Promise} -// */ -// static async myFormHandler(_event, _form, formData) { -// // Do things with the returned FormData - -// const items = []; -// const color = formData.get("color"); - -// for (const [key, value] of formData.entries()) { -// if (key.startsWith("predicate.")) { -// const index = key.split(".")[1]; -// items[index] = items[index] || {}; -// items[index].predicate = value; -// } else if (key.startsWith("onlyCrit.")) { -// const index = key.split(".")[1]; -// items[index] = items[index] || {}; -// items[index].onlyCrit = formData.get(key) === "on"; -// } else if (key.startsWith("finisherText.")) { -// const index = key.split(".")[1]; -// items[index] = items[index] || {}; -// items[index].finisherText = value; -// } -// } - -// const finisherData = { -// color: color, -// items: items.filter((item) => item !== null), -// }; - -// await this.actor.setFlag(MODULE_ID, "finisherData", finisherData); -// } -// constructor(actor, options = {}) { -// super(options); -// this.actor = actor; -// } - -// static get defaultOptions() { -// return mergeObject(super.defaultOptions, { -// id: "finisher-dialog", -// title: "Finisher Settings", -// template: "modules/pf2e-rpg-numbers/templates/actor-finisher.html", -// width: 600, -// submitOnChange: false, -// closeOnSubmit: true, -// }); -// } - -// _prepareContext(actor) { -// const finisherData = actor.getFlag(MODULE_ID, "finisherData") || { color: "#000000", items: [] }; -// return { -// color: finisherData.color, -// items: finisherData.items, -// actor, -// buttons: [{ type: "submit", icon: "fa-solid fa-save", label: "SETTINGS.Save" }], -// }; -// } - -// _onRender(_context, _options) { -// this.element.find(".add-row").on("click", this._onAddRow.bind(this)); -// this.element.on("click", ".delete-row", this._onDeleteRow.bind(this)); -// } - -// _onAddRow(event) { -// const items = this.element.find(".finisher-item").length; -// const newRow = ` -//
-// -// -// -// -//
-// `; -// this.element.find(".finisher-items").append(newRow); -// } - -// async _onDeleteRow(event) { -// event.preventDefault(); -// let r = await Dialog.confirm({title: "Delete Row of Finishing Moves", content: "Are you sure you want to delete this row?"}); -// if (r) { -// event.target.closest(".finisher-item").remove(); -// } -// } -// } + get title() { + return `PF2e RPG #s: Actor Config`; + } + + /** + * Process form submission for the sheet + * @this {MyApplication} The handler is called with the application as its bound scope + * @param {SubmitEvent} event The originating form submission event + * @param {HTMLFormElement} form The form element that was submitted + * @param {FormDataExtended} formData Processed data for the submitted form + * @returns {Promise} + */ + static async myFormHandler(_event, _form, formData) { + // Do things with the returned FormData + + const items = []; + const color = formData.get("color"); + + for (const [key, value] of formData.entries()) { + if (key.startsWith("predicate.")) { + const index = key.split(".")[1]; + items[index] = items[index] || {}; + items[index].predicate = value; + } else if (key.startsWith("onlyCrit.")) { + const index = key.split(".")[1]; + items[index] = items[index] || {}; + items[index].onlyCrit = formData.get(key) === "on"; + } else if (key.startsWith("finisherText.")) { + const index = key.split(".")[1]; + items[index] = items[index] || {}; + items[index].finisherText = value; + } + } + + const finisherData = { + color: color, + items: items.filter((item) => item !== null), + }; + + await this.actor.setFlag(MODULE_ID, "finisherData", finisherData); + } + constructor(actor, options = {}) { + super(options); + this.actor = actor; + } + + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + id: "finisher-dialog", + title: "Finisher Settings", + template: "modules/pf2e-rpg-numbers/templates/actor-finisher.html", + width: 600, + submitOnChange: false, + closeOnSubmit: true, + }); + } + + _prepareContext(actor) { + const finisherData = actor.getFlag(MODULE_ID, "finisherData") || { color: "#000000", items: [] }; + return { + color: finisherData.color, + items: finisherData.items, + actor, + buttons: [{ type: "submit", icon: "fa-solid fa-save", label: "SETTINGS.Save" }], + }; + } + + _onRender(_context, _options) { + this.element.find(".add-row").on("click", this._onAddRow.bind(this)); + this.element.on("click", ".delete-row", this._onDeleteRow.bind(this)); + } + + _onAddRow(event) { + const items = this.element.find(".finisher-item").length; + const newRow = ` +
+ + + + +
+ `; + this.element.find(".finisher-items").append(newRow); + } + + async _onDeleteRow(event) { + event.preventDefault(); + let r = await Dialog.confirm({title: "Delete Row of Finishing Moves", content: "Are you sure you want to delete this row?"}); + if (r) { + event.target.closest(".finisher-item").remove(); + } + } +} // export function exportDebugInfo() { // const settingsInfo = [...game.settings.settings.values()]