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:
joaquinpereyra98 2025-06-18 10:47:50 -03:00 committed by GitHub
parent 96ed90b5fc
commit a0a5196825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 33 additions and 632 deletions

View file

@ -12,6 +12,4 @@ export { default as DhpWeapon } from './sheets/items/weapon.mjs';
export { default as DhpArmor } from './sheets/items/armor.mjs';
export { default as DhpChatMessage } from './chatMessage.mjs';
export { default as DhpEnvironment } from './sheets/environment.mjs';
export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs';
export * as pseudoDocumentSheet from './sheets/pseudo-documents/_module.mjs';
export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs';

View file

@ -1 +0,0 @@
export {default as PseudoDocumentSheet }from "./pseudo-documents-sheet.mjs";

View file

@ -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);
}
}