mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 11:08:04 +00:00 
			
		
		
		
	 7fd8b4d03a
			
		
	
	7fd8b4d03a
	
	
	
		
			
			Porting changes from https://github.com/chatwoot/chatwoot/pull/10552 --------- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com> Co-authored-by: Sojan <sojan@pepalo.com> Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Pranav <pranavrajs@gmail.com>
		
			
				
	
	
		
			186 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			186 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <script setup>
 | |
| import { computed } from 'vue';
 | |
| import { useUISettings } from 'dashboard/composables/useUISettings';
 | |
| import { useMapGetter } from 'dashboard/composables/store.js';
 | |
| import wootConstants from 'dashboard/constants/globals';
 | |
| import { FEATURE_FLAGS } from 'dashboard/featureFlags';
 | |
| 
 | |
| import ConversationBasicFilter from './widgets/conversation/ConversationBasicFilter.vue';
 | |
| import SwitchLayout from 'dashboard/routes/dashboard/conversation/search/SwitchLayout.vue';
 | |
| import NextButton from 'dashboard/components-next/button/Button.vue';
 | |
| 
 | |
| const props = defineProps({
 | |
|   pageTitle: {
 | |
|     type: String,
 | |
|     required: true,
 | |
|   },
 | |
|   hasAppliedFilters: {
 | |
|     type: Boolean,
 | |
|     required: true,
 | |
|   },
 | |
|   hasActiveFolders: {
 | |
|     type: Boolean,
 | |
|     required: true,
 | |
|   },
 | |
|   activeStatus: {
 | |
|     type: String,
 | |
|     required: true,
 | |
|   },
 | |
|   isOnExpandedLayout: {
 | |
|     type: Boolean,
 | |
|     required: true,
 | |
|   },
 | |
| });
 | |
| 
 | |
| const emit = defineEmits([
 | |
|   'addFolders',
 | |
|   'deleteFolders',
 | |
|   'resetFilters',
 | |
|   'basicFilterChange',
 | |
|   'filtersModal',
 | |
| ]);
 | |
| 
 | |
| const { uiSettings, updateUISettings } = useUISettings();
 | |
| 
 | |
| const currentAccountId = useMapGetter('getCurrentAccountId');
 | |
| const isFeatureEnabledonAccount = useMapGetter(
 | |
|   'accounts/isFeatureEnabledonAccount'
 | |
| );
 | |
| 
 | |
| const onBasicFilterChange = (value, type) => {
 | |
|   emit('basicFilterChange', value, type);
 | |
| };
 | |
| 
 | |
| const hasAppliedFiltersOrActiveFolders = computed(() => {
 | |
|   return props.hasAppliedFilters || props.hasActiveFolders;
 | |
| });
 | |
| 
 | |
| const showV4View = computed(() => {
 | |
|   return isFeatureEnabledonAccount.value(
 | |
|     currentAccountId.value,
 | |
|     FEATURE_FLAGS.CHATWOOT_V4
 | |
|   );
 | |
| });
 | |
| 
 | |
| const toggleConversationLayout = () => {
 | |
|   const { LAYOUT_TYPES } = wootConstants;
 | |
|   const {
 | |
|     conversation_display_type: conversationDisplayType = LAYOUT_TYPES.CONDENSED,
 | |
|   } = uiSettings.value;
 | |
|   const newViewType =
 | |
|     conversationDisplayType === LAYOUT_TYPES.CONDENSED
 | |
|       ? LAYOUT_TYPES.EXPANDED
 | |
|       : LAYOUT_TYPES.CONDENSED;
 | |
|   updateUISettings({
 | |
|     conversation_display_type: newViewType,
 | |
|     previously_used_conversation_display_type: newViewType,
 | |
|   });
 | |
| };
 | |
| </script>
 | |
| 
 | |
| <template>
 | |
|   <div
 | |
|     class="flex items-center justify-between gap-2 px-4"
 | |
|     :class="{
 | |
|       'pb-3 border-b border-n-strong': hasAppliedFiltersOrActiveFolders,
 | |
|       'pt-3 pb-2': showV4View,
 | |
|       'mb-2 pb-0': !showV4View,
 | |
|     }"
 | |
|   >
 | |
|     <div class="flex items-center justify-center min-w-0">
 | |
|       <h1
 | |
|         class="text-lg font-medium truncate text-n-slate-12"
 | |
|         :title="pageTitle"
 | |
|       >
 | |
|         {{ pageTitle }}
 | |
|       </h1>
 | |
|       <span
 | |
|         v-if="!hasAppliedFiltersOrActiveFolders"
 | |
|         class="px-2 py-1 my-0.5 mx-1 rounded-md capitalize bg-n-slate-3 text-xxs text-n-slate-12 shrink-0"
 | |
|       >
 | |
|         {{ $t(`CHAT_LIST.CHAT_STATUS_FILTER_ITEMS.${activeStatus}.TEXT`) }}
 | |
|       </span>
 | |
|     </div>
 | |
|     <div class="flex items-center gap-1">
 | |
|       <template v-if="hasAppliedFilters && !hasActiveFolders">
 | |
|         <div class="relative">
 | |
|           <NextButton
 | |
|             v-tooltip.top-end="$t('FILTER.CUSTOM_VIEWS.ADD.SAVE_BUTTON')"
 | |
|             icon="i-lucide-save"
 | |
|             slate
 | |
|             xs
 | |
|             faded
 | |
|             @click="emit('addFolders')"
 | |
|           />
 | |
|           <div
 | |
|             id="saveFilterTeleportTarget"
 | |
|             class="absolute z-40 mt-2"
 | |
|             :class="{ 'ltr:right-0 rtl:left-0': isOnExpandedLayout }"
 | |
|           />
 | |
|         </div>
 | |
|         <NextButton
 | |
|           v-tooltip.top-end="$t('FILTER.CLEAR_BUTTON_LABEL')"
 | |
|           icon="i-lucide-circle-x"
 | |
|           ruby
 | |
|           faded
 | |
|           xs
 | |
|           @click="emit('resetFilters')"
 | |
|         />
 | |
|       </template>
 | |
|       <template v-if="hasActiveFolders">
 | |
|         <div class="relative">
 | |
|           <NextButton
 | |
|             id="toggleConversationFilterButton"
 | |
|             v-tooltip.top-end="$t('FILTER.CUSTOM_VIEWS.EDIT.EDIT_BUTTON')"
 | |
|             icon="i-lucide-pen-line"
 | |
|             slate
 | |
|             xs
 | |
|             faded
 | |
|             @click="emit('filtersModal')"
 | |
|           />
 | |
|           <div
 | |
|             id="conversationFilterTeleportTarget"
 | |
|             class="absolute z-40 mt-2"
 | |
|             :class="{ 'ltr:right-0 rtl:left-0': isOnExpandedLayout }"
 | |
|           />
 | |
|         </div>
 | |
|         <NextButton
 | |
|           id="toggleConversationFilterButton"
 | |
|           v-tooltip.top-end="$t('FILTER.CUSTOM_VIEWS.DELETE.DELETE_BUTTON')"
 | |
|           icon="i-lucide-trash-2"
 | |
|           ruby
 | |
|           xs
 | |
|           faded
 | |
|           @click="emit('deleteFolders')"
 | |
|         />
 | |
|       </template>
 | |
|       <div v-else class="relative">
 | |
|         <NextButton
 | |
|           id="toggleConversationFilterButton"
 | |
|           v-tooltip.right="$t('FILTER.TOOLTIP_LABEL')"
 | |
|           icon="i-lucide-list-filter"
 | |
|           slate
 | |
|           xs
 | |
|           faded
 | |
|           @click="emit('filtersModal')"
 | |
|         />
 | |
|         <div
 | |
|           id="conversationFilterTeleportTarget"
 | |
|           class="absolute z-40 mt-2"
 | |
|           :class="{ 'ltr:right-0 rtl:left-0': isOnExpandedLayout }"
 | |
|         />
 | |
|       </div>
 | |
|       <ConversationBasicFilter
 | |
|         v-if="!hasAppliedFiltersOrActiveFolders"
 | |
|         :is-on-expanded-layout="isOnExpandedLayout"
 | |
|         @change-filter="onBasicFilterChange"
 | |
|       />
 | |
|       <SwitchLayout
 | |
|         v-if="showV4View"
 | |
|         :is-on-expanded-layout="isOnExpandedLayout"
 | |
|         @toggle="toggleConversationLayout"
 | |
|       />
 | |
|     </div>
 | |
|   </div>
 | |
| </template>
 |