« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/album.js18
-rw-r--r--src/data/things/track.js37
2 files changed, 36 insertions, 19 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 9cbab427..4a714361 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -77,12 +77,20 @@ export class Album extends Thing {
     name: name('Unnamed Album'),
     directory: directory(),
 
-    directorySuffix: {
-      flags: {update: true, expose: true},
-      update: {validate: isDirectory},
-    },
+    directorySuffix: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isDirectory),
+      }),
+
+      withDirectory(),
+
+      exposeDependency({
+        dependency: '#directory',
+      }),
+    ],
 
     alwaysReferenceTracksByDirectory: flag(false),
+    suffixTrackDirectories: flag(false),
 
     color: color(),
     urls: urls(),
@@ -333,8 +341,10 @@ export class Album extends Thing {
   static [Thing.yamlDocumentSpec] = {
     fields: {
       'Album': {property: 'name'},
+
       'Directory': {property: 'directory'},
       'Directory Suffix': {property: 'directorySuffix'},
+      'Suffix Track Directories': {property: 'suffixTrackDirectories'},
 
       'Always Reference Tracks By Directory': {
         property: 'alwaysReferenceTracksByDirectory',
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 2ee42fdf..a1740f87 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -5,7 +5,7 @@ import {colors} from '#cli';
 import {input} from '#composite';
 import find from '#find';
 import Thing from '#thing';
-import {isColor, isContributionList, isDate, isFileExtension}
+import {isBoolean, isColor, isContributionList, isDate, isFileExtension}
   from '#validators';
 
 import {
@@ -67,10 +67,12 @@ import {
   withAlwaysReferenceByDirectory,
   withContainingTrackSection,
   withDate,
+  withDirectorySuffix,
   withHasUniqueCoverArt,
   withOriginalRelease,
   withOtherReleases,
   withPropertyFromAlbum,
+  withSuffixDirectoryFromAlbum,
   withTrackArtDate,
 } from '#composite/things/track';
 
@@ -90,29 +92,34 @@ export class Track extends Thing {
     name: name('Unnamed Track'),
 
     directory: [
-      withPropertyFromAlbum({
-        property: input.value('directorySuffix'),
+      withDirectorySuffix(),
+
+      directory({
+        suffix: '#directorySuffix',
       }),
+    ],
 
+    suffixDirectoryFromAlbum: [
       {
-        dependencies: ['suffixDirectory', '#album.directorySuffix'],
+        dependencies: [
+          input.updateValue({validate: isBoolean}),
+        ],
+
         compute: (continuation, {
-          ['suffixDirectory']: suffixDirectory,
-          ['#album.directorySuffix']: directorySuffix,
+          [input.updateValue()]: value,
         }) => continuation({
-          ['#suffix']:
-            (suffixDirectory
-              ? directorySuffix
-              : null),
+          ['#flagValue']: value ?? false,
         }),
       },
 
-      directory({
-        suffix: '#suffix',
+      withSuffixDirectoryFromAlbum({
+        flagValue: '#flagValue',
       }),
-    ],
 
-    suffixDirectory: flag(false),
+      exposeDependency({
+        dependency: '#suffixDirectoryFromAlbum',
+      })
+    ],
 
     additionalNames: additionalNameList(),
 
@@ -458,7 +465,7 @@ export class Track extends Thing {
     fields: {
       'Track': {property: 'name'},
       'Directory': {property: 'directory'},
-      'Suffix Directory': {property: 'suffixDirectory'},
+      'Suffix Directory': {property: 'suffixDirectoryFromAlbum'},
 
       'Additional Names': {
         property: 'additionalNames',