« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/composite/wiki-properties/index.js1
-rw-r--r--src/data/composite/wiki-properties/reverseReferencedArtworkList.js39
-rw-r--r--src/data/things/album.js10
-rw-r--r--src/data/things/track.js9
4 files changed, 59 insertions, 0 deletions
diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js
index e98c89fc..2de76912 100644
--- a/src/data/composite/wiki-properties/index.js
+++ b/src/data/composite/wiki-properties/index.js
@@ -24,6 +24,7 @@ export {default as referencedArtworkList} from './referencedArtworkList.js';
 export {default as reverseAnnotatedReferenceList} from './reverseAnnotatedReferenceList.js';
 export {default as reverseContributionList} from './reverseContributionList.js';
 export {default as reverseReferenceList} from './reverseReferenceList.js';
+export {default as reverseReferencedArtworkList} from './reverseReferencedArtworkList.js';
 export {default as reverseSingleReferenceList} from './reverseSingleReferenceList.js';
 export {default as seriesList} from './seriesList.js';
 export {default as simpleDate} from './simpleDate.js';
diff --git a/src/data/composite/wiki-properties/reverseReferencedArtworkList.js b/src/data/composite/wiki-properties/reverseReferencedArtworkList.js
new file mode 100644
index 00000000..2950bdb9
--- /dev/null
+++ b/src/data/composite/wiki-properties/reverseReferencedArtworkList.js
@@ -0,0 +1,39 @@
+import {input, templateCompositeFrom} from '#composite';
+import {combineWikiDataArrays} from '#wiki-data';
+
+import {exposeDependency} from '#composite/control-flow';
+import {inputWikiData, withReverseAnnotatedReferenceList}
+  from '#composite/wiki-data';
+
+export default templateCompositeFrom({
+  annotation: `reverseReferencedArtworkList`,
+
+  compose: false,
+
+  steps: () => [
+    {
+      dependencies: [
+        'albumData',
+        'trackData',
+      ],
+
+      compute: (continuation, {
+        albumData,
+        trackData,
+      }) => continuation({
+        ['#data']:
+          combineWikiDataArrays([
+            albumData,
+            trackData,
+          ]),
+      }),
+    },
+
+    withReverseAnnotatedReferenceList({
+      data: '#data',
+      list: input.value('referencedArtworks'),
+    }),
+
+    exposeDependency({dependency: '#reverseAnnotatedReferenceList'}),
+  ],
+});
diff --git a/src/data/things/album.js b/src/data/things/album.js
index af7f0239..35cf1f3e 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -49,6 +49,7 @@ import {
   name,
   referencedArtworkList,
   referenceList,
+  reverseReferencedArtworkList,
   simpleDate,
   simpleString,
   singleReference,
@@ -280,6 +281,15 @@ export class Album extends Thing {
       withTracks(),
       exposeDependency({dependency: '#tracks'}),
     ],
+
+    referencedByArtworks: [
+      exitWithoutContribs({
+        contribs: 'coverArtistContribs',
+        value: input.value([]),
+      }),
+
+      reverseReferencedArtworkList(),
+    ],
   });
 
   static [Thing.getSerializeDescriptors] = ({
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 5c3161aa..0ac6aabd 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -50,6 +50,7 @@ import {
   referenceList,
   referencedArtworkList,
   reverseReferenceList,
+  reverseReferencedArtworkList,
   simpleDate,
   simpleString,
   singleReference,
@@ -443,6 +444,14 @@ export class Track extends Thing {
       data: 'flashData',
       list: input.value('featuredTracks'),
     }),
+
+    referencedByArtworks: [
+      exitWithoutUniqueCoverArt({
+        value: input.value([]),
+      }),
+
+      reverseReferencedArtworkList(),
+    ],
   });
 
   static [Thing.yamlDocumentSpec] = {