diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-07 06:57:21 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-07 06:57:21 -0300 |
commit | 817b302878251d66ae88fa414f831a001964374f (patch) | |
tree | 106d1a7a6b3fe8d45a7731d309ba82560beed135 /src/data/things/album.js | |
parent | f3d39fd828aef3ac6f78c43d189b8792e2ad8e69 (diff) |
data: TrackSection.{start,continue}CountingFrom, Track.trackNumber
Diffstat (limited to 'src/data/things/album.js')
-rw-r--r-- | src/data/things/album.js | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js index 3eb6fc60..762e7d48 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -9,7 +9,7 @@ import {traverse} from '#node-utils'; import {sortAlbumsTracksChronologically, sortChronologically} from '#sort'; import {accumulateSum, empty} from '#sugar'; import Thing from '#thing'; -import {isColor, isDate, isDirectory} from '#validators'; +import {isColor, isDate, isDirectory, isNumber} from '#validators'; import { parseAdditionalFiles, @@ -57,7 +57,8 @@ import { } from '#composite/wiki-properties'; import {withTracks} from '#composite/things/album'; -import {withAlbum} from '#composite/things/track-section'; +import {withAlbum, withContinueCountingFrom, withStartCountingFrom} + from '#composite/things/track-section'; export class Album extends Thing { static [Thing.referenceType] = 'album'; @@ -682,6 +683,14 @@ export class TrackSection extends Thing { exposeDependency({dependency: '#album.color'}), ], + startCountingFrom: [ + withStartCountingFrom({ + from: input.updateValue({validate: isNumber}), + }), + + exposeDependency({dependency: '#startCountingFrom'}), + ], + dateOriginallyReleased: simpleDate(), isDefaultTrackSection: flag(false), @@ -731,6 +740,12 @@ export class TrackSection extends Thing { }, ], + continueCountingFrom: [ + withContinueCountingFrom(), + + exposeDependency({dependency: '#continueCountingFrom'}), + ], + startIndex: [ withAlbum(), @@ -797,6 +812,7 @@ export class TrackSection extends Thing { fields: { 'Section': {property: 'name'}, 'Color': {property: 'color'}, + 'Start Counting From': {property: 'startCountingFrom'}, 'Date Originally Released': { property: 'dateOriginallyReleased', @@ -820,12 +836,12 @@ export class TrackSection extends Thing { let first = null; try { - first = this.startIndex; + first = this.tracks.at(0).trackNumber; } catch {} - let length = null; + let last = null; try { - length = this.tracks.length; + last = this.tracks.at(-1).trackNumber; } catch {} if (album) { @@ -838,8 +854,8 @@ export class TrackSection extends Thing { : `#${albumIndex + 1}`); const range = - (albumIndex >= 0 && first !== null && length !== null - ? `: ${first + 1}-${first + length}` + (albumIndex >= 0 && first !== null && last !== null + ? `: ${first}-${last}` : ''); parts.push(` (${colors.yellow(num + range)} in ${colors.green(albumName)})`); |