Skip to content

A self-hosted media server and file management system

fix: large number of pages are not efficiently shown in folder sidebar

aminnausin2e9800ecfc47
diff --git a/resources/js/components/cedar-ui/table/TablePagination.vue b/resources/js/components/cedar-ui/table/TablePagination.vue
index 1502ae94..32a3d930 100644
--- a/resources/js/components/cedar-ui/table/TablePagination.vue
+++ b/resources/js/components/cedar-ui/table/TablePagination.vue
@@ -84,11 +84,12 @@ const handleSetPage = async (page: number) => {
<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" v-if="maxVisiblePages > 3" />
<TablePaginationButton
- :pageNumber="-1"
- :text="'...'"
@click="handleSetPage(Math.floor(currentPage / 2))"
- :underline="true"
:title="`Page ${Math.floor(currentPage / 2)}`"
+ :class="'@4xs:block hidden'"
+ :text="'...'"
+ :pageNumber="-1"
+ :underline="true"
/>
</template>
@@ -96,10 +97,11 @@ const handleSetPage = async (page: number) => {
<template v-if="pageCount > props.maxVisiblePages && pageCount - props.currentPage > Math.max(props.maxVisiblePages - 3, 1)">
<TablePaginationButton
- :pageNumber="-1"
- :text="'...'"
- :title="`Page ${Math.floor((pageCount - currentPage) / 2 + currentPage)}`"
@click="handleSetPage(Math.floor((pageCount - currentPage) / 2 + currentPage))"
+ :title="`Page ${Math.floor((pageCount - currentPage) / 2 + currentPage)}`"
+ :class="'@4xs:block hidden'"
+ :text="'...'"
+ :pageNumber="-1"
:underline="true"
/>
<TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="handleSetPage(pageCount)" :sticky="true" v-if="maxVisiblePages > 3" />
@@ -126,3 +128,11 @@ const handleSetPage = async (page: number) => {
</ul>
</div>
</template>
+
+<style lang="css" scoped>
+.\@4xs\:block {
+ @container (width >= 12rem) {
+ display: block;
+ }
+}
+</style>
diff --git a/resources/js/components/panels/FolderSidebar.vue b/resources/js/components/panels/FolderSidebar.vue
index aaf727f1..1580eb9e 100644
--- a/resources/js/components/panels/FolderSidebar.vue
+++ b/resources/js/components/panels/FolderSidebar.vue
@@ -2,6 +2,7 @@
import type { FolderResource } from '@/types/resources';
import type { SortDir } from '@/types/types';
+import { useBreakpoints, breakpointsTailwind } from '@vueuse/core';
import { formatFileSize, toTitleCase } from '@/service/util';
import { folderSortingOptions } from '@/constants/sortingOptions';
import { useContentStore } from '@/stores/ContentStore';
@@ -33,6 +34,9 @@ const showFilters = ref(true);
const { stateDirectory, stateFolder } = storeToRefs(useContentStore());
+const breakpoints = useBreakpoints({ ...breakpointsTailwind, xs: 320, xms: 400, '3xl': 2000 });
+const maxVisiblePages = computed(() => (breakpoints.isSmaller('lg') ? 5 : 3));
+
const sortedFolders = computed<FolderResource[]>(() => {
return [...stateDirectory.value.folders].sort(sortObject<FolderResource>(folderSortKey.value, folderSortDir.value, ['created_at', 'updated_at']));
});
@@ -98,10 +102,10 @@ const handleFolderAction = (e: Event, id: number, action: 'edit' | 'share' = 'ed
stateFolderName: stateFolder?.name,
}"
:items-per-page="12"
- :max-visible-pages="3"
+ :max-visible-pages="maxVisiblePages"
:table-styles="cn('gap-3 sm:gap-2')"
:pagination-class="'justify-center! flex-col-reverse!'"
- :use-pagination-icons="false"
+ :use-pagination-icons="true"
:sort-action="
(sortKey: keyof FolderResource, sortDir: SortDir) => {
folderSortDir = sortDir;