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 | |
parent | db054be170faa6146759cce20b18f242d89dfdcf (diff) |
data: contribution: thingProperty
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/composite/wiki-data/withResolvedContribs.js | 34 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/contributionList.js | 15 | ||||
-rw-r--r-- | src/data/things/contribution.js | 5 | ||||
-rw-r--r-- | src/data/things/track.js | 2 |
4 files changed, 51 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([]), + }), ], }); diff --git a/src/data/things/contribution.js b/src/data/things/contribution.js index dc7f2157..7eb8cfc7 100644 --- a/src/data/things/contribution.js +++ b/src/data/things/contribution.js @@ -21,6 +21,11 @@ export class Contribution extends Thing { update: {validate: isThing}, }, + thingProperty: { + flags: {update: true, expose: true}, + update: {validate: isStringNonEmpty}, + }, + artist: [ withContributionArtist({ ref: input.updateValue({ diff --git a/src/data/things/track.js b/src/data/things/track.js index 725b1bb7..11e71151 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -198,6 +198,7 @@ export class Track extends Thing { withResolvedContribs({ from: input.updateValue({validate: isContributionList}), + thingProperty: input.thisProperty(), }).outputs({ '#resolvedContribs': '#artistContribs', }), @@ -232,6 +233,7 @@ export class Track extends Thing { withResolvedContribs({ from: input.updateValue({validate: isContributionList}), + thingProperty: input.thisProperty(), }).outputs({ '#resolvedContribs': '#coverArtistContribs', }), |