mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-15 00:05:15 +02:00
Feature: Add pagination & limits to URL parameters (#303)
* Set search conditions to query parameters * Fixed by review * Update query parameters when new message notified
This commit is contained in:
committed by
Ralph Slooten
parent
31390e4b82
commit
e87b98b73b
@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import CommonMixins from '../mixins/CommonMixins'
|
||||
import { mailbox } from '../stores/mailbox'
|
||||
import { pagination } from '../stores/pagination'
|
||||
import {limitOptions, pagination} from '../stores/pagination'
|
||||
|
||||
export default {
|
||||
|
||||
@ -17,6 +17,7 @@ export default {
|
||||
return {
|
||||
pagination,
|
||||
mailbox,
|
||||
limitOptions,
|
||||
}
|
||||
},
|
||||
|
||||
@ -44,11 +45,13 @@ export default {
|
||||
changeLimit: function () {
|
||||
pagination.start = 0
|
||||
this.$emit('loadMessages')
|
||||
this.updateQueryParams()
|
||||
},
|
||||
|
||||
viewNext: function () {
|
||||
pagination.start = parseInt(pagination.start, 10) + parseInt(pagination.limit, 10)
|
||||
this.$emit('loadMessages')
|
||||
this.updateQueryParams()
|
||||
},
|
||||
|
||||
viewPrev: function () {
|
||||
@ -58,6 +61,17 @@ export default {
|
||||
}
|
||||
pagination.start = s
|
||||
this.$emit('loadMessages')
|
||||
this.updateQueryParams()
|
||||
},
|
||||
|
||||
updateQueryParams: function () {
|
||||
const path = this.$route.path
|
||||
const params = new URLSearchParams({
|
||||
...this.$route.query,
|
||||
start: pagination.start.toString(),
|
||||
limit: pagination.limit.toString(),
|
||||
})
|
||||
this.$router.push(path + '?' + params.toString())
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -66,10 +80,7 @@ export default {
|
||||
<template>
|
||||
<select v-model="pagination.limit" @change="changeLimit" class="form-select form-select-sm d-inline w-auto me-2"
|
||||
:disabled="total == 0">
|
||||
<option value="25">25</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<option value="200">200</option>
|
||||
<option v-for="option in limitOptions" :key="option" :value="option">{{option}}</option>
|
||||
</select>
|
||||
|
||||
<small>
|
||||
|
Reference in New Issue
Block a user