« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data/withRecontextualizedContributionList.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/wiki-data/withRecontextualizedContributionList.js')
-rw-r--r--src/data/composite/wiki-data/withRecontextualizedContributionList.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/data/composite/wiki-data/withRecontextualizedContributionList.js b/src/data/composite/wiki-data/withRecontextualizedContributionList.js
index 06c997b5..d2401eac 100644
--- a/src/data/composite/wiki-data/withRecontextualizedContributionList.js
+++ b/src/data/composite/wiki-data/withRecontextualizedContributionList.js
@@ -1,12 +1,14 @@
 // Clones all the contributions in a list, with thing and thingProperty both
 // updated to match the current thing. Overwrites the provided dependency.
-// Doesn't do anything if the provided dependency is null.
+// Optionally updates artistProperty as well. Doesn't do anything if
+// the provided dependency is null.
 //
 // See also:
 //  - withRedatedContributionList
 //
 
 import {input, templateCompositeFrom} from '#composite';
+import {isStringNonEmpty} from '#validators';
 
 import {raiseOutputWithoutDependency} from '#composite/control-flow';
 import {withClonedThings} from '#composite/wiki-data';
@@ -19,6 +21,11 @@ export default templateCompositeFrom({
       type: 'array',
       acceptsNull: true,
     }),
+
+    artistProperty: input({
+      validate: isStringNonEmpty,
+      defaultValue: null,
+    }),
   },
 
   outputs: ({
@@ -47,16 +54,25 @@ export default templateCompositeFrom({
     },
 
     {
-      dependencies: [input.myself(), input.thisProperty()],
+      dependencies: [
+        input.myself(),
+        input.thisProperty(),
+        input('artistProperty'),
+      ],
 
       compute: (continuation, {
         [input.myself()]: myself,
         [input.thisProperty()]: thisProperty,
+        [input('artistProperty')]: artistProperty,
       }) => continuation({
-        ['#assignment']: {
-          thing: myself,
-          thingProperty: thisProperty,
-        },
+        ['#assignment']:
+          Object.assign(
+            {thing: myself},
+            {thingProperty: thisProperty},
+
+            (artistProperty
+              ? {artistProperty}
+              : {})),
       }),
     },