63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
|
|
|
export class LiturgySheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
|
|
|
/** @inheritDoc */
|
|
static DEFAULT_OPTIONS = {
|
|
position: {width: 520, height: 480},
|
|
classes: ['dsa41', 'sheet', 'item', 'liturgy'],
|
|
tag: 'form',
|
|
form: {
|
|
submitOnChange: true,
|
|
closeOnSubmit: false,
|
|
handler: LiturgySheet.#onSubmitForm
|
|
},
|
|
}
|
|
|
|
|
|
static TABS = {
|
|
sheet: {
|
|
tabs: [
|
|
{id: 'json', group: 'sheet', label: 'JSON'},
|
|
],
|
|
initial: 'json'
|
|
}
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
static PARTS = {
|
|
form: {
|
|
template: `systems/DSA_4-1/templates/item/liturgy/main-sheet.hbs`
|
|
},
|
|
json: {
|
|
template: `systems/DSA_4-1/templates/item/liturgy/tab-json.hbs`
|
|
},
|
|
}
|
|
|
|
/**
|
|
* Handle form submission
|
|
* @this {EquipmentSheet}
|
|
* @param {SubmitEvent} event
|
|
* @param {HTMLFormElement} form
|
|
* @param {FormDataExtended} formData
|
|
*/
|
|
static async #onSubmitForm(event, form, formData) {
|
|
event.preventDefault()
|
|
|
|
await this.document.update(formData.object) // Note: formData.object
|
|
}
|
|
|
|
/** @override */
|
|
async _prepareContext(options) {
|
|
const context = await super._prepareContext(options);
|
|
|
|
const liturgyData = context.document;
|
|
|
|
context.system = liturgyData.system;
|
|
context.flags = liturgyData.flags;
|
|
context.json = JSON.stringify(liturgyData);
|
|
return context;
|
|
}
|
|
|
|
}
|