diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data/composite/things/contribution/thingPropertyMatches.js | 19 | ||||
-rw-r--r-- | src/data/composite/things/contribution/thingReferenceTypeMatches.js | 29 |
2 files changed, 44 insertions, 4 deletions
diff --git a/src/data/composite/things/contribution/thingPropertyMatches.js b/src/data/composite/things/contribution/thingPropertyMatches.js index 4a37f2cf..1e9019b8 100644 --- a/src/data/composite/things/contribution/thingPropertyMatches.js +++ b/src/data/composite/things/contribution/thingPropertyMatches.js @@ -1,6 +1,7 @@ import {input, templateCompositeFrom} from '#composite'; import {exitWithoutDependency} from '#composite/control-flow'; +import {withPropertyFromObject} from '#composite/data'; export default templateCompositeFrom({ annotation: `thingPropertyMatches`, @@ -12,19 +13,31 @@ export default templateCompositeFrom({ }, steps: () => [ + { + dependencies: ['thing', 'thingProperty'], + + compute: (continuation, {thing, thingProperty}) => + continuation({ + ['#thingProperty']: + (thing.constructor[Symbol.for('Thing.referenceType')] === 'artwork' + ? thing.artistContribsFromThingProperty + : thingProperty), + }), + }, + exitWithoutDependency({ - dependency: 'thingProperty', + dependency: '#thingProperty', value: input.value(false), }), { dependencies: [ - 'thingProperty', + '#thingProperty', input('value'), ], compute: ({ - ['thingProperty']: thingProperty, + ['#thingProperty']: thingProperty, [input('value')]: value, }) => thingProperty === value, diff --git a/src/data/composite/things/contribution/thingReferenceTypeMatches.js b/src/data/composite/things/contribution/thingReferenceTypeMatches.js index 2ee811af..4042e78f 100644 --- a/src/data/composite/things/contribution/thingReferenceTypeMatches.js +++ b/src/data/composite/things/contribution/thingReferenceTypeMatches.js @@ -29,10 +29,37 @@ export default templateCompositeFrom({ input('value'), ], - compute: ({ + compute: (continuation, { ['#thing.constructor']: constructor, [input('value')]: value, }) => + (constructor[Symbol.for('Thing.referenceType')] === value + ? continuation.exit(true) + : constructor[Symbol.for('Thing.referenceType')] === 'artwork' + ? continuation() + : continuation.exit(false)), + }, + + withPropertyFromObject({ + object: 'thing', + property: input.value('thing'), + }), + + withPropertyFromObject({ + object: '#thing.thing', + property: input.value('constructor'), + }), + + { + dependencies: [ + '#thing.thing.constructor', + input('value'), + ], + + compute: ({ + ['#thing.thing.constructor']: constructor, + [input('value')]: value, + }) => constructor[Symbol.for('Thing.referenceType')] === value, }, ], |