Feature/116-implementation-of-pseudo-documents (#125)

* FEAT: add baseDataModel logic

* FEAT: new PseudoDocumentsField
FIX: BasePseudoDocument 's getEmbeddedDocument

* FEAT: PseudoDocument class

* FEAT: add TypedPseudoDocument
REFACTOR: PreudoDocument
FIX: Typos Bug

* FIX: CONFIG types

* FEAT: basic PseudoDocumentSheet

* FIX: remove schema
ADD: input of example

---------

Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
joaquinpereyra98 2025-06-13 08:51:33 -03:00 committed by GitHub
parent 3a0a4673ad
commit f840dc2553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 844 additions and 190 deletions

View file

@ -1,8 +1,7 @@
import { actionsTypes } from "../action/_module.mjs";
import { actionsTypes } from '../action/_module.mjs';
// Temporary Solution
export default class ActionField extends foundry.data.fields.ObjectField {
getModel(value) {
return actionsTypes[value.type] ?? actionsTypes.attack;
}
@ -11,10 +10,10 @@ export default class ActionField extends foundry.data.fields.ObjectField {
/** @override */
_cleanType(value, options) {
if ( !(typeof value === "object") ) value = {};
if (!(typeof value === 'object')) value = {};
const cls = this.getModel(value);
if ( cls ) return cls.cleanData(value, options);
if (cls) return cls.cleanData(value, options);
return value;
}
@ -23,7 +22,7 @@ export default class ActionField extends foundry.data.fields.ObjectField {
/** @override */
initialize(value, model, options = {}) {
const cls = this.getModel(value);
if ( cls ) return new cls(value, { parent: model, ...options });
if (cls) return new cls(value, { parent: model, ...options });
return foundry.utils.deepClone(value);
}
@ -36,6 +35,6 @@ export default class ActionField extends foundry.data.fields.ObjectField {
*/
migrateSource(sourceData, fieldData) {
const cls = this.getModel(fieldData);
if ( cls ) cls.migrateDataSafe(fieldData);
if (cls) cls.migrateDataSafe(fieldData);
}
}
}