2020-10-02 05:46:12 +00:00
|
|
|
<template>
|
2021-12-01 07:15:39 +00:00
|
|
|
<woot-dropdown-menu>
|
|
|
|
<woot-dropdown-header :title="$t('SIDEBAR.SET_AVAILABILITY_TITLE')" />
|
|
|
|
<woot-dropdown-item
|
|
|
|
v-for="status in availabilityStatuses"
|
|
|
|
:key="status.value"
|
|
|
|
class="status-items"
|
|
|
|
>
|
2021-05-13 10:09:10 +00:00
|
|
|
<woot-button
|
2021-12-01 07:15:39 +00:00
|
|
|
size="small"
|
|
|
|
:color-scheme="status.disabled ? '' : 'secondary'"
|
|
|
|
:variant="status.disabled ? 'smooth' : 'clear'"
|
|
|
|
class-names="status-change--dropdown-button"
|
|
|
|
@click="changeAvailabilityStatus(status.value)"
|
2021-05-13 10:09:10 +00:00
|
|
|
>
|
2021-12-01 07:15:39 +00:00
|
|
|
<availability-status-badge :status="status.value" />
|
|
|
|
{{ status.label }}
|
2021-05-13 10:09:10 +00:00
|
|
|
</woot-button>
|
2021-12-01 07:15:39 +00:00
|
|
|
</woot-dropdown-item>
|
|
|
|
<woot-dropdown-divider />
|
|
|
|
</woot-dropdown-menu>
|
2020-10-02 05:46:12 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
2021-12-01 07:15:39 +00:00
|
|
|
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem';
|
|
|
|
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
|
|
|
|
import WootDropdownHeader from 'shared/components/ui/dropdown/DropdownHeader';
|
|
|
|
import WootDropdownDivider from 'shared/components/ui/dropdown/DropdownDivider';
|
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: {
|
2021-12-01 07:15:39 +00:00
|
|
|
WootDropdownHeader,
|
|
|
|
WootDropdownDivider,
|
2021-03-20 07:38:56 +00:00
|
|
|
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-14 19:00:48 +00:00
|
|
|
getCurrentUserAvailability: 'getCurrentUserAvailability',
|
2022-04-14 15:24:26 +00:00
|
|
|
currentAccountId: 'getCurrentAccountId',
|
2020-10-02 05:46:12 +00:00
|
|
|
}),
|
2020-11-17 05:09:46 +00:00
|
|
|
availabilityDisplayLabel() {
|
|
|
|
const availabilityIndex = AVAILABILITY_STATUS_KEYS.findIndex(
|
2021-10-14 19:00:48 +00:00
|
|
|
key => key === this.currentUserAvailability
|
2020-11-17 05:09:46 +00:00
|
|
|
);
|
|
|
|
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST')[
|
|
|
|
availabilityIndex
|
|
|
|
];
|
|
|
|
},
|
2021-10-14 19:00:48 +00:00
|
|
|
currentUserAvailability() {
|
|
|
|
return this.getCurrentUserAvailability;
|
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:
|
2021-12-01 07:15:39 +00:00
|
|
|
this.currentUserAvailability === AVAILABILITY_STATUS_KEYS[index],
|
2020-10-02 05:46:12 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
openStatusMenu() {
|
|
|
|
this.isStatusMenuOpened = true;
|
|
|
|
},
|
|
|
|
closeStatusMenu() {
|
|
|
|
this.isStatusMenuOpened = false;
|
|
|
|
},
|
2021-12-01 07:15:39 +00:00
|
|
|
changeAvailabilityStatus(availability) {
|
|
|
|
const accountId = this.currentAccountId;
|
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>
|