2021-04-11 02:55:26 +02:00
|
|
|
<template>
|
2022-12-13 21:02:47 +01:00
|
|
|
<div class="justify-between flex items-baseline">
|
2021-04-11 02:55:26 +02:00
|
|
|
<div class="text-sm text-gray-500" v-html="desc"></div>
|
2022-12-13 21:02:47 +01:00
|
|
|
<div class="-mx-1 items-baseline" :class="{hidden: value.last_page == 1, flex: value.last_page > 1}">
|
2021-04-11 02:55:26 +02:00
|
|
|
<div class="pl-1 pr-3 text-gray-500 text-sm">Seite:</div>
|
2022-12-13 21:02:47 +01:00
|
|
|
<div class="px-1" v-for="(link, index) in links" :key="index">
|
2023-07-06 13:56:19 +02:00
|
|
|
<button
|
2022-12-13 21:02:47 +01:00
|
|
|
href="#"
|
|
|
|
@click.prevent="goto(link)"
|
|
|
|
class="rounded text-sm w-8 h-8 text-primary-100 flex items-center justify-center leading-none shadow"
|
|
|
|
:key="index"
|
|
|
|
v-text="link.page"
|
2021-04-11 02:55:26 +02:00
|
|
|
:class="{'bg-primary-700': link.current, 'bg-primary-900': !link.current}"
|
2023-07-06 13:56:19 +02:00
|
|
|
></button>
|
2021-04-11 02:55:26 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
only: {
|
2023-05-08 15:11:16 +02:00
|
|
|
default: null,
|
|
|
|
required: false,
|
2021-04-11 02:55:26 +02:00
|
|
|
},
|
|
|
|
value: {
|
2022-12-13 21:02:47 +01:00
|
|
|
required: true,
|
2021-04-11 02:55:26 +02:00
|
|
|
},
|
|
|
|
preserve: {
|
|
|
|
default: false,
|
2022-12-13 21:02:47 +01:00
|
|
|
type: Boolean,
|
|
|
|
},
|
2021-04-11 02:55:26 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
goto(page) {
|
2023-07-06 13:56:19 +02:00
|
|
|
if (this.$attrs.onReload) {
|
2023-05-08 15:11:16 +02:00
|
|
|
this.$emit('reload', page.page);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:32:57 +02:00
|
|
|
var params = new URLSearchParams(window.location.search);
|
|
|
|
params.set('page', page.page);
|
|
|
|
|
|
|
|
this.$inertia.visit(window.location.pathname + '?' + params.toString(), {
|
2021-04-11 02:55:26 +02:00
|
|
|
only: this.only,
|
2022-12-13 21:02:47 +01:00
|
|
|
preserveState: this.preserve,
|
2021-04-11 02:55:26 +02:00
|
|
|
});
|
2022-12-13 21:02:47 +01:00
|
|
|
},
|
2021-04-11 02:55:26 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
links() {
|
|
|
|
var links = [];
|
|
|
|
|
|
|
|
var from = Math.max(1, this.value.current_page - 3);
|
|
|
|
var to = Math.min(this.value.last_page, this.value.current_page + 3);
|
|
|
|
|
|
|
|
for (var i = from; i <= to; i++) {
|
|
|
|
links.push({
|
|
|
|
page: i,
|
2022-12-13 21:02:47 +01:00
|
|
|
current: i === this.value.current_page,
|
2021-04-11 02:55:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return links;
|
|
|
|
},
|
|
|
|
desc() {
|
|
|
|
return `${this.value.from} - ${this.value.to} von ${this.value.total} Einträgen`;
|
2022-12-13 21:02:47 +01:00
|
|
|
},
|
|
|
|
},
|
2021-04-11 02:55:26 +02:00
|
|
|
};
|
|
|
|
</script>
|