start converting main power dialog to applicationv2
This commit is contained in:
parent
669c3799a0
commit
a47b765c6f
@ -40,52 +40,39 @@ function _hashCode(str) {
|
|||||||
return Math.abs(hash);
|
return Math.abs(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PowerFormApplicationV2 extends HandlebarsApplicationMixin(ApplicationV2) {
|
export class PowerFormApplication extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
constructor(powerEffect) {
|
constructor(powerEffect) {
|
||||||
super();
|
|
||||||
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
|
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
|
||||||
this.options.id = `${this.options.id}${name}`;
|
const id = `${PowerFormApplication.DEFAULT_OPTIONS.id}${name}`;
|
||||||
|
super({ id });
|
||||||
this.powerEffect = powerEffect;
|
this.powerEffect = powerEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
id: ['mbSwadePowerEffectsApplicationV2'],
|
id: 'mbSwadePowerEffectsApplicationV2',
|
||||||
form: {
|
form: {
|
||||||
handler: PowerFormApplicationV2.#onSubmit,
|
handler: PowerFormApplication.#onSubmit,
|
||||||
closeOnSubmit: true,
|
closeOnSubmit: true,
|
||||||
},
|
},
|
||||||
tag: 'form',
|
tag: 'form',
|
||||||
position: {
|
position: {
|
||||||
width: 400,
|
width: 600,
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
},
|
},
|
||||||
|
classes: ['sheet', 'mbSwadeForm', 'mbSwadePowerEffectsForm'],
|
||||||
window: {
|
window: {
|
||||||
icon: 'fas fa-gear',
|
icon: 'fa-solid fa-hand-sparkles',
|
||||||
title: 'mbSwade.powerEffectsForm.title',
|
title: 'mbSwade.powerEffectsForm.title',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static #onSubmit(event, form, formData) {}
|
static PARTS = {
|
||||||
}
|
body: { template: templates['powerDialog.html'] },
|
||||||
|
footer: {
|
||||||
export class PowerFormApplication extends FormApplication {
|
template: 'templates/generic/form-footer.hbs',
|
||||||
constructor(powerEffect) {
|
classes: ['sheet-footer', 'flexrow'],
|
||||||
super();
|
},
|
||||||
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
|
};
|
||||||
this.options.id = `${this.options.id}${name}`;
|
|
||||||
this.powerEffect = powerEffect;
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultOptions() {
|
|
||||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
|
||||||
classes: ['sheet', 'mbSwadeForm', 'mbSwadePowerEffectsForm'],
|
|
||||||
popOut: true,
|
|
||||||
template: templates['powerDialog.html'],
|
|
||||||
id: ['mbSwadePowerEffectsApplication'],
|
|
||||||
title: 'Power Effects',
|
|
||||||
width: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static sortMods(a, b) {
|
static sortMods(a, b) {
|
||||||
if (a.isGlobal !== b.isGlobal) {
|
if (a.isGlobal !== b.isGlobal) {
|
||||||
@ -100,7 +87,7 @@ export class PowerFormApplication extends FormApplication {
|
|||||||
return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
|
return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
getData() {
|
_prepareContext() {
|
||||||
let modifiers = foundry.utils.deepClone(this.powerEffect.modifiers);
|
let modifiers = foundry.utils.deepClone(this.powerEffect.modifiers);
|
||||||
modifiers.sort(PowerFormApplication.sortMods);
|
modifiers.sort(PowerFormApplication.sortMods);
|
||||||
for (const modifier of modifiers) {
|
for (const modifier of modifiers) {
|
||||||
@ -153,8 +140,8 @@ export class PowerFormApplication extends FormApplication {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _updateObject(ev, formData) {
|
static async #onSubmit(event, form, formData) {
|
||||||
formData.submit = ev?.submitter?.value ?? 'cancel';
|
formData.submit = event?.submitter?.value ?? 'cancel';
|
||||||
if (formData.submit !== 'cancel') {
|
if (formData.submit !== 'cancel') {
|
||||||
this.powerEffect.formData = formData;
|
this.powerEffect.formData = formData;
|
||||||
this.powerEffect.applyEffect();
|
this.powerEffect.applyEffect();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<form class="flexcol"><!-- vim: set ft=handlebars.html: -->
|
<div class="standard-form"><!-- vim: set ft=handlebars.html: -->
|
||||||
<header class="sheet-header flexrow">
|
<header class="flexrow">
|
||||||
<img src="{{icon}}" height="64" width="64" title="{{name}} Effect" alt=" " />
|
<img src="{{icon}}" height="64" width="64" class="flex0" title="{{name}} Effect" alt=" " />
|
||||||
<section class="flexcol">
|
<section class="flexcol">
|
||||||
<h2>{{name}} Effect</h2>
|
<h2>{{name}} Effect</h2>
|
||||||
<p>Apply the affects of {{name}}.</p>
|
<p>Apply the affects of {{name}}.</p>
|
||||||
@ -39,16 +39,11 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if isNumber}}
|
{{#if isNumber}}
|
||||||
<label for="{{id}}">{{#if epic}}⭐ {{/if}}{{name}}:</label>
|
<label for="{{id}}">{{#if epic}}⭐ {{/if}}{{name}}:</label>
|
||||||
<input name="{{id}}"
|
<input name="{{id}}" type="number" value="{{default}}" {{#if step}}step="{{step}}" {{/if}} {{#if min}}min="{{min}}"
|
||||||
type="number"
|
{{/if}} {{#if max}}max="{{max}}" {{/if}}>
|
||||||
value="{{default}}"
|
|
||||||
{{#if step}}step="{{step}}"{{/if}}
|
|
||||||
{{#if min}}min="{{min}}"{{/if}}
|
|
||||||
{{#if max}}max="{{max}}"{{/if}}
|
|
||||||
>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if isSelect}}
|
{{#if isSelect}}
|
||||||
<label>{{#if epic}}⭐ {{/if}}{{name}}:</label>
|
<label for="{{id}}">{{#if epic}}⭐ {{/if}}{{name}}:</label>
|
||||||
<select name="{{id}}">{{selectOptions choices selected=default}}</select>
|
<select name="{{id}}">{{selectOptions choices selected=default}}</select>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if isRadio}}
|
{{#if isRadio}}
|
||||||
@ -56,9 +51,4 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<footer class="sheet-footer flexrow">
|
</div>
|
||||||
{{#each buttons}}
|
|
||||||
<button type="submit" name="submit" value="{{value}}">{{label}}</button>
|
|
||||||
{{/each}}
|
|
||||||
</footer>
|
|
||||||
</form>
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user