mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Improves ForeignDocumentUUIDArrayField for can use documents to update it. (#963)
Fixes #389 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
parent
16591cd327
commit
18b6194afe
2 changed files with 10 additions and 1 deletions
|
|
@ -38,4 +38,13 @@ export default class ForeignDocumentUUIDField extends foundry.data.fields.Docume
|
|||
toObject(value) {
|
||||
return value?.uuid ?? value;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_cast(value) {
|
||||
if (typeof value === 'string') return value;
|
||||
if (value instanceof foundry.abstract.Document) return value.uuid;
|
||||
throw new Error(
|
||||
`The value provided to a ForeignDocumentUUIDField must be a ${foundry.abstract.Document.name} instance or a UUID string.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue