2023-09-22 15:06:03 +12:00
|
|
|
<script>
|
2025-06-20 23:26:06 +12:00
|
|
|
import NavSelected from "../components/NavSelected.vue";
|
|
|
|
import AjaxLoader from "./AjaxLoader.vue";
|
|
|
|
import CommonMixins from "../mixins/CommonMixins";
|
|
|
|
import { mailbox } from "../stores/mailbox";
|
|
|
|
import { pagination } from "../stores/pagination";
|
2023-09-22 15:06:03 +12:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
NavSelected,
|
|
|
|
AjaxLoader,
|
|
|
|
},
|
|
|
|
|
2025-06-20 23:26:06 +12:00
|
|
|
mixins: [CommonMixins],
|
|
|
|
|
2023-09-22 15:06:03 +12:00
|
|
|
props: {
|
|
|
|
modals: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2025-06-20 23:26:06 +12:00
|
|
|
},
|
2023-09-22 15:06:03 +12:00
|
|
|
},
|
|
|
|
|
2025-06-20 23:26:06 +12:00
|
|
|
emits: ["loadMessages"],
|
2023-09-22 15:06:03 +12:00
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mailbox,
|
|
|
|
pagination,
|
2025-06-20 23:26:06 +12:00
|
|
|
};
|
2023-09-22 15:06:03 +12:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2024-06-22 13:27:00 +12:00
|
|
|
reloadInbox() {
|
2025-06-20 23:26:06 +12:00
|
|
|
const paginationParams = this.getPaginationParams();
|
|
|
|
const reload = !paginationParams?.start;
|
2024-06-07 14:05:50 +12:00
|
|
|
|
2025-06-20 23:26:06 +12:00
|
|
|
this.$router.push("/");
|
2024-06-07 14:05:50 +12:00
|
|
|
if (reload) {
|
|
|
|
// already on first page, reload messages
|
2025-06-20 23:26:06 +12:00
|
|
|
this.loadMessages();
|
2024-06-07 14:05:50 +12:00
|
|
|
}
|
2023-09-22 15:06:03 +12:00
|
|
|
},
|
|
|
|
|
2024-06-22 13:27:00 +12:00
|
|
|
loadMessages() {
|
2025-06-20 23:26:06 +12:00
|
|
|
this.hideNav(); // hide mobile menu
|
|
|
|
this.$emit("loadMessages");
|
2023-09-22 15:06:03 +12:00
|
|
|
},
|
|
|
|
|
2024-06-22 13:27:00 +12:00
|
|
|
markAllRead() {
|
2025-06-20 23:26:06 +12:00
|
|
|
this.put(this.resolve(`/api/v1/messages`), { read: true }, (response) => {
|
|
|
|
window.scrollInPlace = true;
|
|
|
|
this.loadMessages();
|
|
|
|
});
|
2023-09-22 15:06:03 +12:00
|
|
|
},
|
|
|
|
|
2024-06-22 13:27:00 +12:00
|
|
|
deleteAllMessages() {
|
|
|
|
this.delete(this.resolve(`/api/v1/messages`), false, (response) => {
|
2025-06-20 23:26:06 +12:00
|
|
|
pagination.start = 0;
|
|
|
|
this.loadMessages();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2023-09-22 15:06:03 +12:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template v-if="!modals">
|
2025-06-20 23:26:06 +12:00
|
|
|
<div v-if="mailbox.uiConfig.Label" class="text-center badge text-bg-primary py-2 my-2 w-100">
|
2025-03-08 22:49:07 +13:00
|
|
|
<div class="text-truncate fw-normal" style="line-height: 1rem">
|
2024-09-07 17:34:42 +12:00
|
|
|
{{ mailbox.uiConfig.Label }}
|
|
|
|
</div>
|
2024-06-21 16:54:33 +12:00
|
|
|
</div>
|
|
|
|
|
2024-06-22 12:12:18 +12:00
|
|
|
<div class="list-group my-2" :class="mailbox.uiConfig.Label ? 'mt-0' : ''">
|
2025-06-20 23:26:06 +12:00
|
|
|
<button class="list-group-item list-group-item-action active" @click="reloadInbox">
|
|
|
|
<i v-if="mailbox.connected" class="bi bi-envelope-fill me-1"></i>
|
|
|
|
<i v-else class="bi bi-arrow-clockwise me-1"></i>
|
2023-09-22 15:06:03 +12:00
|
|
|
<span class="ms-1">Inbox</span>
|
2025-06-20 23:26:06 +12:00
|
|
|
<span
|
|
|
|
v-if="mailbox.unread"
|
|
|
|
class="badge rounded-pill ms-1 float-end text-bg-secondary"
|
|
|
|
title="Unread messages"
|
|
|
|
>
|
2023-09-22 15:06:03 +12:00
|
|
|
{{ formatNumber(mailbox.unread) }}
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<template v-if="!mailbox.selected.length">
|
2025-06-20 23:26:06 +12:00
|
|
|
<button
|
|
|
|
v-if="mailbox.skipConfirmations"
|
|
|
|
class="list-group-item list-group-item-action"
|
|
|
|
:disabled="!mailbox.messages_unread"
|
|
|
|
@click="markAllRead"
|
|
|
|
>
|
2025-02-02 15:31:18 +13:00
|
|
|
<i class="bi bi-eye-fill me-1"></i>
|
|
|
|
Mark all read
|
|
|
|
</button>
|
2025-06-20 23:26:06 +12:00
|
|
|
<button
|
|
|
|
v-else
|
|
|
|
class="list-group-item list-group-item-action"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#MarkAllReadModal"
|
|
|
|
:disabled="!mailbox.messages_unread"
|
|
|
|
>
|
2023-09-22 15:06:03 +12:00
|
|
|
<i class="bi bi-eye-fill me-1"></i>
|
|
|
|
Mark all read
|
|
|
|
</button>
|
2025-05-17 12:28:35 +12:00
|
|
|
<!-- checking if MessageRelay is defined prevents UI flicker while loading -->
|
|
|
|
<template v-if="mailbox.uiConfig.MessageRelay && !mailbox.uiConfig.HideDeleteAllButton">
|
2025-06-20 23:26:06 +12:00
|
|
|
<button
|
|
|
|
v-if="mailbox.skipConfirmations"
|
|
|
|
class="list-group-item list-group-item-action"
|
|
|
|
:disabled="!mailbox.total"
|
|
|
|
@click="deleteAllMessages"
|
|
|
|
>
|
2025-05-17 12:28:35 +12:00
|
|
|
<i class="bi bi-trash-fill me-1 text-danger"></i>
|
|
|
|
Delete all
|
|
|
|
</button>
|
2025-06-20 23:26:06 +12:00
|
|
|
<button
|
|
|
|
v-else
|
|
|
|
class="list-group-item list-group-item-action"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#DeleteAllModal"
|
|
|
|
:disabled="!mailbox.total"
|
|
|
|
>
|
2025-05-17 12:28:35 +12:00
|
|
|
<i class="bi bi-trash-fill me-1 text-danger"></i>
|
|
|
|
Delete all
|
|
|
|
</button>
|
|
|
|
</template>
|
2023-09-22 15:06:03 +12:00
|
|
|
</template>
|
|
|
|
|
2025-06-20 23:26:06 +12:00
|
|
|
<NavSelected @load-messages="loadMessages" />
|
2023-09-22 15:06:03 +12:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
<!-- Modals -->
|
2025-06-20 23:26:06 +12:00
|
|
|
<div
|
|
|
|
id="MarkAllReadModal"
|
|
|
|
class="modal fade"
|
|
|
|
tabindex="-1"
|
|
|
|
aria-labelledby="MarkAllReadModalLabel"
|
|
|
|
aria-hidden="true"
|
|
|
|
>
|
2023-09-22 15:06:03 +12:00
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
2025-06-20 23:26:06 +12:00
|
|
|
<h5 id="MarkAllReadModalLabel" class="modal-title">Mark all messages as read?</h5>
|
2023-09-22 15:06:03 +12:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
2025-06-20 23:26:06 +12:00
|
|
|
This will mark {{ formatNumber(mailbox.unread) }} message<span v-if="mailbox.unread > 1"
|
|
|
|
>s</span
|
|
|
|
>
|
|
|
|
as read.
|
2023-09-22 15:06:03 +12:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
2025-06-20 23:26:06 +12:00
|
|
|
<button type="button" class="btn btn-success" data-bs-dismiss="modal" @click="markAllRead">
|
|
|
|
Confirm
|
|
|
|
</button>
|
2023-09-22 15:06:03 +12:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2025-06-20 23:26:06 +12:00
|
|
|
<div
|
|
|
|
id="DeleteAllModal"
|
|
|
|
class="modal fade"
|
|
|
|
tabindex="-1"
|
|
|
|
aria-labelledby="DeleteAllModalLabel"
|
|
|
|
aria-hidden="true"
|
|
|
|
>
|
2023-09-22 15:06:03 +12:00
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
2025-06-20 23:26:06 +12:00
|
|
|
<h5 id="DeleteAllModalLabel" class="modal-title">Delete all messages?</h5>
|
2023-09-22 15:06:03 +12:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
2025-06-20 23:26:06 +12:00
|
|
|
This will permanently delete {{ formatNumber(mailbox.total) }} message<span
|
|
|
|
v-if="mailbox.total > 1"
|
|
|
|
>s</span
|
|
|
|
>.
|
2023-09-22 15:06:03 +12:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
2025-06-20 23:26:06 +12:00
|
|
|
<button type="button" class="btn btn-danger" data-bs-dismiss="modal" @click="deleteAllMessages">
|
|
|
|
Delete
|
|
|
|
</button>
|
2023-09-22 15:06:03 +12:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<AjaxLoader :loading="loading" />
|
|
|
|
</template>
|