From c1b01ea4c05e00b42fb0bd67724ee6f9f4be45a1 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Tue, 17 Jan 2023 17:21:28 +0100 Subject: [PATCH] #74 - Lors du changement de page on connait l'ordre de tri --- javascripts/mon-compte/ma-collection/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/javascripts/mon-compte/ma-collection/index.js b/javascripts/mon-compte/ma-collection/index.js index a2d93c5..40d263f 100644 --- a/javascripts/mon-compte/ma-collection/index.js +++ b/javascripts/mon-compte/ma-collection/index.js @@ -41,6 +41,11 @@ if (typeof isPublicCollection !== "undefined") { const urlParams = new URLSearchParams(queryString); const entries = urlParams.entries(); + const sortOrder = { + sort: "artists_sort", + order: "asc", + }; + // eslint-disable-next-line no-restricted-syntax for (const entry of entries) { const [key, value] = entry; @@ -49,10 +54,15 @@ if (typeof isPublicCollection !== "undefined") { this.artist = value; break; default: + if (["order", "sort"].indexOf(key) !== -1) { + sortOrder[key] = value; + } this[key] = value; } } + this.sortOrder = `${sortOrder.sort}-${sortOrder.order}`; + let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`; if (this.artist) { url += `&artists_sort=${this.artist.replace("&", "%26")}`;