From 69ae43806f57daf9a29caf5ee3de14ec53bcaac1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 10 Dec 2025 17:32:11 -0400 Subject: data, content: TrackSection.hasTrackNumbers closes #566 PRETTY SWEET !!! examples here: https://discord.com/channels/749042497610842152/779895315750715422/1448422818944647429 --- src/data/things/album.js | 51 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'src/data/things/album.js') diff --git a/src/data/things/album.js b/src/data/things/album.js index f9d7a3a3..31d94ef1 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -979,20 +979,24 @@ export class TrackSection extends Thing { exposeDependency({dependency: '#album.color'}), ], + hasTrackNumbers: [ + exposeUpdateValueOrContinue({ + validate: input.value(isBoolean), + }), + + withPropertyFromObject('album', V('hasTrackNumbers')), + exposeDependency('#album.hasTrackNumbers'), + ], + startCountingFrom: [ exposeUpdateValueOrContinue({ validate: input.value(isNumber), }), - exitWithoutDependency({ - dependency: 'album', - value: input.value(1), - }), + withPropertyFromObject('album', V('hasTrackNumbers')), + exitWithoutDependency('#album.hasTrackNumbers', V(1), V('falsy')), - withPropertyFromObject({ - object: 'album', - property: input.value('trackSections'), - }), + withPropertyFromObject('album', V('trackSections')), withNearbyItemFromList({ list: '#album.trackSections', @@ -1002,19 +1006,10 @@ export class TrackSection extends Thing { '#nearbyItem': '#previousTrackSection', }), - exitWithoutDependency({ - dependency: '#previousTrackSection', - value: input.value(1), - }), - - withPropertyFromObject({ - object: '#previousTrackSection', - property: input.value('continueCountingFrom'), - }), + exitWithoutDependency('#previousTrackSection', V(1)), - exposeDependency({ - dependency: '#previousTrackSection.continueCountingFrom', - }), + withPropertyFromObject('#previousTrackSection', V('continueCountingFrom')), + exposeDependency('#previousTrackSection.continueCountingFrom'), ], dateOriginallyReleased: simpleDate(), @@ -1071,9 +1066,18 @@ export class TrackSection extends Thing { ], continueCountingFrom: [ - withLengthOfList({ - list: 'tracks', - }), + withPropertyFromObject('album', V('hasTrackNumbers')), + exitWithoutDependency('#album.hasTrackNumbers', V(null), V('falsy')), + + { + dependencies: ['hasTrackNumbers', 'startCountingFrom'], + compute: (continuation, {hasTrackNumbers, startCountingFrom}) => + (hasTrackNumbers + ? continuation() + : continuation.exit(startCountingFrom)), + }, + + withLengthOfList('tracks'), { dependencies: ['startCountingFrom', '#tracks.length'], @@ -1104,6 +1108,7 @@ export class TrackSection extends Thing { 'Suffix Track Directories': {property: 'suffixTrackDirectories'}, 'Color': {property: 'color'}, + 'Has Track Numbers': {property: 'hasTrackNumbers'}, 'Start Counting From': {property: 'startCountingFrom'}, 'Date Originally Released': { -- cgit 1.3.0-6-gf8a5