From 163c541f4b8244f3c2fd8568ab3ef5cc4ed114a2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 3 Nov 2024 09:59:31 -0400 Subject: data: Track.suffixDirectory, Album.directorySuffix --- src/data/things/album.js | 13 ++++++++++--- src/data/things/track.js | 27 ++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src/data/things') diff --git a/src/data/things/album.js b/src/data/things/album.js index b8009063..9cbab427 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -11,7 +11,7 @@ import {traverse} from '#node-utils'; import {sortAlbumsTracksChronologically, sortChronologically} from '#sort'; import {accumulateSum, empty} from '#sugar'; import Thing from '#thing'; -import {isColor, isDate, validateWikiData} from '#validators'; +import {isColor, isDate, isDirectory, validateWikiData} from '#validators'; import { parseAdditionalFiles, @@ -75,12 +75,18 @@ export class Album extends Thing { // Update & expose name: name('Unnamed Album'), - color: color(), directory: directory(), - urls: urls(), + + directorySuffix: { + flags: {update: true, expose: true}, + update: {validate: isDirectory}, + }, alwaysReferenceTracksByDirectory: flag(false), + color: color(), + urls: urls(), + additionalNames: additionalNameList(), bandcampAlbumIdentifier: simpleString(), @@ -328,6 +334,7 @@ export class Album extends Thing { fields: { 'Album': {property: 'name'}, 'Directory': {property: 'directory'}, + 'Directory Suffix': {property: 'directorySuffix'}, 'Always Reference Tracks By Directory': { property: 'alwaysReferenceTracksByDirectory', diff --git a/src/data/things/track.js b/src/data/things/track.js index 078ad11b..2ee42fdf 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -88,7 +88,31 @@ export class Track extends Thing { // Update & expose name: name('Unnamed Track'), - directory: directory(), + + directory: [ + withPropertyFromAlbum({ + property: input.value('directorySuffix'), + }), + + { + dependencies: ['suffixDirectory', '#album.directorySuffix'], + compute: (continuation, { + ['suffixDirectory']: suffixDirectory, + ['#album.directorySuffix']: directorySuffix, + }) => continuation({ + ['#suffix']: + (suffixDirectory + ? directorySuffix + : null), + }), + }, + + directory({ + suffix: '#suffix', + }), + ], + + suffixDirectory: flag(false), additionalNames: additionalNameList(), @@ -434,6 +458,7 @@ export class Track extends Thing { fields: { 'Track': {property: 'name'}, 'Directory': {property: 'directory'}, + 'Suffix Directory': {property: 'suffixDirectory'}, 'Additional Names': { property: 'additionalNames', -- cgit 1.3.0-6-gf8a5