[web] Add the medium numbers when an album has multiple media #1629
This commit is contained in:
parent
6a84498645
commit
e89c3929cc
|
@ -48,6 +48,21 @@ export function byRating(field, { direction = 'asc', defaultValue = 0 }) {
|
|||
}
|
||||
}
|
||||
|
||||
export function byMedium(field, direction = 'asc', defaultValue = 1) {
|
||||
return {
|
||||
compareFn: (a, b) => {
|
||||
const fieldA = a[field] || defaultValue
|
||||
const fieldB = b[field] || defaultValue
|
||||
const result = fieldA - fieldB
|
||||
return direction === 'asc' ? result : result * -1
|
||||
},
|
||||
|
||||
groupKeyFn: (item) => {
|
||||
return item[field] || defaultValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function byYear(field, { direction = 'asc', defaultValue = '0000' }) {
|
||||
return {
|
||||
compareFn: (a, b) => {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<script>
|
||||
import ContentWithHero from '@/templates/ContentWithHero.vue'
|
||||
import CoverArtwork from '@/components/CoverArtwork.vue'
|
||||
import { GroupByList } from '@/lib/GroupByList'
|
||||
import { GroupByList, byMedium, noop } from '@/lib/GroupByList'
|
||||
import ListTracks from '@/components/ListTracks.vue'
|
||||
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
|
||||
import webapi from '@/webapi'
|
||||
|
@ -63,6 +63,10 @@ const dataObject = {
|
|||
set(vm, response) {
|
||||
vm.album = response[0].data
|
||||
vm.tracks = new GroupByList(response[1].data)
|
||||
vm.tracks.group(byMedium('disc_number'))
|
||||
if (vm.tracks.indexList <= 1) {
|
||||
vm.tracks.group(noop())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue