update summonCosts application
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
/* globals Sequencer */
|
||||
import { log, moduleHelpers, moduleName, settingKeys } from '../globals.js';
|
||||
import { log, moduleName } from '../globals.js';
|
||||
import { templates } from '../preloadTemplates.js';
|
||||
import { ActorFolderEffect } from './basePowers.js';
|
||||
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export class BaseSummonEffect extends ActorFolderEffect {
|
||||
get name() {
|
||||
return 'Base Summon';
|
||||
@@ -62,25 +64,46 @@ export class BaseSummonEffect extends ActorFolderEffect {
|
||||
}
|
||||
}
|
||||
|
||||
export class SummonCostApplication extends FormApplication {
|
||||
export class SummonCostApplication extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actors, powers) {
|
||||
super();
|
||||
this.actors = actors;
|
||||
this.powers = powers;
|
||||
this.object = {};
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ['sheet', 'mbSwade', 'mbSwadeForm', 'mbSwadeSummonCostForm'],
|
||||
popOut: true,
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: 'mbSwadeSummonCostApplication',
|
||||
form: {
|
||||
handler: SummonCostApplication.#onSubmit,
|
||||
closeOnSubmit: true,
|
||||
},
|
||||
tag: 'form',
|
||||
position: {
|
||||
width: 800,
|
||||
height: 'auto',
|
||||
},
|
||||
classes: ['mbSwade', 'mbSwadeForm', 'mbSwadeSummonCostForm'],
|
||||
window: {
|
||||
title: 'Set Summoning Costs',
|
||||
},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
header: {
|
||||
template: templates['dialogHeader.html'],
|
||||
classes: ['mbSwade', 'mbSwadeDialogHeader', 'mbSwadeSummonCostsHeader'],
|
||||
},
|
||||
body: {
|
||||
template: templates['summonCosts.html'],
|
||||
id: ['mbSwadeSummonCostFormApplication'],
|
||||
title: 'Summoning Costs',
|
||||
width: 750,
|
||||
});
|
||||
}
|
||||
classes: ['mbSwade', 'mbSwadePowerEffectsBody', 'scrollable'],
|
||||
},
|
||||
footer: {
|
||||
template: 'templates/generic/form-footer.hbs',
|
||||
},
|
||||
};
|
||||
|
||||
getData() {
|
||||
async _prepareContext() {
|
||||
const actorNames = Object.keys(this.actors).map((k) => {
|
||||
let splitName = k.split(' | ');
|
||||
splitName.pop();
|
||||
@@ -96,8 +119,15 @@ export class SummonCostApplication extends FormApplication {
|
||||
return 0;
|
||||
});
|
||||
const data = {
|
||||
name: 'Set Summon Costs',
|
||||
formId: foundry.utils.randomID(),
|
||||
headerTitle: 'Set Summon Costs',
|
||||
powers: this.powers,
|
||||
actors: [],
|
||||
buttons: [
|
||||
{ type: 'submit', icon: 'fa-solid fa-save', label: 'SETTINGS.Save' },
|
||||
{ type: 'cancel', icon: 'fa-solid fa-ban', label: 'SETTINGS.Cancel' },
|
||||
],
|
||||
};
|
||||
for (const actor of actorNames) {
|
||||
const summon = this.actors[actor.fullName].getFlag(moduleName, 'summonData') ?? {
|
||||
@@ -118,12 +148,13 @@ export class SummonCostApplication extends FormApplication {
|
||||
return data;
|
||||
}
|
||||
|
||||
async _updateObject(ev, formData) {
|
||||
const submit = ev?.submitter?.value ?? 'cancel';
|
||||
static async #onSubmit(event, form, formData) {
|
||||
const submit = event?.submitter?.value ?? 'cancel';
|
||||
if (submit === 'cancel') {
|
||||
return;
|
||||
}
|
||||
log('FORMDATA |', formData);
|
||||
formData = formData.object;
|
||||
const updates = {};
|
||||
for (const key of Object.keys(formData)) {
|
||||
const value = formData[key];
|
||||
|
||||
Reference in New Issue
Block a user