#74 - Lors du changement de page on connait l'ordre de tri

This commit is contained in:
Damien Broqua 2023-01-17 17:21:28 +01:00
parent fe3ed3e91f
commit c1b01ea4c0
1 changed files with 10 additions and 0 deletions

View File

@ -41,6 +41,11 @@ if (typeof isPublicCollection !== "undefined") {
const urlParams = new URLSearchParams(queryString); const urlParams = new URLSearchParams(queryString);
const entries = urlParams.entries(); const entries = urlParams.entries();
const sortOrder = {
sort: "artists_sort",
order: "asc",
};
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
for (const entry of entries) { for (const entry of entries) {
const [key, value] = entry; const [key, value] = entry;
@ -49,10 +54,15 @@ if (typeof isPublicCollection !== "undefined") {
this.artist = value; this.artist = value;
break; break;
default: default:
if (["order", "sort"].indexOf(key) !== -1) {
sortOrder[key] = value;
}
this[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}`; let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
if (this.artist) { if (this.artist) {
url += `&artists_sort=${this.artist.replace("&", "%26")}`; url += `&artists_sort=${this.artist.replace("&", "%26")}`;