mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
23 lines
1.1 KiB
JavaScript
23 lines
1.1 KiB
JavaScript
import ForeignDocumentUUIDField from './foreignDocumentUUIDField.mjs';
|
|
/**
|
|
* A subclass of {@link foundry.data.fields.ArrayField} that defines an array of foreign document UUID references.
|
|
*/
|
|
export default class ForeignDocumentUUIDArrayField extends foundry.data.fields.ArrayField {
|
|
/**
|
|
* @param {foundry.data.types.DocumentUUIDFieldOptions} [fieldOption] - Options to configure each individual ForeignDocumentUUIDField.
|
|
* @param {foundry.data.types.ArrayFieldOptions} [options] - Options to configure the array behavior
|
|
* @param {foundry.data.types.DataFieldContext} [context] - Optional context for schema processing
|
|
*/
|
|
constructor(fieldOption = {}, options = {}, context = {}) {
|
|
super(new ForeignDocumentUUIDField(fieldOption), options, context);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
initialize(value, model, options = {}) {
|
|
const v = super.initialize(value, model, options);
|
|
return () => {
|
|
const data = v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
|
return this.options.prune ? data.filter((d) => !!d) : d;
|
|
};
|
|
}
|
|
}
|