diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-26 19:00:58 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-26 20:20:19 -0400 |
| commit | 8835c9c03c837b2f8567730f94b5a85aa7ffdf2c (patch) | |
| tree | d8b3a648b7c4ce030af9d9138c426655bee3ba20 /src/data/things | |
| parent | 342c028a597aa42c5ddf0f47a4fd1b2111289dd7 (diff) | |
data: TrackSection: chop with{Start,Continue}CountingFrom
Diffstat (limited to 'src/data/things')
| -rw-r--r-- | src/data/things/album.js | 51 |
1 files changed, 43 insertions, 8 deletions
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, + }, ], }); |