« 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/things/artwork.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/artwork.js')
-rw-r--r--src/data/things/artwork.js123
1 files changed, 117 insertions, 6 deletions
diff --git a/src/data/things/artwork.js b/src/data/things/artwork.js
index 2a97fd6d..57c293ca 100644
--- a/src/data/things/artwork.js
+++ b/src/data/things/artwork.js
@@ -1,5 +1,6 @@
 import {inspect} from 'node:util';
 
+import {colors} from '#cli';
 import {input} from '#composite';
 import find from '#find';
 import Thing from '#thing';
@@ -44,6 +45,7 @@ import {
 import {
   contentString,
   directory,
+  flag,
   reverseReferenceList,
   simpleString,
   soupyFind,
@@ -52,15 +54,18 @@ import {
   wikiData,
 } from '#composite/wiki-properties';
 
-import {withDate} from '#composite/things/artwork';
+import {
+  withAttachedArtwork,
+  withContainingArtworkList,
+  withContribsFromAttachedArtwork,
+  withPropertyFromAttachedArtwork,
+  withDate,
+} from '#composite/things/artwork';
 
 export class Artwork extends Thing {
   static [Thing.referenceType] = 'artwork';
 
-  static [Thing.getPropertyDescriptors] = ({
-    ArtTag,
-    Contribution,
-  }) => ({
+  static [Thing.getPropertyDescriptors] = ({ArtTag}) => ({
     // Update & expose
 
     unqualifiedDirectory: directory({
@@ -68,9 +73,11 @@ export class Artwork extends Thing {
     }),
 
     thing: thing(),
+    thingProperty: simpleString(),
 
     label: simpleString(),
     source: contentString(),
+    originDetails: contentString(),
 
     dateFromThingProperty: simpleString(),
 
@@ -127,7 +134,7 @@ export class Artwork extends Thing {
       }),
 
       exitWithoutDependency({
-        dependency: 'artistContribsFromThingProperty',
+        dependency: 'dimensionsFromThingProperty',
         value: input.value(null),
       }),
 
@@ -152,6 +159,8 @@ export class Artwork extends Thing {
       }),
     ],
 
+    attachAbove: flag(false),
+
     artistContribsFromThingProperty: simpleString(),
     artistContribsArtistProperty: simpleString(),
 
@@ -161,6 +170,7 @@ export class Artwork extends Thing {
       withResolvedContribs({
         from: input.updateValue({validate: isContributionList}),
         date: '#date',
+        thingProperty: input.thisProperty(),
         artistProperty: 'artistContribsArtistProperty',
       }),
 
@@ -169,6 +179,12 @@ export class Artwork extends Thing {
         mode: input.value('empty'),
       }),
 
+      withContribsFromAttachedArtwork(),
+
+      exposeDependencyOrContinue({
+        dependency: '#attachedArtwork.artistContribs',
+      }),
+
       exitWithoutDependency({
         dependency: 'artistContribsFromThingProperty',
         value: input.value([]),
@@ -207,6 +223,14 @@ export class Artwork extends Thing {
         mode: input.value('empty'),
       }),
 
+      withPropertyFromAttachedArtwork({
+        property: input.value('artTags'),
+      }),
+
+      exposeDependencyOrContinue({
+        dependency: '#attachedArtwork.artTags',
+      }),
+
       exitWithoutDependency({
         dependency: 'artTagsFromThingProperty',
         value: input.value([]),
@@ -302,6 +326,66 @@ export class Artwork extends Thing {
     referencedByArtworks: reverseReferenceList({
       reverse: soupyReverse.input('artworksWhichReference'),
     }),
+
+    isMainArtwork: [
+      withContainingArtworkList(),
+
+      exitWithoutDependency({
+        dependency: '#containingArtworkList',
+        value: input.value(null),
+      }),
+
+      {
+        dependencies: [input.myself(), '#containingArtworkList'],
+        compute: ({
+          [input.myself()]: myself,
+          ['#containingArtworkList']: list,
+        }) =>
+          list[0] === myself,
+      },
+    ],
+
+    mainArtwork: [
+      withContainingArtworkList(),
+
+      exitWithoutDependency({
+        dependency: '#containingArtworkList',
+        value: input.value(null),
+      }),
+
+      {
+        dependencies: ['#containingArtworkList'],
+        compute: ({'#containingArtworkList': list}) =>
+          list[0],
+      },
+    ],
+
+    attachedArtwork: [
+      withAttachedArtwork(),
+
+      exposeDependency({
+        dependency: '#attachedArtwork',
+      }),
+    ],
+
+    attachingArtworks: reverseReferenceList({
+      reverse: soupyReverse.input('artworksWhichAttach'),
+    }),
+
+    groups: [
+      withPropertyFromObject({
+        object: 'thing',
+        property: input.value('groups'),
+      }),
+
+      exposeDependencyOrContinue({
+        dependency: '#thing.groups',
+      }),
+
+      exposeConstant({
+        value: input.value([]),
+      }),
+    ],
   });
 
   static [Thing.yamlDocumentSpec] = {
@@ -316,12 +400,15 @@ export class Artwork extends Thing {
 
       'Label': {property: 'label'},
       'Source': {property: 'source'},
+      'Origin Details': {property: 'originDetails'},
 
       'Date': {
         property: 'date',
         transform: parseDate,
       },
 
+      'Attach Above': {property: 'attachAbove'},
+
       'Artists': {
         property: 'artistContribs',
         transform: parseContributors,
@@ -358,6 +445,18 @@ export class Artwork extends Thing {
       date: ({artwork}) => artwork.date,
     },
 
+    artworksWhichAttach: {
+      bindTo: 'artworkData',
+
+      referencing: referencingArtwork =>
+        (referencingArtwork.attachAbove
+          ? [referencingArtwork]
+          : []),
+
+      referenced: referencingArtwork =>
+        [referencingArtwork.attachedArtwork],
+    },
+
     artworksWhichFeature: {
       bindTo: 'artworkData',
 
@@ -373,6 +472,18 @@ export class Artwork extends Thing {
     return this.thing.getOwnArtworkPath(this);
   }
 
+  countOwnContributionInContributionTotals(contrib) {
+    if (this.attachAbove) {
+      return false;
+    }
+
+    if (contrib.annotation?.startsWith('edits for wiki')) {
+      return false;
+    }
+
+    return true;
+  }
+
   [inspect.custom](depth, options, inspect) {
     const parts = [];