64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
|
|
|
export class CultureSheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
|
|
|
/** @inheritDoc */
|
|
static DEFAULT_OPTIONS = {
|
|
position: {width: 520, height: 480},
|
|
classes: ['dsa41', 'sheet', 'item', 'culture'],
|
|
tag: 'form',
|
|
form: {
|
|
submitOnChange: true,
|
|
closeOnSubmit: false,
|
|
handler: CultureSheet.#onSubmitForm
|
|
},
|
|
actions: {
|
|
editImage: DocumentSheetV2.DEFAULT_OPTIONS.actions.editImage,
|
|
}
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
static PARTS = {
|
|
form: {
|
|
template: `systems/DSA_4-1/templates/item/culture-sheet.hbs`
|
|
},
|
|
}
|
|
|
|
_configureRenderOptions(options) {
|
|
super._configureRenderOptions(options)
|
|
|
|
if (options.window) {
|
|
options.window.title = this.document.name
|
|
}
|
|
|
|
return options
|
|
}
|
|
|
|
/**
|
|
* Handle form submission
|
|
* @this {CultureSheet}
|
|
* @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)
|
|
context.system = context.document.system
|
|
|
|
context.name = context.document.name
|
|
context.img = context.document.img
|
|
context.description = context.document.system.description
|
|
context.masculineDemonym = context.document.system.masculineDemonym
|
|
context.feminineDemonym = context.document.system.feminineDemonym
|
|
|
|
return context
|
|
}
|
|
} |