« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/wiki-data')
-rw-r--r--src/data/composite/wiki-data/withResolvedContribs.js34
1 files changed, 32 insertions, 2 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;