From b630e73c790e7dbaf575cbb7afa98eefc584d6e9 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Thu, 23 Mar 2023 14:30:40 +0100 Subject: [PATCH] =?UTF-8?q?#82=20-=20Utilisateur=20artists=20plut=C3=B4t?= =?UTF-8?q?=20que=20artists=5Fsort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascripts/collection.js | 19 +++++++++++++++++-- src/middleware/Albums.js | 10 +++++----- views/pages/collection.ejs | 10 ++++++---- .../mon-compte/ma-collection/details.ejs | 6 +++++- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/javascripts/collection.js b/javascripts/collection.js index f99e921..946ed7a 100644 --- a/javascripts/collection.js +++ b/javascripts/collection.js @@ -21,7 +21,7 @@ Vue.createApp({ showModalDelete: false, showModalShare: false, // eslint-disable-next-line no-undef - shareLink: `${protocol}//${host}/collection/${userId}`, + shareLink: `/collection/${userId}`, // eslint-disable-next-line no-undef isPublicCollection, // eslint-disable-next-line no-undef @@ -67,7 +67,7 @@ Vue.createApp({ let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`; if (this.artist) { - url += `&artists_sort=${this.formatParams(this.artist)}`; + url += `&artist=${this.formatParams(this.artist)}`; } if (this.format) { url += `&format=${this.formatParams(this.format)}`; @@ -218,5 +218,20 @@ Vue.createApp({ this.toggleModalShare(); }); }, + renderAlbumTitle(item) { + let render = ''; + + for ( let i = 0 ; i < item.artists.length ; i += 1 ) { + const { + name, + join, + } = item.artists[i]; + render += `${name} ${join ? `${join} ` : ''}`; + } + + render += `- ${item.title}`; + + return render; + } }, }).mount("#collection"); \ No newline at end of file diff --git a/src/middleware/Albums.js b/src/middleware/Albums.js index a502bd3..943eaec 100644 --- a/src/middleware/Albums.js +++ b/src/middleware/Albums.js @@ -80,7 +80,7 @@ class Albums extends Pages { exportFormat = "json", sort = "artists_sort", order = "asc", - artists_sort, + artist, format, year, genre, @@ -92,8 +92,8 @@ class Albums extends Pages { const where = {}; - if (artists_sort) { - where.artists_sort = artists_sort; + if (artist) { + where["artists.name"] = artist; } if (format) { where["formats.name"] = format; @@ -236,7 +236,7 @@ class Albums extends Pages { */ async loadMyCollection() { const artists = await Albums.getAllDistincts( - "artists_sort", + "artists.name", this.req.user._id ); const formats = await Albums.getAllDistincts( @@ -301,7 +301,7 @@ class Albums extends Pages { ); } - const artists = await Albums.getAllDistincts("artists_sort", userId); + const artists = await Albums.getAllDistincts("artists.name", userId); const formats = await Albums.getAllDistincts("formats.name", userId); const years = await Albums.getAllDistincts("year", userId); const genres = await Albums.getAllDistincts("genres", userId); diff --git a/views/pages/collection.ejs b/views/pages/collection.ejs index 8680885..8d18ab2 100644 --- a/views/pages/collection.ejs +++ b/views/pages/collection.ejs @@ -11,9 +11,11 @@ } %> <% if ( pageType === 'private' ) { %> - - Voir ma collection partagée - +
+ + Voir ma collection partagée + +
<% } %> <%- include('../components/filters/index') %> @@ -28,7 +30,7 @@
<% if ( pageType === 'private' ) { %> - {{ item.artists_sort}} - {{ item.title }} + {{ renderAlbumTitle(item) }} <% } else { %> {{ item.artists_sort}} - {{ item.title }} diff --git a/views/pages/mon-compte/ma-collection/details.ejs b/views/pages/mon-compte/ma-collection/details.ejs index dc56b3a..126cea4 100644 --- a/views/pages/mon-compte/ma-collection/details.ejs +++ b/views/pages/mon-compte/ma-collection/details.ejs @@ -1,7 +1,11 @@

- {{item.artists_sort}} - {{item.title}} + + - {{item.title}}