From 7e593ad05bf6aa15d93ecd572b2b24a86b1c0d42 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Wed, 7 Mar 2018 23:02:33 +0100 Subject: [PATCH 1/2] Added year filter --- front/src/filters.js | 6 ++++++ front/test/unit/specs/filters/filters.spec.js | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/front/src/filters.js b/front/src/filters.js index 22d93149b..afc393d40 100644 --- a/front/src/filters.js +++ b/front/src/filters.js @@ -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) } diff --git a/front/test/unit/specs/filters/filters.spec.js b/front/test/unit/specs/filters/filters.spec.js index c2b43da44..f4789ca48 100644 --- a/front/test/unit/specs/filters/filters.spec.js +++ b/front/test/unit/specs/filters/filters.spec.js @@ -1,4 +1,4 @@ -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' From 1822fdf4499fb01b96eed5f2af6e5644d4e76e72 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Wed, 7 Mar 2018 23:03:46 +0100 Subject: [PATCH 2/2] Fix #116: On artist page, albums are not sorted by release date, if any --- changes/changelog.d/116.feature | 1 + front/src/components/audio/album/Card.vue | 9 +++++---- front/src/components/library/Artist.vue | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changes/changelog.d/116.feature diff --git a/changes/changelog.d/116.feature b/changes/changelog.d/116.feature new file mode 100644 index 000000000..e17343401 --- /dev/null +++ b/changes/changelog.d/116.feature @@ -0,0 +1 @@ +On artist page, albums are not sorted by release date, if any (#116) diff --git a/front/src/components/audio/album/Card.vue b/front/src/components/audio/album/Card.vue index ea42f06a8..bb37b2b2f 100644 --- a/front/src/components/audio/album/Card.vue +++ b/front/src/components/audio/album/Card.vue @@ -6,12 +6,13 @@
- {{ album.title }} + {{ album.title }}
- By - {{ album.artist.name }} - + + By + {{ album.artist.name }} + – {{ album.release_date | year }}
diff --git a/front/src/components/library/Artist.vue b/front/src/components/library/Artist.vue index 7724428ca..9a546aa0e 100644 --- a/front/src/components/library/Artist.vue +++ b/front/src/components/library/Artist.vue @@ -31,7 +31,7 @@

Albums by this artist

-
+
@@ -41,6 +41,7 @@