Init Contact Panel (#206)

This commit is contained in:
Pranav Raj S 2019-11-14 13:46:43 +05:30 committed by GitHub
parent b985085786
commit 88fc4d894a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 11 deletions

View file

@ -44,8 +44,22 @@
.user--name { .user--name {
@include margin(0); @include margin(0);
font-size: $font-size-medium; font-size: $font-size-medium;
}
.user--profile__meta {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
margin-left: $space-slab; margin-left: $space-slab;
} }
.user--profile__button {
color: $color-woot;
font-size: $font-size-mini;
margin-top: $space-micro;
cursor: pointer;
}
} }
} }

View file

@ -4,6 +4,8 @@
.user-thumbnail { .user-thumbnail {
border-radius: 50%; border-radius: 50%;
height: 100%;
width: 100%;
} }
.source-badge { .source-badge {

View file

@ -13,12 +13,14 @@
class="user-thumbnail" class="user-thumbnail"
background-color="#1f93ff" background-color="#1f93ff"
color="white" color="white"
:size="avatarSize"
> >
</Avatar> </Avatar>
<img <img
v-if="badge === 'Facebook'" v-if="badge === 'Facebook'"
id="badge" id="badge"
class="source-badge" class="source-badge"
:style="badgeStyle"
src="~dashboard/assets/images/fb-badge.png" src="~dashboard/assets/images/fb-badge.png"
/> />
</div> </div>
@ -58,6 +60,15 @@ export default {
imgError: false, imgError: false,
}; };
}, },
computed: {
avatarSize() {
return Number(this.size.replace(/\D+/g, ''));
},
badgeStyle() {
const badgeSize = `${this.avatarSize / 3}px`;
return { width: badgeSize, height: badgeSize };
},
},
methods: { methods: {
onImgError() { onImgError() {
this.imgError = true; this.imgError = true;

View file

@ -1,7 +1,11 @@
<template> <template>
<div class="medium-8 columns conversation-wrap"> <div :class="conversationClass">
<div v-if="currentChat.id !== null" class="view-box columns"> <div v-if="currentChat.id !== null" class="view-box columns">
<conversation-header :chat="currentChat" /> <conversation-header
:chat="currentChat"
:is-contact-panel-open="isContactPanelOpen"
@contactPanelToggle="onToggleContactPanel"
/>
<ul class="conversation-panel"> <ul class="conversation-panel">
<transition name="slide-up"> <transition name="slide-up">
<li> <li>
@ -104,6 +108,10 @@ export default {
type: [Number, String], type: [Number, String],
required: true, required: true,
}, },
isContactPanelOpen: {
type: Boolean,
default: false,
},
}, },
data() { data() {
@ -124,6 +132,11 @@ export default {
fetchingInboxes: 'getInboxLoadingStatus', fetchingInboxes: 'getInboxLoadingStatus',
loadingChatList: 'getChatListLoadingStatus', loadingChatList: 'getChatListLoadingStatus',
}), }),
conversationClass() {
return `medium-${
this.isContactPanelOpen ? '5' : '8'
} columns conversation-wrap`;
},
// Loading indicator // Loading indicator
// Returns corresponding loading message // Returns corresponding loading message
loadingIndicatorMessage() { loadingIndicatorMessage() {
@ -193,6 +206,10 @@ export default {
}, 0); }, 0);
}, },
onToggleContactPanel() {
this.$emit('contactPanelToggle');
},
attachListner() { attachListner() {
this.conversationPanel = this.$el.querySelector('.conversation-panel'); this.conversationPanel = this.$el.querySelector('.conversation-panel');
this.heightBeforeLoad = this.heightBeforeLoad =

View file

@ -7,9 +7,17 @@
:badge="chat.meta.sender.channel" :badge="chat.meta.sender.channel"
:username="chat.meta.sender.name" :username="chat.meta.sender.name"
/> />
<h3 class="user--name"> <div class="user--profile__meta">
{{ chat.meta.sender.name }} <h3 class="user--name">
</h3> {{ chat.meta.sender.name }}
</h3>
<button
class="user--profile__button"
@click="$emit('contactPanelToggle')"
>
{{ viewProfileButtonLabel }}
</button>
</div>
</div> </div>
<div class="flex-container"> <div class="flex-container">
<div class="multiselect-box ion-headphone"> <div class="multiselect-box ion-headphone">
@ -49,7 +57,16 @@ export default {
ResolveButton, ResolveButton,
}, },
props: ['chat'], props: {
chat: {
type: Object,
default: () => {},
},
isContactPanelOpen: {
type: Boolean,
default: false,
},
},
data() { data() {
return { return {
@ -75,6 +92,9 @@ export default {
...this.agents, ...this.agents,
]; ];
}, },
viewProfileButtonLabel() {
return `${this.isContactPanelOpen ? 'Hide' : 'View'} Profile`;
},
}, },
methods: { methods: {
@ -89,9 +109,7 @@ export default {
}); });
}, },
removeAgent(agent) { removeAgent() {},
console.log(agent.email);
},
}, },
}; };
</script> </script>

View file

@ -0,0 +1,49 @@
<template>
<div class="medium-3 bg-white contact--panel">
<thumbnail
:src="contactImage"
size="80px"
:badge="contact.channel"
:username="contact.name"
/>
<h4>
{{ contact.name }}
</h4>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
export default {
components: {
Thumbnail,
},
computed: {
...mapGetters({
currentChat: 'getSelectedChat',
}),
contact() {
const { meta: { sender = {} } = {} } = this.currentChat || {};
return sender;
},
contactImage() {
return `/uploads/avatar/contact/${this.contact.id}/profilepic.jpeg`;
},
},
};
</script>
<style lang="scss" scoped>
@import '~dashboard/assets/scss/variables';
@import '~dashboard/assets/scss/mixins';
.contact--panel {
@include border-normal-left;
display: flex;
flex-direction: column;
padding: $space-large $space-normal $space-normal;
align-items: center;
}
</style>

View file

@ -1,7 +1,17 @@
<template> <template>
<section class="app-content columns"> <section class="app-content columns">
<chat-list :conversationInbox="inboxId" :pageTitle="$t('CHAT_LIST.TAB_HEADING')" ></chat-list> <chat-list
<conversation-box :inbox-id="inboxId"></conversation-box> :conversation-inbox="inboxId"
:page-title="$t('CHAT_LIST.TAB_HEADING')"
>
</chat-list>
<conversation-box
:inbox-id="inboxId"
:is-contact-panel-open="isContactPanelOpen"
@contactPanelToggle="onToggleContactPanel"
>
</conversation-box>
<contact-panel v-if="isContactPanelOpen"></contact-panel>
</section> </section>
</template> </template>
@ -11,17 +21,20 @@
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import ChatList from '../../../components/ChatList'; import ChatList from '../../../components/ChatList';
import ContactPanel from './ContactPanel';
import ConversationBox from '../../../components/widgets/conversation/ConversationBox'; import ConversationBox from '../../../components/widgets/conversation/ConversationBox';
export default { export default {
components: { components: {
ChatList, ChatList,
ContactPanel,
ConversationBox, ConversationBox,
}, },
data() { data() {
return { return {
pageTitle: this.$state, pageTitle: this.$state,
isContactPanelOpen: false,
}; };
}, },
computed: { computed: {
@ -62,6 +75,9 @@ export default {
bus.$emit('scrollToMessage'); bus.$emit('scrollToMessage');
}); });
}, },
onToggleContactPanel() {
this.isContactPanelOpen = !this.isContactPanelOpen;
},
}, },
}; };
</script> </script>