1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-06-15 00:05:15 +02:00

Improve pagination & limit URL parameter handling

This commit is contained in:
Ralph Slooten
2024-06-02 16:07:26 +12:00
parent e87b98b73b
commit aa3f94457c
7 changed files with 114 additions and 59 deletions

View File

@ -2,7 +2,7 @@
import { mailbox } from '../stores/mailbox'
import CommonMixins from '../mixins/CommonMixins'
import dayjs from 'dayjs'
import {pagination} from "../stores/pagination";
import { pagination } from "../stores/pagination";
export default {
mixins: [
@ -16,6 +16,7 @@ export default {
data() {
return {
mailbox,
pagination,
}
},
@ -102,11 +103,17 @@ export default {
},
toTagUrl: function (t) {
const params = new URLSearchParams({
start: String(0),
limit: pagination.limit.toString(),
})
return '/search?q=' + this.tagEncodeURI(t) + '&' + params.toString()
if (t.match(/ /)) {
t = `"${t}"`
}
const p = {
q: 'tag:' + t
}
if (pagination.limit != pagination.defaultLimit) {
p.limit = pagination.limit.toString()
}
const params = new URLSearchParams(p)
return '/search?' + params.toString()
},
}
}
@ -153,6 +160,7 @@ export default {
</div>
<div v-if="message.Tags.length">
<RouterLink class="badge me-1" v-for="t in message.Tags" :to="toTagUrl(t)"
v-on:click="pagination.start = 0"
:style="mailbox.showTagColors ? { backgroundColor: colorHash(t) } : { backgroundColor: '#6c757d' }"
:title="'Filter messages tagged with ' + t">
{{ t }}