From 298d89284428fa1565738c794a7fd691221145a7 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sat, 31 May 2025 01:02:47 -0500 Subject: [PATCH] converted powers dialog to applicationv2 --- src/module/powers/basePowers.js | 26 ++++++++++++++++++++------ src/module/preloadTemplates.js | 2 +- src/styles/swade-mb-helpers.scss | 20 ++++++++++++++++++++ src/templates/dialogHeader.html | 7 +++++++ src/templates/powerDialog.html | 11 ++--------- 5 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 src/templates/dialogHeader.html diff --git a/src/module/powers/basePowers.js b/src/module/powers/basePowers.js index 6ab60d4..3aaea2d 100644 --- a/src/module/powers/basePowers.js +++ b/src/module/powers/basePowers.js @@ -59,15 +59,22 @@ export class PowerFormApplication extends HandlebarsApplicationMixin(Application width: 600, height: 'auto', }, - classes: ['sheet', 'mbSwadeForm', 'mbSwadePowerEffectsForm'], + classes: ['standard-form', 'mbSwade', 'mbSwadeForm', 'mbSwadePowerEffectsForm'], window: { icon: 'fa-solid fa-hand-sparkles', - title: 'mbSwade.powerEffectsForm.title', + title: 'Apply Effect', }, }; static PARTS = { - body: { template: templates['powerDialog.html'] }, + header: { + template: templates['dialogHeader.html'], + classes: ['mbSwade', 'mbSwadeDialogHeader', 'flexrow'], + }, + body: { + template: templates['powerDialog.html'], + classes: ['mbSwadePowerEffectsBody'], + }, footer: { template: 'templates/generic/form-footer.hbs', classes: ['sheet-footer', 'flexrow'], @@ -111,6 +118,8 @@ export class PowerFormApplication extends HandlebarsApplicationMixin(Application } const data = { name: this.powerEffect.name, + headerTitle: `${this.powerEffect.name} Effect`, + headerSubtitle: `Apply the effects from ${this.powerEffect.name}`, icon: this.powerEffect.icon, basePowerPoints: this.powerEffect.basePowerPoints, modifiers, @@ -123,6 +132,10 @@ export class PowerFormApplication extends HandlebarsApplicationMixin(Application targets: [], buttons: this.powerEffect.menuButtons, }; + for (let button of data.buttons) { + button.action = button.value; + button.type = button.value === 'cancel' ? 'cancel' : 'submit'; + } if (this.powerEffect.isTargeted) { if (this.powerEffect.oneTarget) { data.targets = [this.powerEffect.targets?.[0]?.name ?? 'No Target Selected!']; @@ -141,9 +154,10 @@ export class PowerFormApplication extends HandlebarsApplicationMixin(Application } static async #onSubmit(event, form, formData) { - formData.submit = event?.submitter?.value ?? 'cancel'; - if (formData.submit !== 'cancel') { - this.powerEffect.formData = formData; + log(this.formData); + formData.object.submit = event?.submitter?.dataset?.action ?? 'cancel'; + if (formData.object.submit !== 'cancel') { + this.powerEffect.formData = formData.object; this.powerEffect.applyEffect(); } } diff --git a/src/module/preloadTemplates.js b/src/module/preloadTemplates.js index 928de81..9f60aab 100644 --- a/src/module/preloadTemplates.js +++ b/src/module/preloadTemplates.js @@ -1,4 +1,4 @@ -const _templatePaths = ['powerDialog.html', 'summonCosts.html']; +const _templatePaths = ['dialogHeader.html', 'powerDialog.html', 'summonCosts.html']; export async function preloadTemplates() { return loadTemplates(_templatePaths.map((f) => `modules/swade-mb-helpers/templates/${f}`)); diff --git a/src/styles/swade-mb-helpers.scss b/src/styles/swade-mb-helpers.scss index 650bf57..a5f385a 100644 --- a/src/styles/swade-mb-helpers.scss +++ b/src/styles/swade-mb-helpers.scss @@ -10,3 +10,23 @@ table.mbForm { padding-right: 0.25em; } } + +.mbSwade.mbSwadeDialogHeader { + align-items: flex-start; + + img.mbSwadeIcon { + margin-right: 1em; + } + + .mbSwadeTitle { + h2:has(+ p) { + margin-bottom: 0; + } + } +} + +.mbSwade.mbSwadeForm { + .mbSwadePowerEffectsBody { + margin-bottom: 0.5em; + } +} diff --git a/src/templates/dialogHeader.html b/src/templates/dialogHeader.html new file mode 100644 index 0000000..c004167 --- /dev/null +++ b/src/templates/dialogHeader.html @@ -0,0 +1,7 @@ +
+  +
+

{{headerTitle}}

+ {{#if headerSubtitle}}

{{headerSubtitle}}

{{/if}} +
+
diff --git a/src/templates/powerDialog.html b/src/templates/powerDialog.html index cd68bfa..de4775c 100644 --- a/src/templates/powerDialog.html +++ b/src/templates/powerDialog.html @@ -1,11 +1,4 @@ -
-
-  -
-

{{name}} Effect

-

Apply the affects of {{name}}.

-
-
+
{{#if extraDescription }}
{{{extraDescription}}} @@ -51,4 +44,4 @@ {{/if}}
{{/each}} -
+