Skip to content

A self-hosted media server and file management system

fix: table pagination overflow

aminnausin2704dfdde28b
diff --git a/resources/js/components/panels/VideoSidebar.vue b/resources/js/components/panels/VideoSidebar.vue
index 79ce7f61..75eb61de 100755
--- a/resources/js/components/panels/VideoSidebar.vue
+++ b/resources/js/components/panels/VideoSidebar.vue
@@ -80,6 +80,7 @@ watch(
}"
:items-per-page="10"
:pagination-class="'!justify-center !flex-col-reverse'"
+ :use-pagination-icons="true"
/>
</section>
<section v-if="selectedSideBar === 'history'" id="list-content-history" class="flex gap-2 flex-wrap">
diff --git a/resources/js/components/table/TableBase.vue b/resources/js/components/table/TableBase.vue
index 2eb36c32..e95c67d6 100755
--- a/resources/js/components/table/TableBase.vue
+++ b/resources/js/components/table/TableBase.vue
@@ -23,6 +23,7 @@ const props = withDefaults(defineProps<TableProps<T>>(), {
selectedID: null,
startAscending: true,
searchQuery: '',
+ usePaginationIcons: false,
});
const emit = defineEmits<{
@@ -141,6 +142,7 @@ onMounted(() => {
:listLength="props.data?.length ?? 0"
:itemsPerPage="tableData.fields.itemsPerPage"
:currentPage="tableData.fields.currentPage"
+ :useIcons="props.usePaginationIcons"
@setPage="tableData.handlePageChange"
/>
</section>
diff --git a/resources/js/components/table/TablePagination.vue b/resources/js/components/table/TablePagination.vue
index 552154d9..b7ce45c9 100755
--- a/resources/js/components/table/TablePagination.vue
+++ b/resources/js/components/table/TablePagination.vue
@@ -1,12 +1,17 @@
<script setup lang="ts">
import { computed, nextTick, ref } from 'vue';
-import TablePaginationButton from './TablePaginationButton.vue';
+import TablePaginationButton from '@/components/table/TablePaginationButton.vue';
+
+import ProiconsChevronRight from '~icons/proicons/chevron-right';
+import ProiconsArrowImport from '~icons/proicons/arrow-import';
+import ProiconsChevronLeft from '~icons/proicons/chevron-left';
const props = defineProps<{
listLength: number;
currentPage: number;
itemsPerPage: number;
+ useIcons: boolean;
}>();
const $element = ref<null | HTMLElement>(null);
@@ -48,12 +53,22 @@ const handleSetPage = async (page: number) => {
<span class="font-medium dark:text-neutral-100">{{ listLength }}</span>
<!-- Results -->
</p>
- <nav>
- <ul
- class="flex flex-wrap 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-200 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))" />
+ <ul
+ class="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-200 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))">
+ <template #content v-if="useIcons">
+ <ProiconsChevronLeft class="w-4 h-4" title="Previous" />
+ </template>
+ <template #content v-else>
+ <span class="hidden sm:block">
+ {{ 'Previous' }}
+ </span>
+ <ProiconsChevronLeft class="w-4 h-4 sm:hidden" title="Previous" />
+ </template>
+ </TablePaginationButton>
+ <span class="flex flex-wrap items-center h-full divide-x divide-neutral-200 dark:divide-neutral-700">
<template v-if="pageCount > 5 && props.currentPage > 3">
<TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="handleSetPage(1)" :sticky="true" />
<TablePaginationButton :pageNumber="-1" :text="'...'" @click="handleSetPage(Math.floor(currentPage / 2))" :underline="true" />
@@ -65,14 +80,19 @@ const handleSetPage = async (page: number) => {
<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" />
</template>
+ </span>
- <TablePaginationButton
- :pageNumber="-1"
- :text="'Next'"
- :disabled="props.currentPage === pageCount"
- @click="handleSetPage(Math.min(pageCount, props.currentPage + 1))"
- />
- </ul>
- </nav>
+ <TablePaginationButton :pageNumber="-1" :text="'Next'" :disabled="props.currentPage === pageCount" @click="handleSetPage(Math.min(pageCount, props.currentPage + 1))">
+ <template #content v-if="useIcons">
+ <ProiconsChevronRight class="w-4 h-4" title="Next" />
+ </template>
+ <template #content v-else>
+ <span class="hidden sm:block">
+ {{ 'Previous' }}
+ </span>
+ <ProiconsChevronRight class="w-4 h-4 sm:hidden" title="Next" />
+ </template>
+ </TablePaginationButton>
+ </ul>
</div>
</template>
diff --git a/resources/js/components/table/TablePaginationButton.vue b/resources/js/components/table/TablePaginationButton.vue
index 9371a943..09ac6749 100755
--- a/resources/js/components/table/TablePaginationButton.vue
+++ b/resources/js/components/table/TablePaginationButton.vue
@@ -1,5 +1,19 @@
-<script setup>
-const props = defineProps(['currentPage', 'pageNumber', 'text', 'underline', 'sticky', 'disabled']);
+<script setup lang="ts">
+const props = withDefaults(
+ defineProps<{
+ currentPage?: number;
+ pageNumber?: number;
+ text?: string;
+ underline?: boolean;
+ sticky?: boolean;
+ disabled?: boolean;
+ }>(),
+ {
+ underline: false,
+ sticky: false,
+ disabled: false,
+ },
+);
</script>
<template>
@@ -9,9 +23,11 @@ const props = defineProps(['currentPage', 'pageNumber', 'text', 'underline', 'st
:class="{ 'text-neutral-900 dark:text-neutral-50 bg-gray-50 dark:bg-neutral-900': props.currentPage === props.pageNumber }"
:disabled="props.disabled ?? false"
>
- <span>
- {{ props?.text ?? props.pageNumber }}
- </span>
+ <slot name="content">
+ <span>
+ {{ props?.text ?? props.pageNumber }}
+ </span>
+ </slot>
<span
v-if="!props.text || props.underline"
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index df2733db..e49f762c 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -265,6 +265,7 @@ export declare type SortOption = {
export interface TableProps<T> {
useToolbar?: boolean;
usePagination?: boolean;
+ usePaginationIcons?: boolean;
useGrid?: string;
data: T[];
row: DefineComponent<any, any, any> | Component;