« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/checks.js4
-rw-r--r--src/data/things/art-tag.js25
2 files changed, 29 insertions, 0 deletions
diff --git a/src/data/checks.js b/src/data/checks.js
index 58f9daee..8698e877 100644
--- a/src/data/checks.js
+++ b/src/data/checks.js
@@ -188,6 +188,10 @@ export function filterReferenceErrors(wikiData, {
       commentary: '_commentary',
     }],
 
+    ['artTagData', {
+      directDescendantTags: 'artTag',
+    }],
+
     ['flashData', {
       commentary: '_commentary',
     }],
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index 9842c887..8519f7f9 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -1,6 +1,7 @@
 export const ART_TAG_DATA_FILE = 'tags.yaml';
 
 import {input} from '#composite';
+import find from '#find';
 import {sortAlphabetically, sortAlbumsTracksChronologically} from '#sort';
 import Thing from '#thing';
 import {isName} from '#validators';
@@ -11,7 +12,10 @@ import {
   color,
   directory,
   flag,
+  referenceList,
+  reverseReferenceList,
   name,
+  soupyFind,
   soupyReverse,
   wikiData,
 } from '#composite/wiki-properties';
@@ -40,8 +44,14 @@ export class ArtTag extends Thing {
       },
     ],
 
+    directDescendantTags: referenceList({
+      class: input.value(ArtTag),
+      find: soupyFind.input('artTag'),
+    }),
+
     // Update only
 
+    find: soupyFind(),
     reverse: soupyReverse(),
 
     // Expose only
@@ -60,6 +70,10 @@ export class ArtTag extends Thing {
             {getDate: thing => thing.coverArtDate ?? thing.date}),
       },
     },
+
+    directAncestorTags: reverseReferenceList({
+      reverse: soupyReverse.input('artTagsWhichDirectlyAncestor'),
+    }),
   });
 
   static [Thing.findSpecs] = {
@@ -74,6 +88,15 @@ export class ArtTag extends Thing {
     },
   };
 
+  static [Thing.reverseSpecs] = {
+    artTagsWhichDirectlyAncestor: {
+      bindTo: 'artTagData',
+
+      referencing: artTag => [artTag],
+      referenced: artTag => artTag.directDescendantTags,
+    },
+  };
+
   static [Thing.yamlDocumentSpec] = {
     fields: {
       'Tag': {property: 'name'},
@@ -82,6 +105,8 @@ export class ArtTag extends Thing {
 
       'Color': {property: 'color'},
       'Is CW': {property: 'isContentWarning'},
+
+      'Direct Descendant Tags': {property: 'directDescendantTags'},
     },
   };