2021-05-13 10:10:36 +00:00
|
|
|
<template>
|
|
|
|
<div class="panel">
|
|
|
|
<contact-intro
|
|
|
|
:contact="contact"
|
|
|
|
@message="toggleConversationModal"
|
|
|
|
@edit="toggleEditModal"
|
|
|
|
/>
|
2021-05-21 13:52:47 +00:00
|
|
|
<contact-fields
|
|
|
|
:contact="contact"
|
|
|
|
@update="updateField"
|
|
|
|
@create-attribute="toggleCustomAttributeModal"
|
|
|
|
/>
|
2021-05-13 10:10:36 +00:00
|
|
|
<edit-contact
|
|
|
|
v-if="showEditModal"
|
|
|
|
:show="showEditModal"
|
|
|
|
:contact="contact"
|
|
|
|
@cancel="toggleEditModal"
|
|
|
|
/>
|
|
|
|
<new-conversation
|
2021-05-21 13:52:47 +00:00
|
|
|
v-if="enableNewConversation"
|
2021-05-13 10:10:36 +00:00
|
|
|
:show="showConversationModal"
|
|
|
|
:contact="contact"
|
|
|
|
@cancel="toggleConversationModal"
|
|
|
|
/>
|
2021-05-21 13:52:47 +00:00
|
|
|
<add-custom-attribute
|
|
|
|
:show="showCustomAttributeModal"
|
|
|
|
@cancel="toggleCustomAttributeModal"
|
|
|
|
@create="createCustomAttribute"
|
|
|
|
/>
|
2021-05-13 10:10:36 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import EditContact from 'dashboard/routes/dashboard/conversation/contact/EditContact';
|
|
|
|
import NewConversation from 'dashboard/routes/dashboard/conversation/contact/NewConversation';
|
2021-05-21 13:52:47 +00:00
|
|
|
import AddCustomAttribute from 'dashboard/modules/contact/components/AddCustomAttribute';
|
2021-05-13 10:10:36 +00:00
|
|
|
import ContactIntro from './ContactIntro';
|
|
|
|
import ContactFields from './ContactFields';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-05-21 13:52:47 +00:00
|
|
|
AddCustomAttribute,
|
|
|
|
ContactFields,
|
|
|
|
ContactIntro,
|
2021-05-13 10:10:36 +00:00
|
|
|
EditContact,
|
|
|
|
NewConversation,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
contact: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-05-21 13:52:47 +00:00
|
|
|
showCustomAttributeModal: false,
|
2021-05-13 10:10:36 +00:00
|
|
|
showEditModal: false,
|
|
|
|
showConversationModal: false,
|
|
|
|
};
|
|
|
|
},
|
2021-05-21 13:52:47 +00:00
|
|
|
computed: {
|
|
|
|
enableNewConversation() {
|
|
|
|
return this.contact && this.contact.id;
|
|
|
|
},
|
|
|
|
},
|
2021-05-13 10:10:36 +00:00
|
|
|
methods: {
|
2021-05-21 13:52:47 +00:00
|
|
|
toggleCustomAttributeModal() {
|
|
|
|
this.showCustomAttributeModal = !this.showCustomAttributeModal;
|
|
|
|
},
|
2021-05-13 10:10:36 +00:00
|
|
|
toggleEditModal() {
|
|
|
|
this.showEditModal = !this.showEditModal;
|
|
|
|
},
|
|
|
|
toggleConversationModal() {
|
|
|
|
this.showConversationModal = !this.showConversationModal;
|
|
|
|
},
|
2021-05-21 13:52:47 +00:00
|
|
|
createCustomAttribute(data) {
|
|
|
|
const { id } = this.contact;
|
|
|
|
const { attributeValue, attributeName } = data;
|
|
|
|
const updatedFields = {
|
|
|
|
id,
|
|
|
|
custom_attributes: {
|
|
|
|
[attributeName]: attributeValue,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
this.updateContact(updatedFields);
|
|
|
|
},
|
|
|
|
updateField(data) {
|
|
|
|
const { id } = this.contact;
|
|
|
|
const updatedFields = {
|
|
|
|
id,
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
this.updateContact(updatedFields);
|
|
|
|
},
|
|
|
|
updateContact(contactItem) {
|
|
|
|
this.$store.dispatch('contacts/update', contactItem);
|
|
|
|
},
|
2021-05-13 10:10:36 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.panel {
|
|
|
|
padding: var(--space-normal) var(--space-normal);
|
|
|
|
}
|
|
|
|
</style>
|