2020-10-02 05:46:12 +00:00
|
|
|
<template>
|
|
|
|
<div class="status">
|
|
|
|
<div class="status-view">
|
|
|
|
<div
|
2020-11-04 06:53:44 +00:00
|
|
|
:class="`status-badge status-badge__${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"
|
|
|
|
>
|
2020-10-02 05:46:12 +00:00
|
|
|
<button
|
|
|
|
class="button clear status-change--dropdown-button"
|
|
|
|
:disabled="status.disabled"
|
|
|
|
@click="changeAvailabilityStatus(status.value)"
|
|
|
|
>
|
2021-03-20 07:38:56 +00:00
|
|
|
<span :class="`status-badge status-badge__${status.value}`" />
|
2020-10-02 05:46:12 +00:00
|
|
|
{{ status.label }}
|
|
|
|
</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>
|
|
|
|
|
|
|
|
<button class="status-change--change-button" @click="openStatusMenu">
|
|
|
|
{{ $t('SIDEBAR_ITEMS.CHANGE_AVAILABILITY_STATUS') }}
|
|
|
|
</button>
|
|
|
|
</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';
|
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
|
2020-10-02 05:46:12 +00:00
|
|
|
mixins: [clickaway],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isStatusMenuOpened: false,
|
|
|
|
isUpdating: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
currentUser: 'getCurrentUser',
|
|
|
|
}),
|
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
|
|
|
|
];
|
|
|
|
},
|
2020-10-02 05:46:12 +00:00
|
|
|
currentUserAvailabilityStatus() {
|
|
|
|
return this.currentUser.availability_status;
|
|
|
|
},
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
changeAvailabilityStatus(availability) {
|
|
|
|
if (this.isUpdating) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isUpdating = true;
|
|
|
|
|
|
|
|
this.$store
|
|
|
|
.dispatch('updateAvailability', {
|
|
|
|
availability,
|
|
|
|
})
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-20 07:38:56 +00:00
|
|
|
.status-badge {
|
|
|
|
width: var(--space-one);
|
|
|
|
height: var(--space-one);
|
|
|
|
margin-right: var(--space-micro);
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
|
|
&__online {
|
|
|
|
background: var(--g-400);
|
|
|
|
}
|
|
|
|
|
|
|
|
&__offline {
|
|
|
|
background: var(--b-600);
|
|
|
|
}
|
|
|
|
|
|
|
|
&__busy {
|
|
|
|
background: var(--y-700);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 05:46:12 +00:00
|
|
|
.status-change {
|
|
|
|
.dropdown-pane {
|
2021-03-20 07:38:56 +00:00
|
|
|
top: -132px;
|
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
|
|
|
& &--change-button {
|
2021-03-20 07:38:56 +00:00
|
|
|
color: var(--b-600);
|
|
|
|
font-size: var(--font-size-small);
|
2020-10-02 05:46:12 +00:00
|
|
|
cursor: pointer;
|
2021-03-20 07:38:56 +00:00
|
|
|
outline: none;
|
2020-10-02 05:46:12 +00:00
|
|
|
|
|
|
|
&:hover {
|
2021-03-20 07:38:56 +00:00
|
|
|
color: var(--w-600);
|
2020-10-02 05:46:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-04 06:53:44 +00:00
|
|
|
}
|
2020-10-02 05:46:12 +00:00
|
|
|
</style>
|