list change to pagination of count not dated lists

This commit is contained in:
Julian Krauser 2025-01-16 14:13:47 +01:00
parent b7e5e9e7fa
commit 42d8722265

View file

@ -44,7 +44,7 @@
</div>
</div>
<div
v-if="data?.lookup.date_list"
v-if="pagination.pageCount > 1"
class="flex flex-row w-full max-w-4xl mx-auto justify-between items-center select-none pt-4"
>
<p class="text-sm font-normal text-gray-500">
@ -67,7 +67,7 @@
v-for="page in displayedPagesNumbers"
:key="page"
class="flex h-8 w-8 items-center justify-center text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 first:rounded-s-lg last:rounded-e-lg"
:class="[currentPage == page ? 'font-bold border-primary' : '', page != '.' ? ' cursor-pointer' : '']"
:class="[currentPage - 1 == page ? 'font-bold border-primary' : '', page != '.' ? ' cursor-pointer' : '']"
@click="changeTimedPage(page)"
>
{{ typeof page == "number" ? page + 1 : "..." }}
@ -75,7 +75,7 @@
<li
class="flex h-8 w-8 items-center justify-center text-gray-500 bg-white border border-gray-300 first:rounded-s-lg last:rounded-e-lg"
:class="[
currentPage + 1 < pagination.pageCount
currentPage < pagination.pageCount
? 'cursor-pointer hover:bg-gray-100 hover:text-gray-700'
: 'opacity-50 pointer-events-none',
]"
@ -127,7 +127,7 @@ const { data: collections } = await useAsyncData("collection", () =>
sort: "date:desc",
filters: {
date: {
$between: [`${activeYear.value}-01-01T00:00:00.000Z`, `${activeYear.value}-12-31T23:59:59.999Z`],
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
},
},
pagination: {
@ -136,7 +136,13 @@ const { data: collections } = await useAsyncData("collection", () =>
withCount: true,
},
}
: {}),
: {
pagination: {
page: 1,
pageSize: 10,
withCount: true,
},
}),
})
);
collection.value = collections.value?.data;
@ -195,7 +201,7 @@ const displayedPagesNumbers = computed(() => {
function getNumber(index: number): number {
if (props.data?.lookup.inverse_count) {
return pagination.value.pageCount - numberOffset.value - index + 1;
return pagination.value.total - numberOffset.value - index;
} else {
return numberOffset.value + index + 1;
}
@ -221,7 +227,7 @@ async function changeTimedData(year: number) {
sort: "date:desc",
filters: {
date: {
$between: [`${activeYear.value}-01-01T00:00:00.000Z`, `${activeYear.value}-12-31T23:59:59.999Z`],
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
},
},
pagination: {
@ -230,6 +236,7 @@ async function changeTimedData(year: number) {
withCount: true,
},
});
console.log(data);
collection.value = data?.data;
pagination.value = (data?.meta.pagination as unknown as {
page: number;
@ -248,7 +255,7 @@ async function changeTimedPage(page: number = 1) {
sort: "date:desc",
filters: {
date: {
$between: [`${activeYear.value}-01-01T00:00:00.000Z`, `${activeYear.value}-12-31T23:59:59.999Z`],
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
},
},
pagination: {