2021-02-07 07:24:32 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-11-13 07:02:53 +00:00
|
|
|
export const DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER = [
|
2021-11-15 05:04:57 +00:00
|
|
|
{ name: 'conversation_actions' },
|
2021-11-13 07:02:53 +00:00
|
|
|
{ name: 'conversation_info' },
|
|
|
|
{ name: 'contact_attributes' },
|
|
|
|
{ name: 'previous_conversation' },
|
2022-09-23 10:34:46 +00:00
|
|
|
{ name: 'macros' },
|
2021-11-13 07:02:53 +00:00
|
|
|
];
|
|
|
|
export const DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER = [
|
|
|
|
{ name: 'contact_attributes' },
|
|
|
|
{ name: 'contact_labels' },
|
|
|
|
{ name: 'previous_conversation' },
|
|
|
|
];
|
2021-02-07 07:24:32 +00:00
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
uiSettings: 'getUISettings',
|
|
|
|
}),
|
2021-11-13 07:02:53 +00:00
|
|
|
conversationSidebarItemsOrder() {
|
2022-09-23 16:26:49 +00:00
|
|
|
const { conversation_sidebar_items_order: itemsOrder } = this.uiSettings;
|
2022-09-29 11:45:38 +00:00
|
|
|
// If the sidebar order is not set, use the default order.
|
2022-09-23 16:26:49 +00:00
|
|
|
if (!itemsOrder) {
|
|
|
|
return DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER;
|
|
|
|
}
|
2022-09-29 11:45:38 +00:00
|
|
|
|
|
|
|
// If the sidebar order doesn't have the new elements, then add them to the list.
|
|
|
|
DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER.forEach(item => {
|
|
|
|
if (!itemsOrder.find(i => i.name === item.name)) {
|
|
|
|
itemsOrder.push(item);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return itemsOrder;
|
2021-11-13 07:02:53 +00:00
|
|
|
},
|
|
|
|
contactSidebarItemsOrder() {
|
|
|
|
const { contact_sidebar_items_order: itemsOrder } = this.uiSettings;
|
|
|
|
return itemsOrder || DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER;
|
|
|
|
},
|
2021-02-07 07:24:32 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateUISettings(uiSettings = {}) {
|
|
|
|
this.$store.dispatch('updateUISettings', {
|
|
|
|
uiSettings: {
|
|
|
|
...this.uiSettings,
|
|
|
|
...uiSettings,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2021-09-13 12:38:58 +00:00
|
|
|
isContactSidebarItemOpen(key) {
|
|
|
|
const { [key]: isOpen } = this.uiSettings;
|
|
|
|
return !!isOpen;
|
|
|
|
},
|
|
|
|
toggleSidebarUIState(key) {
|
|
|
|
this.updateUISettings({ [key]: !this.isContactSidebarItemOpen(key) });
|
|
|
|
},
|
2021-02-07 07:24:32 +00:00
|
|
|
},
|
|
|
|
};
|