Fix #116: On artist page, albums are not sorted by release date, if any

This commit is contained in:
Eliot Berriot 2018-03-07 23:03:46 +01:00
parent 7e593ad05b
commit 1822fdf449
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
3 changed files with 12 additions and 5 deletions

View File

@ -0,0 +1 @@
On artist page, albums are not sorted by release date, if any (#116)

View File

@ -6,12 +6,13 @@
<img v-else src="../../../assets/audio/default-cover.png">
</div>
<div class="header">
<router-link class="discrete link" :to="{name: 'library.albums.detail', params: {id: album.id }}">{{ album.title }}</router-link>
<router-link class="discrete link" :to="{name: 'library.albums.detail', params: {id: album.id }}">{{ album.title }} </router-link>
</div>
<div class="meta">
By <router-link :to="{name: 'library.artists.detail', params: {id: album.artist.id }}">
{{ album.artist.name }}
</router-link>
<span>
By <router-link tag="span" :to="{name: 'library.artists.detail', params: {id: album.artist.id }}">
{{ album.artist.name }}</router-link>
</span><span class="time" v-if="album.release_date"> {{ album.release_date | year }}</span>
</div>
<div class="description" v-if="mode === 'rich'">
<table class="ui very basic fixed single line compact unstackable table">

View File

@ -31,7 +31,7 @@
<div class="ui vertical stripe segment">
<h2>Albums by this artist</h2>
<div class="ui stackable doubling three column grid">
<div class="column" :key="album.id" v-for="album in albums">
<div class="column" :key="album.id" v-for="album in sortedAlbums">
<album-card :mode="'rich'" class="fluid" :album="album"></album-card>
</div>
</div>
@ -41,6 +41,7 @@
</template>
<script>
import _ from 'lodash'
import axios from 'axios'
import logger from '@/logging'
import backend from '@/audio/backend'
@ -83,6 +84,10 @@ export default {
}
},
computed: {
sortedAlbums () {
let a = this.albums || []
return _.orderBy(a, ['release_date'], ['asc'])
},
totalTracks () {
return this.albums.map((album) => {
return album.tracks.length