mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Now that the legacy v1 frontend (commit 064bdf53) is gone, the v2 directory is the only frontend and the v2 suffix is just noise. Renames resources/scripts-v2 to resources/scripts via git mv (so git records the move as renames, preserving blame and log --follow), then bulk-rewrites the 152 files that imported via @v2/... to use @/scripts/... instead. The existing @ alias (resources/) covers the new path with no extra config needed.
Drops the now-unused @v2 alias from vite.config.js and points the laravel-vite-plugin entry at resources/scripts/main.ts. Updates the only blade reference (resources/views/app.blade.php) to match. The package.json test script (eslint ./resources/scripts) automatically targets the right place after the rename without any edit.
Verified: npm run build exits clean and the Vite warning lines now reference resources/scripts/plugins/i18n.ts, confirming every import resolved through the new path. git log --follow on any moved file walks back through its scripts-v2 history.
373 lines
9.2 KiB
Vue
373 lines
9.2 KiB
Vue
<template>
|
|
<div
|
|
v-if="shouldShowPagination"
|
|
class="
|
|
flex
|
|
items-center
|
|
justify-between
|
|
px-4
|
|
py-3
|
|
bg-surface
|
|
border-t border-line-default
|
|
sm:px-6
|
|
"
|
|
>
|
|
<div class="flex justify-between flex-1 sm:hidden">
|
|
<a
|
|
href="#"
|
|
:class="{
|
|
'disabled cursor-normal pointer-events-none !bg-surface-tertiary !text-subtle':
|
|
pagination.currentPage === 1,
|
|
}"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
text-body
|
|
bg-surface
|
|
border border-line-default
|
|
rounded-md
|
|
hover:bg-hover
|
|
"
|
|
@click="pageClicked(pagination.currentPage - 1)"
|
|
>
|
|
{{ $t('general.pagination.previous') }}
|
|
</a>
|
|
<a
|
|
href="#"
|
|
:class="{
|
|
'disabled cursor-default pointer-events-none !bg-surface-tertiary !text-subtle':
|
|
pagination.currentPage === pagination.totalPages,
|
|
}"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
ml-3
|
|
text-sm
|
|
font-medium
|
|
text-body
|
|
bg-surface
|
|
border border-line-default
|
|
rounded-md
|
|
hover:bg-hover
|
|
"
|
|
@click="pageClicked(pagination.currentPage + 1)"
|
|
>
|
|
{{ $t('general.pagination.next') }}
|
|
</a>
|
|
</div>
|
|
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
|
<div>
|
|
<p class="text-sm text-body">
|
|
{{ $t('general.pagination.showing') }}
|
|
{{ ' ' }}
|
|
<span
|
|
v-if="pagination.limit && pagination.currentPage"
|
|
class="font-medium"
|
|
>
|
|
{{
|
|
pagination.currentPage * pagination.limit - (pagination.limit - 1)
|
|
}}
|
|
</span>
|
|
{{ ' ' }}
|
|
{{ $t('general.pagination.to') }}
|
|
{{ ' ' }}
|
|
<span
|
|
v-if="pagination.limit && pagination.currentPage"
|
|
class="font-medium"
|
|
>
|
|
<span
|
|
v-if="
|
|
pagination.currentPage * pagination.limit <=
|
|
pagination.totalCount
|
|
"
|
|
>
|
|
{{ pagination.currentPage * pagination.limit }}
|
|
</span>
|
|
<span v-else>
|
|
{{ pagination.totalCount }}
|
|
</span>
|
|
</span>
|
|
{{ ' ' }}
|
|
{{ $t('general.pagination.of') }}
|
|
{{ ' ' }}
|
|
<span v-if="pagination.totalCount" class="font-medium">
|
|
{{ pagination.totalCount }}
|
|
</span>
|
|
{{ ' ' }}
|
|
{{ $t('general.pagination.results') }}
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<nav
|
|
class="relative z-0 inline-flex -space-x-px rounded-lg shadow-sm"
|
|
aria-label="Pagination"
|
|
>
|
|
<a
|
|
href="#"
|
|
:class="{
|
|
'disabled cursor-normal pointer-events-none !bg-surface-tertiary !text-subtle':
|
|
pagination.currentPage === 1,
|
|
}"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-2
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
text-muted
|
|
bg-surface
|
|
border border-line-default
|
|
rounded-l-lg
|
|
hover:bg-hover
|
|
"
|
|
@click="pageClicked(pagination.currentPage - 1)"
|
|
>
|
|
<span class="sr-only">Previous</span>
|
|
<BaseIcon name="ChevronLeftIcon" />
|
|
</a>
|
|
<a
|
|
v-if="hasFirst"
|
|
href="#"
|
|
aria-current="page"
|
|
:class="{
|
|
'z-10 bg-primary-500 border-primary-500 text-white':
|
|
isActive(1),
|
|
'bg-surface border-line-default text-muted hover:bg-hover':
|
|
!isActive(1),
|
|
}"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
border
|
|
"
|
|
@click="pageClicked(1)"
|
|
>
|
|
1
|
|
</a>
|
|
|
|
<span
|
|
v-if="hasFirstEllipsis"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
text-body
|
|
bg-surface
|
|
border border-line-default
|
|
"
|
|
>
|
|
...
|
|
</span>
|
|
<a
|
|
v-for="page in pages"
|
|
:key="page"
|
|
href="#"
|
|
:class="{
|
|
'z-10 bg-primary-500 border-primary-500 text-white':
|
|
isActive(page),
|
|
'bg-surface border-line-default text-muted hover:bg-hover':
|
|
!isActive(page),
|
|
}"
|
|
class="
|
|
relative
|
|
items-center
|
|
hidden
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
border
|
|
md:inline-flex
|
|
"
|
|
@click="pageClicked(page)"
|
|
>
|
|
{{ page }}
|
|
</a>
|
|
|
|
<span
|
|
v-if="hasLastEllipsis"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
text-body
|
|
bg-surface
|
|
border border-line-default
|
|
"
|
|
>
|
|
...
|
|
</span>
|
|
<a
|
|
v-if="hasLast"
|
|
href="#"
|
|
aria-current="page"
|
|
:class="{
|
|
'z-10 bg-primary-500 border-primary-500 text-white':
|
|
isActive(pagination.totalPages),
|
|
'bg-surface border-line-default text-muted hover:bg-hover':
|
|
!isActive(pagination.totalPages),
|
|
}"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-4
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
border
|
|
"
|
|
@click="pageClicked(pagination.totalPages)"
|
|
>
|
|
{{ pagination.totalPages }}
|
|
</a>
|
|
<a
|
|
href="#"
|
|
class="
|
|
relative
|
|
inline-flex
|
|
items-center
|
|
px-2
|
|
py-2
|
|
text-sm
|
|
font-medium
|
|
text-muted
|
|
bg-surface
|
|
border border-line-default
|
|
rounded-r-lg
|
|
hover:bg-hover
|
|
"
|
|
:class="{
|
|
'disabled cursor-default pointer-events-none !bg-surface-tertiary !text-subtle':
|
|
pagination.currentPage === pagination.totalPages,
|
|
}"
|
|
@click="pageClicked(pagination.currentPage + 1)"
|
|
>
|
|
<span class="sr-only">Next</span>
|
|
<BaseIcon name="ChevronRightIcon" />
|
|
</a>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
|
|
export interface PaginationInfo {
|
|
currentPage: number
|
|
totalPages: number
|
|
totalCount: number
|
|
count: number
|
|
limit: number
|
|
}
|
|
|
|
interface Props {
|
|
pagination: PaginationInfo
|
|
}
|
|
|
|
interface Emits {
|
|
(e: 'pageChange', page: number): void
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
const emit = defineEmits<Emits>()
|
|
|
|
const pages = computed<number[]>(() => {
|
|
if (props.pagination.totalPages === undefined) return []
|
|
return pageLinks()
|
|
})
|
|
|
|
const hasFirst = computed<boolean>(() => {
|
|
return props.pagination.currentPage >= 4 || props.pagination.totalPages < 10
|
|
})
|
|
|
|
const hasLast = computed<boolean>(() => {
|
|
return (
|
|
props.pagination.currentPage <= props.pagination.totalPages - 3 ||
|
|
props.pagination.totalPages < 10
|
|
)
|
|
})
|
|
|
|
const hasFirstEllipsis = computed<boolean>(() => {
|
|
return (
|
|
props.pagination.currentPage >= 4 && props.pagination.totalPages >= 10
|
|
)
|
|
})
|
|
|
|
const hasLastEllipsis = computed<boolean>(() => {
|
|
return (
|
|
props.pagination.currentPage <= props.pagination.totalPages - 3 &&
|
|
props.pagination.totalPages >= 10
|
|
)
|
|
})
|
|
|
|
const shouldShowPagination = computed<boolean>(() => {
|
|
if (props.pagination.totalPages === undefined) {
|
|
return false
|
|
}
|
|
if (props.pagination.count === 0) {
|
|
return false
|
|
}
|
|
return props.pagination.totalPages > 1
|
|
})
|
|
|
|
function isActive(page: number): boolean {
|
|
const currentPage = props.pagination.currentPage || 1
|
|
return currentPage === page
|
|
}
|
|
|
|
function pageClicked(page: number): void {
|
|
if (
|
|
page === props.pagination.currentPage ||
|
|
page > props.pagination.totalPages ||
|
|
page < 1
|
|
) {
|
|
return
|
|
}
|
|
|
|
emit('pageChange', page)
|
|
}
|
|
|
|
function pageLinks(): number[] {
|
|
const pageList: number[] = []
|
|
let left = 2
|
|
let right = props.pagination.totalPages - 1
|
|
if (props.pagination.totalPages >= 10) {
|
|
left = Math.max(1, props.pagination.currentPage - 2)
|
|
right = Math.min(
|
|
props.pagination.currentPage + 2,
|
|
props.pagination.totalPages
|
|
)
|
|
}
|
|
for (let i = left; i <= right; i++) {
|
|
pageList.push(i)
|
|
}
|
|
return pageList
|
|
}
|
|
</script>
|