Changed ItemLinksField makeup

This commit is contained in:
WBHarry 2025-07-23 14:50:24 +02:00
parent 600c08cb23
commit 30f31e77dd
13 changed files with 120 additions and 96 deletions

View file

@ -4,15 +4,7 @@ export default class ItemLinksField extends foundry.data.fields.TypedObjectField
* @param {DataFieldContext} [context] Additional context which describes the field
*/
constructor(options, context) {
super(
new foundry.data.fields.StringField({
choices: CONFIG.DH.ITEM.itemLinkTypes,
nullable: true,
initial: null
}),
options,
context
);
super(new foundry.data.fields.SetField(new foundry.data.fields.DocumentUUIDField()), options, context);
}
/** @inheritDoc */
@ -24,15 +16,6 @@ export default class ItemLinksField extends foundry.data.fields.TypedObjectField
* @param {Object} [value] The candidate object to be added.
*/
static validateKey(value) {
const parsed = foundry.utils.parseUuid(value);
if (!parsed || parsed.type !== foundry.documents.Item.documentName) return false;
if (!foundry.data.validators.isValidId(parsed.documentId)) return false;
return true;
}
/**@inheritdoc */
_cast(value) {
value = super._cast(value);
return foundry.utils.flattenObject(value);
return Boolean(CONFIG.DH.ITEM.itemLinkTypes[value]);
}
}