2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-08-25 14:29:28 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2021-01-17 19:24:20 +00:00
|
|
|
class="button resolve--button"
|
2019-08-25 14:29:28 +00:00
|
|
|
:class="buttonClass"
|
|
|
|
@click="toggleStatus"
|
|
|
|
>
|
2019-12-16 12:53:14 +00:00
|
|
|
<i v-if="!isLoading" class="icon" :class="buttonIconClass" />
|
2019-08-25 14:29:28 +00:00
|
|
|
<spinner v-if="isLoading" />
|
|
|
|
{{ currentStatus }}
|
2019-08-14 09:48:44 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2020-01-09 07:36:40 +00:00
|
|
|
import Spinner from 'shared/components/Spinner';
|
2020-02-26 15:45:01 +00:00
|
|
|
import wootConstants from '../../constants';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2020-02-26 15:45:01 +00:00
|
|
|
components: {
|
|
|
|
Spinner,
|
|
|
|
},
|
2020-08-17 05:55:13 +00:00
|
|
|
props: { conversationId: { type: [String, Number], required: true } },
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
currentChat: 'getSelectedChat',
|
|
|
|
}),
|
2020-08-17 05:55:13 +00:00
|
|
|
isOpen() {
|
|
|
|
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
currentStatus() {
|
2020-08-17 05:55:13 +00:00
|
|
|
return this.isOpen
|
|
|
|
? this.$t('CONVERSATION.HEADER.RESOLVE_ACTION')
|
|
|
|
: this.$t('CONVERSATION.HEADER.REOPEN_ACTION');
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
buttonClass() {
|
2020-08-17 05:55:13 +00:00
|
|
|
return this.isOpen ? 'success' : 'warning';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
buttonIconClass() {
|
2020-08-17 05:55:13 +00:00
|
|
|
return this.isOpen ? 'ion-checkmark' : 'ion-refresh';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleStatus() {
|
|
|
|
this.isLoading = true;
|
|
|
|
this.$store.dispatch('toggleStatus', this.currentChat.id).then(() => {
|
|
|
|
bus.$emit('newToastMessage', this.$t('CONVERSATION.CHANGE_STATUS'));
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|