1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<script>
import axios from '~/lib/utils/axios_utils';
import Modal from '~/vue_shared/components/modal.vue';
export default {
name: 'NoteAttachment',
components: {
Modal,
},
props: {
attachment: {
type: Object,
required: true,
},
deleteAttachmentPath: {
type: String,
required: true,
},
},
data() {
return {
showModal: false,
loading: false,
};
},
methods: {
removeAttachment() {
this.loading = true;
axios({
url: this.deleteAttachmentPath,
method: 'delete',
})
.then((res) => {
this.showModal = false;
this.loading = false;
this.$emit('disableEditing');
})
.catch((err) => {
this.loading = false;
throw err;
});
}
}
};
</script>
<template>
<div class="note-attachment">
<a
v-if="attachment.image"
:href="attachment.url"
target="_blank"
rel="noopener noreferrer">
<img
:src="attachment.url"
class="note-image-attach"
/>
</a>
<div class="attachment">
<a
v-if="attachment.url"
:href="attachment.url"
target="_blank"
rel="noopener noreferrer">
<i
class="fa fa-paperclip"
aria-hidden="true">
</i>
{{ attachment.filename }}
</a>
<button
type="button"
class="btn btn-transparent"
title="Delete this attachment"
@click.prevent="showModal = true"
>
<i class="fa fa-trash-o cred" />
</button>
<modal
v-if="showModal"
kind="danger"
text="Are you sure you want to remove the attachment?"
primary-button-label="Remove attachment"
:submitDisabled="loading"
@submit="removeAttachment"
@cancel="showModal = false"
/>
</div>
</div>
</template>
|