Skip to content

Commit 60a6d94

Browse files
committed
option to allow anyone to edit or delete messages
1 parent 816f4da commit 60a6d94

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

src/ChatWindow.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
:always-scroll-to-bottom="alwaysScrollToBottom"
2222
:show-confirmation-deletion="showConfirmationDeletion"
2323
:confirmation-deletion-message="confirmationDeletionMessage"
24+
:any-one-can-edit="anyOneCanEdit"
25+
:any-one-can-delete="anyOneCanDelete"
2426
:message-styling="messageStyling"
2527
@scrollToTop="$emit('scrollToTop')"
2628
@remove="$emit('remove', $event)"
@@ -138,6 +140,14 @@ export default {
138140
confirmationDeletionMessage: {
139141
type: String,
140142
required: true
143+
},
144+
anyOneCanEdit: {
145+
type: Boolean,
146+
required: true
147+
},
148+
anyOneCanDelete: {
149+
type: Boolean,
150+
required: true
141151
}
142152
},
143153
data() {

src/Launcher.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
:show-file="showFile"
2525
:show-confirmation-deletion="showConfirmationDeletion"
2626
:confirmation-deletion-message="confirmationDeletionMessage"
27+
:any-one-can-edit="anyOneCanEdit"
28+
:any-one-can-delete="anyOneCanDelete"
2729
:show-header="showHeader"
2830
:placeholder="placeholder"
2931
:show-typing-indicator="showTypingIndicator"
@@ -114,6 +116,14 @@ export default {
114116
type: String,
115117
default: 'Do you really want to delete the message?'
116118
},
119+
anyOneCanEdit: {
120+
type: Boolean,
121+
default: false
122+
},
123+
anyOneCanDelete: {
124+
type: Boolean,
125+
default: false
126+
},
117127
isOpen: {
118128
type: Boolean,
119129
required: true

src/Message.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
:message-styling="messageStyling"
2828
:show-confirmation-deletion="showConfirmationDeletion"
2929
:confirmation-deletion-message="confirmationDeletionMessage"
30+
:any-one-can-edit="anyOneCanEdit"
31+
:any-one-can-delete="anyOneCanDelete"
3032
@remove="$emit('remove')"
3133
>
3234
<template v-slot:default="scopedProps">
@@ -102,6 +104,14 @@ export default {
102104
confirmationDeletionMessage: {
103105
type: String,
104106
required: true
107+
},
108+
anyOneCanEdit: {
109+
type: Boolean,
110+
required: true
111+
},
112+
anyOneCanDelete: {
113+
type: Boolean,
114+
required: true
105115
}
106116
},
107117
computed: {

src/MessageList.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
:message-styling="messageStyling"
1515
:show-confirmation-deletion="showConfirmationDeletion"
1616
:confirmation-deletion-message="confirmationDeletionMessage"
17+
:any-one-can-edit="anyOneCanEdit"
18+
:any-one-can-delete="anyOneCanDelete"
1719
@remove="$emit('remove', message)"
1820
>
1921
<template v-slot:user-avatar="scopedProps">
@@ -45,6 +47,8 @@
4547
:message-styling="messageStyling"
4648
:show-confirmation-deletion="showConfirmationDeletion"
4749
:confirmation-deletion-message="confirmationDeletionMessage"
50+
:any-one-can-edit="anyOneCanEdit"
51+
:any-one-can-delete="anyOneCanDelete"
4852
/>
4953
</div>
5054
</template>
@@ -89,6 +93,14 @@ export default {
8993
confirmationDeletionMessage: {
9094
type: String,
9195
required: true
96+
},
97+
anyOneCanEdit: {
98+
type: Boolean,
99+
required: true
100+
},
101+
anyOneCanDelete: {
102+
type: Boolean,
103+
required: true
92104
}
93105
},
94106
computed: {

src/messages/TextMessage.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<div class="sc-message--text" :style="messageColors">
33
<template>
44
<div class="sc-message--toolbox" :style="{background: messageColors.backgroundColor}">
5-
<button v-if="showEdition && me && message.id" :disabled="isEditing" @click="edit">
5+
<button v-if="showEdition && canEdit && message.id" :disabled="isEditing" @click="edit">
66
<IconBase :color="isEditing ? 'black' : messageColors.color" width="10" icon-name="edit">
77
<IconEdit />
88
</IconBase>
99
</button>
1010
<div v-if="showDeletion">
1111
<button
12-
v-if="me && message.id != null && message.id != undefined"
12+
v-if="canDelete && message.id != null && message.id != undefined"
1313
@click="
1414
ifelse(
1515
showConfirmationDeletion,
@@ -78,9 +78,23 @@ export default {
7878
confirmationDeletionMessage: {
7979
type: String,
8080
required: true
81+
},
82+
anyOneCanEdit: {
83+
type: Boolean,
84+
required: true
85+
},
86+
anyOneCanDelete: {
87+
type: Boolean,
88+
required: true
8189
}
8290
},
8391
computed: {
92+
canEdit() {
93+
return this.anyOneCanEdit || this.me
94+
},
95+
canDelete() {
96+
return this.anyOneCanDelete || this.me
97+
},
8498
messageText() {
8599
const escaped = escapeGoat.escape(this.message.data.text)
86100

0 commit comments

Comments
 (0)