From 83911a3abab88aef7548d95c769eced5d2af821a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 19 May 2024 22:54:10 -0300 Subject: data: referenceList: 'referenceType' input --- src/data/composite/wiki-properties/referenceList.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/data/composite/wiki-properties/referenceList.js') diff --git a/src/data/composite/wiki-properties/referenceList.js b/src/data/composite/wiki-properties/referenceList.js index af634a68..ebd5947c 100644 --- a/src/data/composite/wiki-properties/referenceList.js +++ b/src/data/composite/wiki-properties/referenceList.js @@ -1,5 +1,6 @@ // Stores and exposes a list of references to other data objects; all items -// must be references to the same type, which is specified on the class input. +// must be references to the same type, which is either implied from the class +// input, or explicitly set on the referenceType input. // // See also: // - singleReference @@ -18,7 +19,17 @@ export default templateCompositeFrom({ compose: false, inputs: { - class: input.staticValue({validate: isThingClass}), + class: input.staticValue({ + validate: isThingClass, + acceptsNull: true, + defaultValue: null, + }), + + referenceType: input.staticValue({ + type: 'string', + acceptsNull: true, + defaultValue: null, + }), data: inputWikiData({allowMixedTypes: false}), @@ -27,10 +38,13 @@ export default templateCompositeFrom({ update: ({ [input.staticValue('class')]: thingClass, + [input.staticValue('referenceType')]: referenceType, }) => ({ validate: validateReferenceList( - thingClass[Symbol.for('Thing.referenceType')]), + (thingClass + ? thingClass[Symbol.for('Thing.referenceType')] + : referenceType)), }), steps: () => [ -- cgit 1.3.0-6-gf8a5