#73 - Savoir sur quelle page on est

This commit is contained in:
Damien Broqua 2023-01-17 17:08:41 +01:00
parent 8822056c1f
commit fe3ed3e91f
2 changed files with 9 additions and 4 deletions

View File

@ -6,7 +6,8 @@ if (typeof isPublicCollection !== "undefined") {
moreFilters: false, moreFilters: false,
items: [], items: [],
total: 0, total: 0,
page: 1, // eslint-disable-next-line no-undef
page: query.page || 1,
totalPages: 1, totalPages: 1,
limit: 16, limit: 16,
artist: "", artist: "",
@ -20,9 +21,12 @@ if (typeof isPublicCollection !== "undefined") {
itemId: null, itemId: null,
showModalDelete: false, showModalDelete: false,
showModalShare: false, showModalShare: false,
// eslint-disable-next-line no-undef
shareLink: `${protocol}//${host}/collection/${userId}`, shareLink: `${protocol}//${host}/collection/${userId}`,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
isPublicCollection, isPublicCollection,
// eslint-disable-next-line no-undef
query,
}; };
}, },
created() { created() {

View File

@ -135,12 +135,12 @@
<nav class="pagination" role="navigation" aria-label="Pagination"> <nav class="pagination" role="navigation" aria-label="Pagination">
<ul class="pagination-list"> <ul class="pagination-list">
<template v-for="p in Array.from({length: totalPages}, (v, i) => (i+1))"> <template v-for="p in Array.from({length: totalPages}, (v, i) => (i+1))">
<template v-if="p < 2 || p > (totalPages - 1) || (page - 1) <= p && page + 1 >= p"> <template v-if="p < 2 || p > (totalPages - 1) || (Number(page) - 1) <= p && Number(page) + 1 >= p">
<li> <li>
<a class="pagination-link" :class="{'is-current': p === page}" @click="goTo(p)" aria-label="Aller à la page {{p}}">{{ p }}</a> <a class="pagination-link" :class="{'is-current': p === Number(page)}" @click="goTo(p)" :aria-label="'Aller à la page '+p">{{ p }}</a>
</li> </li>
</template> </template>
<template v-if="(page - 3 === p && page - 2 > 1) || (page + 2 === p && page + 2 < totalPages - 1)"> <template v-if="(Number(page) - 3 === p && Number(page) - 2 > 1) || (Number(page) + 2 === p && Number(page) + 2 < totalPages - 1)">
<li> <li>
<a class="pagination-link is-disabled">…</a> <a class="pagination-link is-disabled">…</a>
</li> </li>
@ -198,4 +198,5 @@
<script> <script>
const isPublicCollection = <%= user.isPublicCollection ? 'true' : 'false' %>; const isPublicCollection = <%= user.isPublicCollection ? 'true' : 'false' %>;
const userId = "<%= user._id %>"; const userId = "<%= user._id %>";
const query = <%- JSON.stringify(query) %>;
</script> </script>