Skip to content

A self-hosted media server and file management system

Make first and last page of table sticky if some are hidden with ...

aminnausin27f457b40e2c
diff --git a/resources/js/components/table/TablePagination.vue b/resources/js/components/table/TablePagination.vue
index b2383111..50b812ff 100644
--- a/resources/js/components/table/TablePagination.vue
+++ b/resources/js/components/table/TablePagination.vue
@@ -29,7 +29,7 @@ const pageRange = computed(() => {
<span class="font-medium dark:text-neutral-100">{{ Math.min(props.itemsPerPage * (currentPage), props.listLength) }}</span>
of
<span class="font-medium dark:text-neutral-100">{{ listLength }}</span>
- Results
+ <!-- Results -->
</p>
<nav id="pageinate">
<ul
@@ -38,7 +38,7 @@ const pageRange = computed(() => {
@click="$emit('setPage', Math.max(1, props.currentPage - 1))" />
<template v-if="pageCount > 5 && props.currentPage > 3">
- <TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="$emit('setPage', 1)" />
+ <TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="$emit('setPage', 1)" :sticky="true"/>
<TablePaginationButton :pageNumber="-1" :text="'...'" @click="$emit('setPage', Math.floor(currentPage/2))" :underline="true"/>
</template>
@@ -47,59 +47,11 @@ const pageRange = computed(() => {
<template v-if="pageCount > 5 && pageCount - props.currentPage > 2">
<TablePaginationButton :pageNumber="-1" :text="'...'" @click="$emit('setPage', Math.floor((pageCount - currentPage) / 2 + currentPage))" :underline="true"/>
- <TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="$emit('setPage', pageCount)"/>
+ <TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="$emit('setPage', pageCount)" :sticky="true"/>
</template>
<TablePaginationButton :pageNumber="-1" :text="'Next'"
@click="$emit('setPage', Math.min(pageCount, props.currentPage + 1))" />
-
- <!-- 1 ... 5 7 8 ... 12 - current is 7
-
- 1 ... 5 7 8 9 current is 8
-
- 1 2 3 4 ... 12
-
- 1 2 3 4 5 6 7 8 9 10
- 12 - 3 = 9 -> 9 > 3
- ie within 3 of start
-
- 9 < 3 not within 3 of end
-
- 12345
- 5 - 3 < 3
-
-
- if number is 1 .. 3 4 5 right
- so if number is greater than 3 add a ... between start and finish
-
-
-
- <li class="h-full">
- <button @click="$emit('setPage', Math.max(1, props.currentPage - 1))"
- class="relative inline-flex items-center h-full px-3 ml-0 rounded-l group hover:text-neutral-900">
- <span>Previous</span>
- </button>
- </li> -->
- <!-- <li v-for="page in pageCount" :key="page" :class="{'hidden' : props.currentPage !== page}" class="h-full md:block" >
- <button @click="$emit('setPage', page)" class="relative inline-flex items-center h-full px-3" :class="{'text-neutral-900 group bg-gray-50' : props.currentPage === page, 'group hover:text-neutral-900' : props.currentPage !== page}">
- <span>{{ page }}</span>
- <span v-if="props.currentPage === page"
- class="box-content absolute bottom-0 left-0 w-full h-px -mx-px translate-y-px border-l border-r bg-neutral-900 border-neutral-900"></span>
- <span v-else
- class="box-content absolute bottom-0 w-0 h-px -mx-px duration-200 ease-out translate-y-px border-transparent bg-neutral-900 group-hover:border-l group-hover:border-r group-hover:border-neutral-900 left-1/2 group-hover:left-0 group-hover:w-full"></span>
- </button>
- </li> -->
- <!-- <li class="hidden h-full md:block">
- <div class="relative inline-flex items-center h-full px-2.5 group">
- <span>...</span>
- </div>
- </li> -->
- <!-- <li class="h-full">
- <button @click="$emit('setPage', Math.min(pageCount, props.currentPage + 1))"
- class="relative inline-flex items-center h-full px-3 rounded-r group hover:text-neutral-900">
- <span>Next</span>
- </button>
- </li> -->
</ul>
</nav>
</div>
diff --git a/resources/js/components/table/TablePaginationButton.vue b/resources/js/components/table/TablePaginationButton.vue
index 8e673805..bdf78cd2 100644
--- a/resources/js/components/table/TablePaginationButton.vue
+++ b/resources/js/components/table/TablePaginationButton.vue
@@ -1,9 +1,9 @@
<script setup>
-const props = defineProps(['currentPage', 'pageNumber', 'text', 'underline']);
+const props = defineProps(['currentPage', 'pageNumber', 'text', 'underline', 'sticky']);
</script>
<template>
- <li :class="{ 'hidden': props.currentPage !== props.pageNumber && !props.text }" class="h-full md:block">
+ <li :class="{ 'hidden': props.currentPage !== props.pageNumber && !props.text && !props.sticky }" class="h-full md:block">
<button class="relative inline-flex items-center h-full px-3 group hover:text-neutral-900 hover:dark:text-neutral-50" :class="{ 'text-neutral-900 dark:text-neutral-50 bg-gray-50 dark:bg-neutral-900': props.currentPage === props.pageNumber, }">
<span>
{{ props?.text ?? props.pageNumber }}
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 4d8f6a32..b9f62571 100644
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -62,7 +62,6 @@ export const useContentStore = defineStore('Content', () => {
records.value = data?.data ?? []; // always overwrite because if limit is set and results cached, no request is made. Otherwise its a full request.
return Promise.resolve(records.value)
- //parseHistory(data.data);
}
async function createRecord(id){
diff --git a/resources/js/views/HistoryView.vue b/resources/js/views/HistoryView.vue
index 5113d232..77437ff5 100644
--- a/resources/js/views/HistoryView.vue
+++ b/resources/js/views/HistoryView.vue
@@ -16,7 +16,7 @@
const { pageTitle, selectedSideBar } = storeToRefs(appStore);
const { records } = storeToRefs(ContentStore);
const { getRecords, deleteRecord } = ContentStore;
- const loaded = ref(false);
+ // const loaded = ref(false);
const cachedID = ref(null);
const confirmModal = useModal({title: 'Delete Record?', submitText: 'Confim'});
@@ -36,7 +36,8 @@
selectedSideBar.value = '';
(async () => {
if( records.value.length <= 10 ) await getRecords();
- loaded.value = true;
+ // await getRecords();
+ // loaded.value = true;
})()
})
</script>
@@ -45,8 +46,6 @@
<LayoutBase>
<template v-slot:content>
<section id="content-history" class=" space-y-2 cursor-pointer min-h-[80vh] ">
- <!-- <RecordCardDetails v-for="record in records" :data="record" :key="record.id" @deleteRecord="handleDelete(record.id)"/> -->
-
<TableBase :data="records" :row="RecordCardDetails" :clickAction="handleDelete">
</TableBase>