From 8835c9c03c837b2f8567730f94b5a85aa7ffdf2c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 26 Nov 2025 19:00:58 -0400 Subject: data: TrackSection: chop with{Start,Continue}CountingFrom --- src/data/things/album.js | 51 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'src/data/things') diff --git a/src/data/things/album.js b/src/data/things/album.js index 42db1773..cf021080 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -44,6 +44,8 @@ import { import { withFlattenedList, + withLengthOfList, + withNearbyItemFromList, withPropertyFromList, withPropertyFromObject, } from '#composite/data'; @@ -81,9 +83,6 @@ import { wikiData, } from '#composite/wiki-properties'; -import {withContinueCountingFrom, withStartCountingFrom} - from '#composite/things/track-section'; - export class Album extends Thing { static [Thing.referenceType] = 'album'; static [Thing.wikiData] = 'albumData'; @@ -1046,11 +1045,41 @@ export class TrackSection extends Thing { ], startCountingFrom: [ - withStartCountingFrom({ - from: input.updateValue({validate: isNumber}), + exposeUpdateValueOrContinue({ + validate: input.value(isNumber), + }), + + exitWithoutDependency({ + dependency: 'album', + value: input.value(1), + }), + + withPropertyFromObject({ + object: 'album', + property: input.value('trackSections'), + }), + + withNearbyItemFromList({ + list: '#album.trackSections', + item: input.myself(), + offset: input.value(-1), + }).outputs({ + '#nearbyItem': '#previousTrackSection', + }), + + exitWithoutDependency({ + dependency: '#previousTrackSection', + value: input.value(1), + }), + + withPropertyFromObject({ + object: '#previousTrackSection', + property: input.value('continueCountingFrom'), }), - exposeDependency({dependency: '#startCountingFrom'}), + exposeDependency({ + dependency: '#previousTrackSection.continueCountingFrom', + }), ], dateOriginallyReleased: simpleDate(), @@ -1115,9 +1144,15 @@ export class TrackSection extends Thing { ], continueCountingFrom: [ - withContinueCountingFrom(), + withLengthOfList({ + list: 'tracks', + }), - exposeDependency({dependency: '#continueCountingFrom'}), + { + dependencies: ['startCountingFrom', '#tracks.length'], + compute: ({startCountingFrom, '#tracks.length': tracks}) => + startCountingFrom + tracks, + }, ], }); -- cgit 1.3.0-6-gf8a5