A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: pagination issues again
aminnausin2a5bce45b0a1
diff --git a/resources/js/components/table/TablePagination.vue b/resources/js/components/table/TablePagination.vueindex a7330cde..9cd29e3e 100755--- a/resources/js/components/table/TablePagination.vue+++ b/resources/js/components/table/TablePagination.vue@@ -36,12 +36,12 @@ const pageRange = computed<number | number[]>(() => {// 1 2 or 3, then show 1 2 3 4... options should be 1 2 or more, so max - 1 or 3 whichever is higher// Threshold (by page selected) to show groups of pages at left end (ie 1, 2, [3], 4, ..., 10)- if (current <= edgeThreshold - 1) return Array.from({ length: edgeThreshold }, (_, i) => i + 1); // Number of pages to show with current page on left end (ie [1], 2, 3, 4, ..., 10) (inclusive)+ if (current <= edgeThreshold - 1) return Array.from({ length: edgeThreshold - 1 }, (_, i) => i + 1); // Number of pages to show with current page on left end (ie [1], 2, 3, 4, ..., 10) (inclusive)if (pageCount.value - current < edgeThreshold - 1) {// 7 8 9 or 10// Threshold (by page selected) to show group of pages at right end (ie 1, ..., 7, [8], 9, 10)let range: number[] = []; // Number of pages to show with current page on left end (ie 1, ..., 7, 8, 9, [10]) (exclusive so 3 items means 3 + 1 [the selected page])- for (let i = pageCount.value - edgeThreshold + 1; i <= pageCount.value; i++) {+ for (let i = pageCount.value - edgeThreshold + 2; i <= pageCount.value; i++) {range = [...range, i]; // Fill an array with all integers from pageCount - (number of items in group - 1) to pageCount}@@ -72,7 +72,13 @@ const handleSetPage = async (page: number) => {<ulclass="flex items-center text-sm leading-tight bg-white dark:bg-primary-dark-800/70 border divide-x rounded h-9 text-neutral-500 dark:text-neutral-300 divide-neutral-200 dark:divide-neutral-700 border-neutral-200 dark:border-neutral-700">- <TablePaginationButton :pageNumber="-1" :text="'Previous'" :disabled="props.currentPage === 1" @click="handleSetPage(Math.max(1, props.currentPage - 1))">+ <TablePaginationButton+ :pageNumber="-1"+ :text="'Previous'"+ :disabled="props.currentPage === 1"+ @click="handleSetPage(Math.max(1, props.currentPage - 1))"+ title="Previous Page"+ ><template #content v-if="useIcons"><ProiconsChevronLeft class="w-4 h-4" title="Previous" /></template>@@ -86,18 +92,36 @@ const handleSetPage = async (page: number) => {<!-- Diff between start and current page is greater than 2 --><template v-if="pageCount > props.maxVisiblePages && props.currentPage > Math.max(props.maxVisiblePages - 2, 2)">- <TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="handleSetPage(1)" :sticky="true" />- <TablePaginationButton :pageNumber="-1" :text="'...'" @click="handleSetPage(Math.floor(currentPage / 2))" :underline="true" />+ <TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="handleSetPage(1)" :sticky="true" v-if="maxVisiblePages > 3" />+ <TablePaginationButton+ :pageNumber="-1"+ :text="'...'"+ @click="handleSetPage(Math.floor(currentPage / 2))"+ :underline="true"+ :title="`Page ${Math.floor(currentPage / 2)}`"+ /></template>- <TablePaginationButton v-for="page in pageRange" :key="page" :pageNumber="page" :currentPage="props.currentPage" @click="handleSetPage(page)" />+ <TablePaginationButton v-for="page in pageRange" :key="page" :pageNumber="page" :currentPage="props.currentPage" @click="handleSetPage(page)" :title="`Page ${page}`" /><template v-if="pageCount > props.maxVisiblePages && pageCount - props.currentPage > Math.max(props.maxVisiblePages - 3, 1)">- <TablePaginationButton :pageNumber="-1" :text="'...'" @click="handleSetPage(Math.floor((pageCount - currentPage) / 2 + currentPage))" :underline="true" />- <TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="handleSetPage(pageCount)" :sticky="true" />+ <TablePaginationButton+ :pageNumber="-1"+ :text="'...'"+ :title="`Page ${Math.floor((pageCount - currentPage) / 2 + currentPage)}`"+ @click="handleSetPage(Math.floor((pageCount - currentPage) / 2 + currentPage))"+ :underline="true"+ />+ <TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="handleSetPage(pageCount)" :sticky="true" v-if="maxVisiblePages > 3" /></template>- <TablePaginationButton :pageNumber="-1" :text="'Next'" :disabled="props.currentPage === pageCount" @click="handleSetPage(Math.min(pageCount, props.currentPage + 1))">+ <TablePaginationButton+ :pageNumber="-1"+ :text="'Next'"+ :disabled="props.currentPage === pageCount"+ @click="handleSetPage(Math.min(pageCount, props.currentPage + 1))"+ title="Next Page"+ ><template #content v-if="useIcons"><ProiconsChevronRight class="w-4 h-4" title="Next" /></template>