-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e232bf
commit 433f59b
Showing
6 changed files
with
87 additions
and
45 deletions.
There are no files selected for viewing
90 changes: 66 additions & 24 deletions
90
resources/js/console/components/Pagination/Pagination.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,101 @@ | ||
<template> | ||
<nav | ||
class="-mx-2 -my-2 sm:-mx-6 lg:-mx-8 gap-2 flex items-center justify-between border-t border-gray-200 bg-white py-3" | ||
class="-mx-2 sm:-mx-6 lg:-mx-8 gap-2 flex items-center justify-between bg-white py-3" | ||
aria-label="Pagination" | ||
> | ||
<div class="hidden sm:block pl-3"> | ||
<p class="text-sm text-gray-700"> | ||
Showing | ||
{{ ' ' }} | ||
<span class="font-medium">{{ from }}</span> | ||
{{ ' ' }} | ||
to | ||
{{ ' ' }} | ||
<span class="font-medium">{{ to }}</span> | ||
{{ ' ' }} | ||
of | ||
{{ ' ' }} | ||
<span class="font-medium">{{ total }}</span> | ||
<span class="font-medium">{{ totalRecords }}</span> | ||
{{ ' ' }} | ||
results | ||
</p> | ||
</div> | ||
<div class="flex flex-1 justify-between sm:justify-end"> | ||
<div class="flex flex-1 gap-3 justify-between sm:justify-end"> | ||
<button | ||
title="To first page" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
:disabled="current <= 1" | ||
@click="$emit('goToPage', 1)" | ||
> | ||
<ForwardIcon class="w-6 rotate-180" /> | ||
</button> | ||
<button | ||
v-if="current - 3 >= 1" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
:disabled="from <= 1" | ||
@click="$emit('prev')" | ||
disabled | ||
> | ||
Previous | ||
... | ||
</button> | ||
<button | ||
class="relative ml-3 inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
:disabled="to === total" | ||
@click="$emit('next')" | ||
v-if="current - 2 >= 1" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
@click="$emit('goToPage', current - 2)" | ||
> | ||
{{ current - 2 }} | ||
</button> | ||
<button | ||
v-if="current - 1 >= 1" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
@click="$emit('goToPage', current - 1)" | ||
> | ||
{{ current - 1 }} | ||
</button> | ||
<button | ||
disabled | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
> | ||
Next | ||
{{ current }} | ||
</button> | ||
<button | ||
v-if="current + 1 <= totalPages" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
@click="$emit('goToPage', current + 1)" | ||
> | ||
{{ current + 1 }} | ||
</button> | ||
<button | ||
v-if="current + 2 <= totalPages" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
@click="$emit('goToPage', current + 2)" | ||
> | ||
{{ current + 2 }} | ||
</button> | ||
<button | ||
v-if="current + 3 <= totalPages" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
disabled | ||
> | ||
... | ||
</button> | ||
<button | ||
title="To last page" | ||
class="relative inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0 disabled:text-gray-400" | ||
:disabled="current === totalPages" | ||
@click="$emit('goToPage', totalPages)" | ||
> | ||
<ForwardIcon class="w-6" /> | ||
</button> | ||
</div> | ||
</nav> | ||
</template> | ||
|
||
<script setup> | ||
import { ForwardIcon } from '@heroicons/vue/24/outline'; | ||
defineProps({ | ||
total: { | ||
totalPages: { | ||
type: Number, | ||
required: true, | ||
}, | ||
from: { | ||
totalRecords: { | ||
type: Number, | ||
required: true, | ||
}, | ||
to: { | ||
current: { | ||
type: Number, | ||
required: true, | ||
}, | ||
}); | ||
defineEmits(['next', 'prev']); | ||
defineEmits(['goToPage']); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters