« get me outta code hell

data: seriesList: expose group - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-10-15 23:53:15 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-11-02 22:12:49 -0300
commitc7b08a3f9dee2be7cd1d3798315b35fdfd6d80f9 (patch)
tree92460a3366c4899d7a93ed19b670da0d41bd96c9
parent7c8abdbb551a05b0d9083bf13a7d82b22b866566 (diff)
data: seriesList: expose group
-rw-r--r--src/data/composite/wiki-data/withResolvedSeriesList.js28
-rw-r--r--src/data/composite/wiki-properties/seriesList.js10
-rw-r--r--src/data/things/group.js4
3 files changed, 37 insertions, 5 deletions
diff --git a/src/data/composite/wiki-data/withResolvedSeriesList.js b/src/data/composite/wiki-data/withResolvedSeriesList.js
index 8a4a4f99..bd2b0ecf 100644
--- a/src/data/composite/wiki-data/withResolvedSeriesList.js
+++ b/src/data/composite/wiki-data/withResolvedSeriesList.js
@@ -1,7 +1,7 @@
 import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
 import {stitchArrays} from '#sugar';
-import {isSeriesList} from '#validators';
+import {isSeriesList, validateThing} from '#validators';
 
 import {raiseOutputWithoutDependency} from '#composite/control-flow';
 
@@ -18,6 +18,10 @@ export default templateCompositeFrom({
   annotation: `withResolvedSeriesList`,
 
   inputs: {
+    group: input({
+      validate: validateThing({referenceType: 'group'}),
+    }),
+
     list: input({
       validate: isSeriesList,
       acceptsNull: true,
@@ -84,12 +88,30 @@ export default templateCompositeFrom({
         ['#serieses.description']: description,
         ['#serieses.albums']: albums,
       }) => continuation({
-        ['#resolvedSeriesList']:
+        ['#seriesProperties']:
           stitchArrays({
             name,
             description,
             albums,
-          }),
+          }).map(properties => ({
+              ...properties,
+              group: input
+            }))
+      }),
+    },
+
+    {
+      dependencies: ['#seriesProperties', input('group')],
+      compute: (continuation, {
+        ['#seriesProperties']: seriesProperties,
+        [input('group')]: group,
+      }) => continuation({
+        ['#resolvedSeriesList']:
+          seriesProperties
+            .map(properties => ({
+              ...properties,
+              group,
+            })),
       }),
     },
   ],
diff --git a/src/data/composite/wiki-properties/seriesList.js b/src/data/composite/wiki-properties/seriesList.js
index aadd56c8..2a101b45 100644
--- a/src/data/composite/wiki-properties/seriesList.js
+++ b/src/data/composite/wiki-properties/seriesList.js
@@ -1,5 +1,5 @@
 import {input, templateCompositeFrom} from '#composite';
-import {isSeriesList} from '#validators';
+import {isSeriesList, validateThing} from '#validators';
 
 import {exposeDependency} from '#composite/control-flow';
 import {withResolvedSeriesList} from '#composite/wiki-data';
@@ -9,8 +9,16 @@ export default templateCompositeFrom({
 
   compose: false,
 
+  inputs: {
+    group: input({
+      validate: validateThing({referenceType: 'group'}),
+    }),
+  },
+
   steps: () => [
     withResolvedSeriesList({
+      group: input('group'),
+
       list: input.updateValue({
         validate: isSeriesList,
       }),
diff --git a/src/data/things/group.js b/src/data/things/group.js
index bd8e2fbf..e000e407 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -35,7 +35,9 @@ export class Group extends Thing {
       data: 'albumData',
     }),
 
-    serieses: seriesList(),
+    serieses: seriesList({
+      group: input.myself(),
+    }),
 
     // Update only