FIX: CONFIG types

This commit is contained in:
Joaquin Pereyra 2025-06-11 13:43:11 -03:00
parent 88bf26dad0
commit 27777dddba
7 changed files with 77 additions and 30 deletions

View file

@ -4,13 +4,13 @@ import SheetManagementMixin from './sheetManagementMixin.mjs';
/** @extends BasePseudoDocument */
export default class PseudoDocument extends SheetManagementMixin(BasePseudoDocument) {
static get TYPES() {
return (this._TYPES ??= Object.freeze(CONFIG.daggerheart.pseudoDocuments[this.metadata.name]));
const { types } = CONFIG.daggerheart.pseudoDocuments[this.metadata.name];
const typeEntries = Object.entries(types).map(([key, { documentClass }]) => [key, documentClass]);
return (this._TYPES ??= Object.freeze(Object.fromEntries(typeEntries)));
}
static _TYPES;
/* -------------------------------------------- */
/**
* The type of this shape.
* @type {string}
@ -19,6 +19,17 @@ export default class PseudoDocument extends SheetManagementMixin(BasePseudoDocum
/* -------------------------------------------- */
static getTypesChoices(validTypes) {
const { types } = CONFIG.daggerheart.pseudoDocuments[model.metadata.name];
const typeEntries = Object.entries(types)
.map(([key, { label }]) => [key, label])
.filter(([key]) => !validTypes || validTypes.includes(key));
return Object.entries(typeEntries);
}
/* -------------------------------------------- */
/** @override */
static defineSchema() {
const { fields } = foundry.data;