mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Bug/124 foreigndocumentuuidfields fail initial initialization (#150)
* FIX: Remove the psudo-documents because they will be used. * FIX: ForeignDocumentUUIDField initialize like a getter FEAT: ForeignDocumentUUIDArrayField created and used * REFACTOR: prettier format --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
parent
96ed90b5fc
commit
a0a5196825
20 changed files with 33 additions and 632 deletions
|
|
@ -1 +0,0 @@
|
|||
export {default as PseudoDocumentSheet }from "./pseudo-documents-sheet.mjs";
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class PseudoDocumentSheet extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.#pseudoDocument = options.document;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID of the associated pseudo-document
|
||||
* @type {string}
|
||||
*/
|
||||
get pseudoUuid() {
|
||||
return this.pseudoDocument.uuid;
|
||||
}
|
||||
|
||||
#pseudoDocument;
|
||||
|
||||
/**
|
||||
* The pseudo-document instance this sheet represents
|
||||
* @type {object}
|
||||
*/
|
||||
get pseudoDocument() {
|
||||
return this.#pseudoDocument;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'sheet'],
|
||||
position: { width: 600 },
|
||||
form: {
|
||||
handler: PseudoDocumentSheet.#onSubmitForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
header: { template: 'systems/daggerheart/templates/sheets/pseudo-documents/header.hbs' },
|
||||
};
|
||||
|
||||
/** @inheritDoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
const document = this.pseudoDocument;
|
||||
return Object.assign(context, {
|
||||
document,
|
||||
source: document._source,
|
||||
editable: this.isEditable,
|
||||
user: game.user,
|
||||
rootId: this.id,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler
|
||||
* @param {SubmitEvent | Event} event - The originating form submission or input change event
|
||||
* @param {HTMLFormElement} form - The form element that was submitted
|
||||
* @param {foundry.applications.ux.FormDataExtended} formData - Processed data for the submitted form
|
||||
*/
|
||||
static async #onSubmitForm(event, form, formData) {
|
||||
const submitData = foundry.utils.expandObject(formData.object);
|
||||
await this.pseudoDocument.update(submitData);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue