FIX: minor fixes

This commit is contained in:
Joaquin Pereyra 2025-05-31 18:30:50 -03:00
parent 1f6bd4a2d3
commit 841c0804b6
3 changed files with 6 additions and 4 deletions

View file

@ -1 +1,2 @@
export { default as FormulaField } from "./formulaField.mjs" export { default as FormulaField } from "./formulaField.mjs";
export {default as ForeignDocumentUUIDField} from "./foreignDocumentUUIDField.mjs";

View file

@ -1,8 +1,9 @@
/** /**
* A class extending DocumentUUIDField to allow selecting a foreign document reference * A subclass of {@link foundry.data.fields.DocumentUUIDField} to allow selecting a foreign document reference
* that resolves to either the document, the index(for items in compenidums) or the UUID string. * that resolves to either the document, the index(for items in compenidums) or the UUID string.
*/ */
export default class ForeignDocumentUUIDField extends foundry.data.fields.DocumentUUIDField { export default class ForeignDocumentUUIDField extends foundry.data.fields.DocumentUUIDField {
/** @inheritdoc */
static get _defaults() { static get _defaults() {
return foundry.utils.mergeObject(super._defaults, { return foundry.utils.mergeObject(super._defaults, {
nullable: true, nullable: true,
@ -11,6 +12,7 @@ export default class ForeignDocumentUUIDField extends foundry.data.fields.Docume
}); });
} }
/**@override */
initialize(value, _model, _options = {}) { initialize(value, _model, _options = {}) {
if (this.idOnly) return value; if (this.idOnly) return value;
return () => { return () => {
@ -23,7 +25,7 @@ export default class ForeignDocumentUUIDField extends foundry.data.fields.Docume
} }
}; };
} }
/**@override */
toObject(value) { toObject(value) {
return value?.uuid ?? value; return value?.uuid ?? value;
} }

View file

@ -438,7 +438,6 @@
"documentTypes": { "documentTypes": {
"Actor": { "Actor": {
"pc": {}, "pc": {},
"npc": {},
"adversary": {}, "adversary": {},
"environment": {} "environment": {}
}, },