diff options
Diffstat (limited to 'src/data/composite/wiki-properties')
-rw-r--r-- | src/data/composite/wiki-properties/constitutibleArtwork.js | 67 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/index.js | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/data/composite/wiki-properties/constitutibleArtwork.js b/src/data/composite/wiki-properties/constitutibleArtwork.js new file mode 100644 index 00000000..e0f0f521 --- /dev/null +++ b/src/data/composite/wiki-properties/constitutibleArtwork.js @@ -0,0 +1,67 @@ +import {input, templateCompositeFrom} from '#composite'; +import {isContributionList, isDate, validateThing} from '#validators'; + +import {exitWithoutDependency, exposeDependency, exposeUpdateValueOrContinue} + from '#composite/control-flow'; +import {withConstitutedArtwork} from '#composite/wiki-data'; + +export default templateCompositeFrom({ + annotation: `constitutibleArtwork`, + + compose: false, + + inputs: { + contribs: input.staticDependency({ + validate: isContributionList, + acceptsNull: true, + }), + + date: input.staticDependency({ + validate: isDate, + acceptsNull: true, + }), + + artistProperty: input.staticValue({ + type: 'string', + }), + }, + + steps: () => [ + exposeUpdateValueOrContinue({ + validate: input.value( + validateThing({ + referenceType: 'artwork', + })), + }), + + exitWithoutDependency({ + dependency: input('contribs'), + value: input.value(null), + }), + + { + dependencies: [ + input.staticDependency('contribs'), + input.staticDependency('date'), + ], + + compute: (continuation, { + [input.staticDependency('contribs')]: contribsProperty, + [input.staticDependency('date')]: dateProperty, + }) => continuation({ + ['#contribsProperty']: contribsProperty, + ['#dateProperty']: dateProperty, + }) + }, + + withConstitutedArtwork({ + contribsProperty: '#contribsProperty', + artistProperty: input('artistProperty'), + dateProperty: '#dateProperty', + }), + + exposeDependency({ + dependency: '#constitutedArtwork', + }), + ], +}); diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js index 4aaaeb72..7583630d 100644 --- a/src/data/composite/wiki-properties/index.js +++ b/src/data/composite/wiki-properties/index.js @@ -9,6 +9,7 @@ export {default as annotatedReferenceList} from './annotatedReferenceList.js'; export {default as color} from './color.js'; export {default as commentary} from './commentary.js'; export {default as commentatorArtists} from './commentatorArtists.js'; +export {default as constitutibleArtwork} from './constitutibleArtwork.js'; export {default as contentString} from './contentString.js'; export {default as contribsPresent} from './contribsPresent.js'; export {default as contributionList} from './contributionList.js'; |