« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/things.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/data/things.js b/src/data/things.js
index 941ef2f2..eb01cc16 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -526,11 +526,6 @@ TrackGroup.propertyDescriptors = {
         }
     },
 
-    startIndex: {
-        flags: {update: true, expose: true},
-        update: {validate: isWholeNumber}
-    },
-
     dateOriginallyReleased: Thing.common.simpleDate(),
 
     tracksByRef: Thing.common.referenceList(Track),
@@ -562,6 +557,17 @@ TrackGroup.propertyDescriptors = {
             )
         }
     },
+
+    startIndex: {
+        flags: {expose: true},
+
+        expose: {
+            dependencies: ['album'],
+            compute: ({ album, [TrackGroup.instance]: trackGroup }) => (album.trackGroups
+                .slice(0, album.trackGroups.indexOf(trackGroup))
+                .reduce((acc, tg) => acc + tg.tracks.length, 0))
+        }
+    },
 };
 
 // -> Track