2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-04-07 06:14:58 +00:00
|
|
|
<div class="resolve-actions">
|
|
|
|
<div class="button-group">
|
|
|
|
<woot-button
|
|
|
|
v-if="isOpen"
|
|
|
|
class-names="resolve"
|
|
|
|
color-scheme="success"
|
|
|
|
icon="ion-checkmark"
|
|
|
|
:is-loading="isLoading"
|
|
|
|
@click="() => toggleStatus(STATUS_TYPE.RESOLVED)"
|
|
|
|
>
|
|
|
|
{{ this.$t('CONVERSATION.HEADER.RESOLVE_ACTION') }}
|
|
|
|
</woot-button>
|
|
|
|
<woot-button
|
|
|
|
v-else-if="isResolved"
|
|
|
|
class-names="resolve"
|
|
|
|
color-scheme="warning"
|
|
|
|
icon="ion-refresh"
|
|
|
|
:is-loading="isLoading"
|
|
|
|
@click="() => toggleStatus(STATUS_TYPE.OPEN)"
|
|
|
|
>
|
|
|
|
{{ this.$t('CONVERSATION.HEADER.REOPEN_ACTION') }}
|
|
|
|
</woot-button>
|
|
|
|
<woot-button
|
|
|
|
v-else-if="isBot"
|
|
|
|
class-names="resolve"
|
|
|
|
color-scheme="primary"
|
|
|
|
icon="ion-person"
|
|
|
|
:is-loading="isLoading"
|
|
|
|
@click="() => toggleStatus(STATUS_TYPE.OPEN)"
|
|
|
|
>
|
|
|
|
{{ this.$t('CONVERSATION.HEADER.OPEN_ACTION') }}
|
|
|
|
</woot-button>
|
|
|
|
<woot-button
|
|
|
|
v-if="showDropDown"
|
|
|
|
:color-scheme="buttonClass"
|
|
|
|
:disabled="isLoading"
|
|
|
|
icon="ion-arrow-down-b"
|
|
|
|
@click="openDropdown"
|
|
|
|
>
|
|
|
|
</woot-button>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="showDropdown"
|
|
|
|
v-on-clickaway="closeDropdown"
|
|
|
|
class="dropdown-pane dropdown-pane--open"
|
|
|
|
>
|
|
|
|
<woot-dropdown-menu>
|
|
|
|
<woot-dropdown-item v-if="!isBot">
|
|
|
|
<woot-button
|
|
|
|
variant="clear"
|
|
|
|
@click="() => toggleStatus(STATUS_TYPE.BOT)"
|
|
|
|
>
|
|
|
|
{{ this.$t('CONVERSATION.RESOLVE_DROPDOWN.OPEN_BOT') }}
|
|
|
|
</woot-button>
|
|
|
|
</woot-dropdown-item>
|
|
|
|
</woot-dropdown-menu>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2021-04-07 06:14:58 +00:00
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
|
|
|
|
|
|
|
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue';
|
|
|
|
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue';
|
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: {
|
2021-04-07 06:14:58 +00:00
|
|
|
WootDropdownItem,
|
|
|
|
WootDropdownMenu,
|
2020-02-26 15:45:01 +00:00
|
|
|
},
|
2021-04-07 06:14:58 +00:00
|
|
|
mixins: [clickaway, alertMixin],
|
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,
|
2021-04-07 06:14:58 +00:00
|
|
|
showDropdown: false,
|
|
|
|
STATUS_TYPE: wootConstants.STATUS_TYPE,
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
currentChat: 'getSelectedChat',
|
|
|
|
}),
|
2020-08-17 05:55:13 +00:00
|
|
|
isOpen() {
|
|
|
|
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN;
|
|
|
|
},
|
2021-04-07 06:14:58 +00:00
|
|
|
isBot() {
|
|
|
|
return this.currentChat.status === wootConstants.STATUS_TYPE.BOT;
|
|
|
|
},
|
|
|
|
isResolved() {
|
|
|
|
return this.currentChat.status === wootConstants.STATUS_TYPE.RESOLVED;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
buttonClass() {
|
2021-04-07 06:14:58 +00:00
|
|
|
if (this.isBot) return 'primary';
|
|
|
|
if (this.isOpen) return 'success';
|
|
|
|
if (this.isResolved) return 'warning';
|
|
|
|
return '';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-04-07 06:14:58 +00:00
|
|
|
showDropDown() {
|
|
|
|
return !this.isBot;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2021-04-07 06:14:58 +00:00
|
|
|
closeDropdown() {
|
|
|
|
this.showDropdown = false;
|
|
|
|
},
|
|
|
|
openDropdown() {
|
|
|
|
this.showDropdown = true;
|
|
|
|
},
|
|
|
|
toggleStatus(status) {
|
|
|
|
this.closeDropdown();
|
2019-08-14 09:48:44 +00:00
|
|
|
this.isLoading = true;
|
2021-04-07 06:14:58 +00:00
|
|
|
this.$store
|
|
|
|
.dispatch('toggleStatus', {
|
|
|
|
conversationId: this.currentChat.id,
|
|
|
|
status,
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.showAlert(this.$t('CONVERSATION.CHANGE_STATUS'));
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2021-04-07 06:14:58 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.resolve-actions {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
2021-04-19 16:47:02 +00:00
|
|
|
|
2021-04-07 06:14:58 +00:00
|
|
|
.dropdown-pane {
|
|
|
|
left: unset;
|
|
|
|
top: 4.2rem;
|
|
|
|
margin-top: var(--space-micro);
|
|
|
|
right: 0;
|
|
|
|
max-width: 20rem;
|
|
|
|
}
|
|
|
|
</style>
|