Skip to content

Commit 2c60463

Browse files
committed
Finalized confirmation on deletion.
1 parent 9615646 commit 2c60463

File tree

11 files changed

+39
-11
lines changed

11 files changed

+39
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ For more detailed examples see the demo folder.
180180
| showFile | Boolean | A bool indicating whether or not to show the file chooser button
181181
| showDeletion | Boolean | A bool indicating whether or not to show the edit button for a message
182182
| showConfirmationDeletion | Boolean | A bool indicating whether or not to show the confirmation text when we remove a message
183+
| confirmationDeletionMessage | String | The message you want to show when confirming the deletion
183184
| showEdition | Boolean | A bool indicating whether or not to show the delete button for a message
184185
| showTypingIndicator | String | A string that can be set to a user's participant.id to show `typing` indicator for them
185186
| showHeader | Boolean | A bool indicating whether or not to show the header of chatwindow

demo/src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
:showEdition="true"
2424
:showDeletion="true"
2525
:showConfirmationDeletion="true"
26+
:confirmationDeletionMessage="'Are you sure? (you can customize this message)'"
2627
:titleImageUrl="titleImageUrl"
2728
@onType="handleOnType"
2829
@edit="editMessage"

demo/src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import App from './App.vue'
33
import Chat from '../../dist/vue-beautiful-chat.umd.min.js'
44
import vmodal from 'vue-js-modal'
55

6-
Vue.use(vmodal , { dialog: true })
6+
Vue.use(vmodal, {dialog: true})
77
Vue.use(Chat)
88

99
// eslint-disable-next-line

demo/vue.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
ifProd = () => process.env.NODE_ENV === 'production'
2+
13
module.exports = {
24
lintOnSave: false,
3-
productionSourceMap: false,
4-
publicPath: process.env.NODE_ENV === 'production' ? '/vue-beautiful-chat/' : '/',
5+
productionSourceMap: ifProd(),
6+
publicPath: ifProd() ? '/vue-beautiful-chat/' : '/',
57
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"build": "vue-cli-service build --target lib --name vue-beautiful-chat --formats umd-min src/index.js",
1111
"lint": "vue-cli-service lint",
12-
"watch": "npm run build -- --watch",
12+
"watch": "npm run build -- --mode development --watch",
1313
"prepublishOnly": "npm run build"
1414
},
1515
"files": [

src/ChatWindow.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
:show-edition="showEdition"
2626
:show-deletion="showDeletion"
2727
:show-confirmation-deletion="showConfirmationDeletion"
28+
:confirmation-deletion-message="confirmationDeletionMessage"
2829
:message-styling="messageStyling"
2930
@scrollToTop="$emit('scrollToTop')"
3031
@remove="$emit('remove', $event)"
@@ -124,7 +125,7 @@ export default {
124125
},
125126
placeholder: {
126127
type: String,
127-
default: 'Write a message...'
128+
required: true
128129
},
129130
showTypingIndicator: {
130131
type: String,
@@ -157,6 +158,10 @@ export default {
157158
showConfirmationDeletion: {
158159
type: Boolean,
159160
required: true
161+
},
162+
confirmationDeletionMessage: {
163+
type: String,
164+
required: true
160165
}
161166
},
162167
data() {

src/Launcher.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:show-edition="showEdition"
2929
:show-deletion="showDeletion"
3030
:show-confirmation-deletion="showConfirmationDeletion"
31+
:confirmation-deletion-message="confirmationDeletionMessage"
3132
:show-header="showHeader"
3233
:placeholder="placeholder"
3334
:show-typing-indicator="showTypingIndicator"
@@ -109,6 +110,10 @@ export default {
109110
type: Boolean,
110111
default: false
111112
},
113+
confirmationDeletionMessage: {
114+
type: String,
115+
default: 'Do you really want to delete the message?'
116+
},
112117
isOpen: {
113118
type: Boolean,
114119
required: true

src/Message.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:show-edition="showEdition"
2929
:show-deletion="showDeletion"
3030
:show-confirmation-deletion="showConfirmationDeletion"
31+
:confirmation-deletion-message="confirmationDeletionMessage"
3132
@remove="$emit('remove')"
3233
>
3334
<template v-slot:default="scopedProps">
@@ -108,6 +109,10 @@ export default {
108109
showConfirmationDeletion: {
109110
type: Boolean,
110111
required: true
112+
},
113+
confirmationDeletionMessage: {
114+
type: String,
115+
required: true
111116
}
112117
},
113118
computed: {

src/MessageList.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:show-edition="showEdition"
1616
:show-deletion="showDeletion"
1717
:show-confirmation-deletion="showConfirmationDeletion"
18+
:confirmation-deletion-message="confirmationDeletionMessage"
1819
@remove="$emit('remove', message)"
1920
>
2021
<template v-slot:user-avatar="scopedProps">
@@ -47,6 +48,7 @@
4748
:show-edition="showEdition"
4849
:show-deletion="showDeletion"
4950
:show-confirmation-deletion="showConfirmationDeletion"
51+
:confirmation-deletion-message="confirmationDeletionMessage"
5052
/>
5153
</div>
5254
</template>
@@ -95,6 +97,10 @@ export default {
9597
showConfirmationDeletion: {
9698
type: Boolean,
9799
required: true
100+
},
101+
confirmationDeletionMessage: {
102+
type: String,
103+
required: true,
98104
}
99105
},
100106
computed: {

src/messages/TextMessage.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</IconBase>
99
</button>
1010
<div v-if="showDeletion">
11-
<button v-if="me && message.id != null && message.id != undefined" @click="ifelse(showConfirmationDeletion, withConfirm('Do you really want to delete the message?', () => $emit('remove')), () => $emit('remove'))()">
11+
<button v-if="me && message.id != null && message.id != undefined" @click="ifelse(showConfirmationDeletion, withConfirm(confirmationDeletionMessage, () => $emit('remove')), () => $emit('remove'))()">
1212
<IconBase :color="messageColors.color" width="10" icon-name="remove">
1313
<IconCross />
1414
</IconBase>
@@ -72,6 +72,10 @@ export default {
7272
type: Boolean,
7373
required: true
7474
},
75+
confirmationDeletionMessage: {
76+
type: String,
77+
required: true
78+
}
7579
},
7680
computed: {
7781
messageText() {
@@ -101,10 +105,7 @@ export default {
101105
},
102106
withConfirm(msg, func) {
103107
return () => {
104-
if (confirm(msg)) {
105-
console.log(func)
106-
func()
107-
}
108+
if (confirm(msg)) func()
108109
}
109110
},
110111
},

0 commit comments

Comments
 (0)