frontend use Lightbox to enlarge mail attachments
This commit is contained in:
parent
027cf4fca4
commit
7e3a151ead
3 changed files with 25 additions and 9 deletions
|
@ -3,7 +3,7 @@
|
||||||
<template #body>
|
<template #body>
|
||||||
<AuthenticatedImage
|
<AuthenticatedImage
|
||||||
class="img-fluid rounded mx-auto d-block mb-3 w-100"
|
class="img-fluid rounded mx-auto d-block mb-3 w-100"
|
||||||
:src="`/media/2/${file}/`"
|
:src="`/media/2/${hash}/`"
|
||||||
alt="Image not available."
|
alt="Image not available."
|
||||||
id="lightbox-image"
|
id="lightbox-image"
|
||||||
/>
|
/>
|
||||||
|
@ -21,7 +21,7 @@ import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
export default {
|
export default {
|
||||||
name: 'Lightbox',
|
name: 'Lightbox',
|
||||||
components: {Modal, AuthenticatedImage},
|
components: {Modal, AuthenticatedImage},
|
||||||
props: ['file']
|
props: ['hash']
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="timeline-item-wrapper">
|
<div class="timeline-item-wrapper">
|
||||||
|
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
|
||||||
<div class="timeline-item-description">
|
<div class="timeline-item-description">
|
||||||
<i class="avatar | small">
|
<i class="avatar | small">
|
||||||
<font-awesome-icon icon="user"/>
|
<font-awesome-icon icon="user"/>
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer" v-if="item.attachments.length">
|
<div class="card-footer" v-if="item.attachments.length">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="attachment in item.attachments">
|
<li v-for="attachment in item.attachments" @click="openLightboxModalWith(attachment)">
|
||||||
<AuthenticatedImage :src="`/media/2/256/${attachment.hash}/`" :alt="attachment.name"
|
<AuthenticatedImage :src="`/media/2/256/${attachment.hash}/`" :alt="attachment.name"
|
||||||
v-if="attachment.mime_type.startsWith('image/')"/>
|
v-if="attachment.mime_type.startsWith('image/')"/>
|
||||||
<AuthenticatedDataLink :href="`/media/2/256/${attachment.hash}/`" :download="attachment.name"
|
<AuthenticatedDataLink :href="`/media/2/256/${attachment.hash}/`" :download="attachment.name"
|
||||||
|
@ -58,10 +59,16 @@
|
||||||
|
|
||||||
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
import AuthenticatedDataLink from "@/components/AuthenticatedDataLink.vue";
|
import AuthenticatedDataLink from "@/components/AuthenticatedDataLink.vue";
|
||||||
|
import Lightbox from "@/components/Lightbox.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TimelineMail',
|
name: 'TimelineMail',
|
||||||
components: {AuthenticatedImage, AuthenticatedDataLink},
|
components: {Lightbox, AuthenticatedImage, AuthenticatedDataLink},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
lightboxHash: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
'item': {
|
'item': {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -76,7 +83,16 @@ export default {
|
||||||
return this.item.body.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br/>');
|
return this.item.body.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br/>');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
},
|
||||||
|
methods: {
|
||||||
|
openLightboxModalWith(attachment) {
|
||||||
|
this.lightboxHash = attachment.hash;
|
||||||
|
console.log(this.lightboxHash);
|
||||||
|
},
|
||||||
|
closeLightboxModal() { // Closes the editing modal and discards the edited copy of the item.
|
||||||
|
this.lightboxHash = null;
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
|
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
|
||||||
</template>
|
</template>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Lightbox v-if="lightboxItem" :file="lightboxItem.file" @close="closeLightboxModal()"/>
|
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
|
||||||
<div class="row" v-if="layout === 'table'">
|
<div class="row" v-if="layout === 'table'">
|
||||||
<div class="col-xl-8 offset-xl-2">
|
<div class="col-xl-8 offset-xl-2">
|
||||||
<Table
|
<Table
|
||||||
|
@ -84,7 +84,7 @@ import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
export default {
|
export default {
|
||||||
name: 'Items',
|
name: 'Items',
|
||||||
data: () => ({
|
data: () => ({
|
||||||
lightboxItem: null,
|
lightboxHash: null,
|
||||||
editingItem: null,
|
editingItem: null,
|
||||||
}),
|
}),
|
||||||
components: {AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem},
|
components: {AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem},
|
||||||
|
@ -92,10 +92,10 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['deleteItem', 'markItemReturned']),
|
...mapActions(['deleteItem', 'markItemReturned']),
|
||||||
openLightboxModalWith(item) {
|
openLightboxModalWith(item) {
|
||||||
this.lightboxItem = {...item};
|
this.lightboxHash = item.file;
|
||||||
},
|
},
|
||||||
closeLightboxModal() { // Closes the editing modal and discards the edited copy of the item.
|
closeLightboxModal() { // Closes the editing modal and discards the edited copy of the item.
|
||||||
this.lightboxItem = null;
|
this.lightboxHash = null;
|
||||||
},
|
},
|
||||||
openEditingModalWith(item) { // Opens the editing modal with a copy of the selected item.
|
openEditingModalWith(item) { // Opens the editing modal with a copy of the selected item.
|
||||||
this.editingItem = item;
|
this.editingItem = item;
|
||||||
|
|
Loading…
Reference in a new issue