Skip to content
Snippets Groups Projects
Commit ab91d837 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '116-chronological-order' into 'develop'

Resolve "Show albums on the artist's page in chronological order"

Closes #116

See merge request funkwhale/funkwhale!85
parents 468faffe 1822fdf4
No related branches found
No related tags found
No related merge requests found
On artist page, albums are not sorted by release date, if any (#116)
......@@ -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">
......
......@@ -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
......
......@@ -35,6 +35,12 @@ export function momentFormat (date, format) {
Vue.filter('moment', momentFormat)
export function year (date) {
return moment(date).year()
}
Vue.filter('year', year)
export function capitalize (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
......
import {truncate, markdown, ago, capitalize} from '@/filters'
import {truncate, markdown, ago, capitalize, year} from '@/filters'
describe('filters', () => {
describe('truncate', () => {
......@@ -32,6 +32,13 @@ describe('filters', () => {
expect(output).to.equal('a few seconds ago')
})
})
describe('year', () => {
it('works', () => {
const input = '2017-07-13'
let output = year(input)
expect(output).to.equal(2017)
})
})
describe('capitalize', () => {
it('works', () => {
const input = 'hello world'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment