fix: Show new message screen instead of input field (#4102)
This commit is contained in:
parent
3d7ca61481
commit
28d102f526
5 changed files with 32 additions and 22 deletions
|
@ -37,12 +37,13 @@ import CustomButton from 'shared/components/Button';
|
||||||
import ChatInputWrap from 'widget/components/ChatInputWrap.vue';
|
import ChatInputWrap from 'widget/components/ChatInputWrap.vue';
|
||||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
import { sendEmailTranscript } from 'widget/api/conversation';
|
import { sendEmailTranscript } from 'widget/api/conversation';
|
||||||
|
import routerMixin from 'widget/mixins/routerMixin';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ChatInputWrap,
|
ChatInputWrap,
|
||||||
CustomButton,
|
CustomButton,
|
||||||
},
|
},
|
||||||
|
mixins: [routerMixin],
|
||||||
props: {
|
props: {
|
||||||
msg: {
|
msg: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -53,7 +54,7 @@ export default {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
conversationAttributes: 'conversationAttributes/getConversationParams',
|
conversationAttributes: 'conversationAttributes/getConversationParams',
|
||||||
widgetColor: 'appConfig/getWidgetColor',
|
widgetColor: 'appConfig/getWidgetColor',
|
||||||
getConversationSize: 'conversation/getConversationSize',
|
conversationSize: 'conversation/getConversationSize',
|
||||||
currentUser: 'contacts/getCurrentUser',
|
currentUser: 'contacts/getCurrentUser',
|
||||||
isWidgetStyleFlat: 'appConfig/isWidgetStyleFlat',
|
isWidgetStyleFlat: 'appConfig/isWidgetStyleFlat',
|
||||||
}),
|
}),
|
||||||
|
@ -80,12 +81,11 @@ export default {
|
||||||
'clearConversationAttributes',
|
'clearConversationAttributes',
|
||||||
]),
|
]),
|
||||||
async handleSendMessage(content) {
|
async handleSendMessage(content) {
|
||||||
const conversationSize = this.getConversationSize;
|
|
||||||
await this.sendMessage({
|
await this.sendMessage({
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
// Update conversation attributes on new conversation
|
// Update conversation attributes on new conversation
|
||||||
if (conversationSize === 0) {
|
if (this.conversationSize === 0) {
|
||||||
this.getAttributes();
|
this.getAttributes();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -95,7 +95,12 @@ export default {
|
||||||
startNewConversation() {
|
startNewConversation() {
|
||||||
this.clearConversations();
|
this.clearConversations();
|
||||||
this.clearConversationAttributes();
|
this.clearConversationAttributes();
|
||||||
window.bus.$emit(BUS_EVENTS.START_NEW_CONVERSATION);
|
|
||||||
|
// To create a new conversation, we are redirecting
|
||||||
|
// the user to pre-chat with contact fields disabled
|
||||||
|
// Pass disableContactFields params to the route
|
||||||
|
// This would disable the contact fields in the pre-chat form
|
||||||
|
this.replaceRoute('prechat-form', { disableContactFields: true });
|
||||||
},
|
},
|
||||||
async sendTranscript() {
|
async sendTranscript() {
|
||||||
const { email } = this.currentUser;
|
const { email } = this.currentUser;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{{ headerMessage }}
|
{{ headerMessage }}
|
||||||
</div>
|
</div>
|
||||||
<form-input
|
<form-input
|
||||||
v-if="options.requireEmail"
|
v-if="areContactFieldsVisible"
|
||||||
v-model="fullName"
|
v-model="fullName"
|
||||||
class="mt-5"
|
class="mt-5"
|
||||||
:label="$t('PRE_CHAT_FORM.FIELDS.FULL_NAME.LABEL')"
|
:label="$t('PRE_CHAT_FORM.FIELDS.FULL_NAME.LABEL')"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<form-input
|
<form-input
|
||||||
v-if="options.requireEmail"
|
v-if="areContactFieldsVisible"
|
||||||
v-model="emailAddress"
|
v-model="emailAddress"
|
||||||
class="mt-5"
|
class="mt-5"
|
||||||
:label="$t('PRE_CHAT_FORM.FIELDS.EMAIL_ADDRESS.LABEL')"
|
:label="$t('PRE_CHAT_FORM.FIELDS.EMAIL_ADDRESS.LABEL')"
|
||||||
|
@ -77,6 +77,10 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
disableContactFields: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
validations() {
|
validations() {
|
||||||
const identityValidations = {
|
const identityValidations = {
|
||||||
|
@ -99,7 +103,7 @@ export default {
|
||||||
if (this.hasActiveCampaign) {
|
if (this.hasActiveCampaign) {
|
||||||
return identityValidations;
|
return identityValidations;
|
||||||
}
|
}
|
||||||
if (this.options.requireEmail) {
|
if (this.areContactFieldsVisible) {
|
||||||
return {
|
return {
|
||||||
...identityValidations,
|
...identityValidations,
|
||||||
...messageValidation,
|
...messageValidation,
|
||||||
|
@ -135,6 +139,9 @@ export default {
|
||||||
}
|
}
|
||||||
return this.options.preChatMessage;
|
return this.options.preChatMessage;
|
||||||
},
|
},
|
||||||
|
areContactFieldsVisible() {
|
||||||
|
return this.options.requireEmail && !this.disableContactFields;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
async replaceRoute(name) {
|
async replaceRoute(name, params = {}) {
|
||||||
if (this.$route.name !== name) {
|
if (this.$route.name !== name) {
|
||||||
return this.$router.replace({ name });
|
return this.$router.replace({ name, params });
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import configMixin from '../mixins/configMixin';
|
import configMixin from '../mixins/configMixin';
|
||||||
import TeamAvailability from 'widget/components/TeamAvailability';
|
import TeamAvailability from 'widget/components/TeamAvailability';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
|
||||||
import routerMixin from 'widget/mixins/routerMixin';
|
import routerMixin from 'widget/mixins/routerMixin';
|
||||||
export default {
|
export default {
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
|
@ -34,10 +33,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
isOnCollapsedView: false,
|
|
||||||
isOnNewConversation: false,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
|
@ -46,12 +42,6 @@ export default {
|
||||||
conversationSize: 'conversation/getConversationSize',
|
conversationSize: 'conversation/getConversationSize',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
bus.$on(BUS_EVENTS.START_NEW_CONVERSATION, () => {
|
|
||||||
this.isOnCollapsedView = true;
|
|
||||||
this.isOnNewConversation = true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
startConversation() {
|
startConversation() {
|
||||||
if (this.preChatFormEnabled && !this.conversationSize) {
|
if (this.preChatFormEnabled && !this.conversationSize) {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-1 overflow-auto">
|
<div class="flex flex-1 overflow-auto">
|
||||||
<pre-chat-form :options="preChatFormOptions" @submit="onSubmit" />
|
<pre-chat-form
|
||||||
|
:options="preChatFormOptions"
|
||||||
|
:disable-contact-fields="disableContactFields"
|
||||||
|
@submit="onSubmit"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -18,6 +22,10 @@ export default {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
conversationSize: 'conversation/getConversationSize',
|
conversationSize: 'conversation/getConversationSize',
|
||||||
}),
|
}),
|
||||||
|
disableContactFields() {
|
||||||
|
const { disableContactFields = false } = this.$route.params || {};
|
||||||
|
return disableContactFields;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
conversationSize(newSize, oldSize) {
|
conversationSize(newSize, oldSize) {
|
||||||
|
|
Loading…
Reference in a new issue