diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-04 20:22:42 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 17:26:31 -0300 |
commit | ef84fb80de0a26fcb959fa6e6799cd01388d236f (patch) | |
tree | 9f910d7380d8326b06dc846a7ea1ae8ceb6b5e31 /src/data/composite | |
parent | db054be170faa6146759cce20b18f242d89dfdcf (diff) |
data: contribution: thingProperty
Diffstat (limited to 'src/data/composite')
-rw-r--r-- | src/data/composite/wiki-data/withResolvedContribs.js | 34 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/contributionList.js | 15 |
2 files changed, 44 insertions, 5 deletions
diff --git a/src/data/composite/wiki-data/withResolvedContribs.js b/src/data/composite/wiki-data/withResolvedContribs.js index 7ff7b1bc..fd51c81e 100644 --- a/src/data/composite/wiki-data/withResolvedContribs.js +++ b/src/data/composite/wiki-data/withResolvedContribs.js @@ -8,7 +8,7 @@ import {input, templateCompositeFrom} from '#composite'; import find from '#find'; import {filterMultipleArrays, stitchArrays} from '#sugar'; import thingConstructors from '#things'; -import {is, isContributionList} from '#validators'; +import {is, isContributionList, isStringNonEmpty} from '#validators'; import {raiseOutputWithoutDependency} from '#composite/control-flow'; import {withPropertiesFromList} from '#composite/data'; @@ -26,6 +26,11 @@ export default templateCompositeFrom({ validate: is('exit', 'filter', 'null'), defaultValue: 'null', }), + + thingProperty: input({ + validate: isStringNonEmpty, + defaultValue: null, + }), }, outputs: ['#resolvedContribs'], @@ -39,6 +44,25 @@ export default templateCompositeFrom({ }), }), + { + dependencies: [ + input('thingProperty'), + input.staticDependency('from'), + ], + + compute: (continuation, { + [input('thingProperty')]: thingProperty, + [input.staticDependency('from')]: fromDependency, + }) => continuation({ + ['#thingProperty']: + (thingProperty + ? thingProperty + : !fromDependency?.startsWith('#') + ? fromDependency + : null), + }), + }, + withPropertiesFromList({ list: input('from'), properties: input.value(['artist', 'annotation']), @@ -62,10 +86,15 @@ export default templateCompositeFrom({ }, { - dependencies: ['#details', input.myself()], + dependencies: [ + '#details', + '#thingProperty', + input.myself(), + ], compute: (continuation, { ['#details']: details, + ['#thingProperty']: thingProperty, [input.myself()]: myself, }) => continuation({ ['#contributions']: @@ -75,6 +104,7 @@ export default templateCompositeFrom({ Object.assign(contrib, { ...details, thing: myself, + thingProperty: thingProperty, }); return contrib; diff --git a/src/data/composite/wiki-properties/contributionList.js b/src/data/composite/wiki-properties/contributionList.js index aad12a2d..001aed17 100644 --- a/src/data/composite/wiki-properties/contributionList.js +++ b/src/data/composite/wiki-properties/contributionList.js @@ -28,8 +28,17 @@ export default templateCompositeFrom({ update: {validate: isContributionList}, steps: () => [ - withResolvedContribs({from: input.updateValue()}), - exposeDependencyOrContinue({dependency: '#resolvedContribs'}), - exposeConstant({value: input.value([])}), + withResolvedContribs({ + from: input.updateValue(), + thingProperty: input.thisProperty(), + }), + + exposeDependencyOrContinue({ + dependency: '#resolvedContribs', + }), + + exposeConstant({ + value: input.value([]), + }), ], }); |