2020-10-02 05:46:12 +00:00
|
|
|
<template>
|
|
|
|
<div class="status">
|
|
|
|
<div class="status-view">
|
2021-04-21 06:48:48 +00:00
|
|
|
<availability-status-badge :status="currentUserAvailabilityStatus" />
|
2020-10-02 05:46:12 +00:00
|
|
|
<div class="status-view--title">
|
2020-11-17 05:09:46 +00:00
|
|
|
{{ availabilityDisplayLabel }}
|
2020-10-02 05:46:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="status-change">
|
|
|
|
<transition name="menu-slide">
|
|
|
|
<div
|
|
|
|
v-if="isStatusMenuOpened"
|
|
|
|
v-on-clickaway="closeStatusMenu"
|
2021-03-20 07:38:56 +00:00
|
|
|
class="dropdown-pane dropdowm--top"
|
2020-10-02 05:46:12 +00:00
|
|
|
>
|
2021-03-20 07:38:56 +00:00
|
|
|
<woot-dropdown-menu>
|
|
|
|
<woot-dropdown-item
|
2020-11-04 06:53:44 +00:00
|
|
|
v-for="status in availabilityStatuses"
|
|
|
|
:key="status.value"
|
|
|
|
class="status-items"
|
|
|
|
>
|
2021-05-13 10:09:10 +00:00
|
|
|
<woot-button
|
|
|
|
variant="clear"
|
2021-05-20 08:21:46 +00:00
|
|
|
size="small"
|
|
|
|
color-scheme="secondary"
|
2021-05-13 10:09:10 +00:00
|
|
|
class-names="status-change--dropdown-button"
|
|
|
|
:is-disabled="status.disabled"
|
2021-10-07 07:51:46 +00:00
|
|
|
@click="
|
|
|
|
changeAvailabilityStatus(status.value, currentAccountId)
|
|
|
|
"
|
2020-10-02 05:46:12 +00:00
|
|
|
>
|
2021-04-21 06:48:48 +00:00
|
|
|
<availability-status-badge :status="status.value" />
|
2020-10-02 05:46:12 +00:00
|
|
|
{{ status.label }}
|
2021-05-13 10:09:10 +00:00
|
|
|
</woot-button>
|
2021-03-20 07:38:56 +00:00
|
|
|
</woot-dropdown-item>
|
|
|
|
</woot-dropdown-menu>
|
2020-10-02 05:46:12 +00:00
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
|
2021-05-13 10:09:10 +00:00
|
|
|
<woot-button
|
|
|
|
variant="clear"
|
|
|
|
color-scheme="secondary"
|
|
|
|
class-names="status-change--change-button link"
|
|
|
|
@click="openStatusMenu"
|
|
|
|
>
|
2020-10-02 05:46:12 +00:00
|
|
|
{{ $t('SIDEBAR_ITEMS.CHANGE_AVAILABILITY_STATUS') }}
|
2021-05-13 10:09:10 +00:00
|
|
|
</woot-button>
|
2020-10-02 05:46:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
2021-03-20 07:38:56 +00:00
|
|
|
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue';
|
|
|
|
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue';
|
2021-04-21 06:48:48 +00:00
|
|
|
import AvailabilityStatusBadge from '../widgets/conversation/AvailabilityStatusBadge';
|
2021-03-20 07:38:56 +00:00
|
|
|
|
2020-11-17 05:09:46 +00:00
|
|
|
const AVAILABILITY_STATUS_KEYS = ['online', 'busy', 'offline'];
|
2020-10-02 05:46:12 +00:00
|
|
|
|
|
|
|
export default {
|
2021-03-20 07:38:56 +00:00
|
|
|
components: {
|
|
|
|
WootDropdownMenu,
|
|
|
|
WootDropdownItem,
|
2021-04-21 06:48:48 +00:00
|
|
|
AvailabilityStatusBadge,
|
2021-03-20 07:38:56 +00:00
|
|
|
},
|
|
|
|
|
2020-10-02 05:46:12 +00:00
|
|
|
mixins: [clickaway],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isStatusMenuOpened: false,
|
|
|
|
isUpdating: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2021-10-07 07:51:46 +00:00
|
|
|
getCurrentUserAvailabilityStatus: 'getCurrentUserAvailabilityStatus',
|
|
|
|
getCurrentAccountId: 'getCurrentAccountId',
|
2020-10-02 05:46:12 +00:00
|
|
|
}),
|
2020-11-17 05:09:46 +00:00
|
|
|
availabilityDisplayLabel() {
|
|
|
|
const availabilityIndex = AVAILABILITY_STATUS_KEYS.findIndex(
|
|
|
|
key => key === this.currentUserAvailabilityStatus
|
|
|
|
);
|
|
|
|
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST')[
|
|
|
|
availabilityIndex
|
|
|
|
];
|
|
|
|
},
|
2021-10-07 07:51:46 +00:00
|
|
|
currentAccountId() {
|
|
|
|
return this.getCurrentAccountId;
|
|
|
|
},
|
2020-10-02 05:46:12 +00:00
|
|
|
currentUserAvailabilityStatus() {
|
2021-10-07 07:51:46 +00:00
|
|
|
return this.getCurrentUserAvailabilityStatus;
|
2020-10-02 05:46:12 +00:00
|
|
|
},
|
|
|
|
availabilityStatuses() {
|
|
|
|
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST').map(
|
2020-11-17 05:09:46 +00:00
|
|
|
(statusLabel, index) => ({
|
|
|
|
label: statusLabel,
|
|
|
|
value: AVAILABILITY_STATUS_KEYS[index],
|
|
|
|
disabled:
|
|
|
|
this.currentUserAvailabilityStatus ===
|
|
|
|
AVAILABILITY_STATUS_KEYS[index],
|
2020-10-02 05:46:12 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
openStatusMenu() {
|
|
|
|
this.isStatusMenuOpened = true;
|
|
|
|
},
|
|
|
|
closeStatusMenu() {
|
|
|
|
this.isStatusMenuOpened = false;
|
|
|
|
},
|
2021-10-07 07:51:46 +00:00
|
|
|
changeAvailabilityStatus(availability, accountId) {
|
2020-10-02 05:46:12 +00:00
|
|
|
if (this.isUpdating) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isUpdating = true;
|
|
|
|
this.$store
|
|
|
|
.dispatch('updateAvailability', {
|
2021-10-07 07:51:46 +00:00
|
|
|
availability: availability,
|
|
|
|
account_id: accountId,
|
2020-10-02 05:46:12 +00:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.isUpdating = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.status {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
2021-03-20 07:38:56 +00:00
|
|
|
padding: var(--space-micro) var(--space-smaller);
|
2020-10-02 05:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.status-view {
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
|
|
|
|
& &--title {
|
2021-03-20 07:38:56 +00:00
|
|
|
color: var(--b-600);
|
|
|
|
font-size: var(--font-size-small);
|
|
|
|
font-weight: var(--font-weight-medium);
|
|
|
|
margin-left: var(--space-small);
|
2020-10-02 05:46:12 +00:00
|
|
|
|
|
|
|
&:first-letter {
|
|
|
|
text-transform: capitalize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.status-change {
|
|
|
|
.dropdown-pane {
|
2021-03-20 07:38:56 +00:00
|
|
|
top: -132px;
|
2021-04-08 14:12:38 +00:00
|
|
|
right: var(--space-normal);
|
2020-10-02 05:46:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 06:53:44 +00:00
|
|
|
.status-items {
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
}
|
|
|
|
}
|
2020-10-02 05:46:12 +00:00
|
|
|
</style>
|