Browse Source

feat(nc-gui): added badge to view selected search field

pull/6292/head
reenphygeorge 1 year ago
parent
commit
6a5c304f6a
  1. 17
      packages/nc-gui/components/smartsheet/toolbar/SearchData.vue

17
packages/nc-gui/components/smartsheet/toolbar/SearchData.vue

@ -55,12 +55,17 @@ function onPressEnter() {
} }
const displayColumnLabel = computed(() => { const displayColumnLabel = computed(() => {
return columns.value?.find((column) => column.primaryValue)?.label const columnLabel = search.value.field.length === 0?columns.value?.find(column => column.primaryValue)?.label:
columns.value?.find(column => column.value === search.value.field)?.label
return (columnLabel && columnLabel.length > 10)
? columnLabel.slice(0, 10) + '...'
: columnLabel;
}) })
watch( watch(
() => search.value.field, () => search.value.field,
() => { () => {
console.log(columns.value)
onPressEnter() onPressEnter()
} }
) )
@ -89,7 +94,12 @@ watchDebounced(
@click="isDropdownOpen = !isDropdownOpen" @click="isDropdownOpen = !isDropdownOpen"
> >
<GeneralIcon icon="search" class="ml-1 h-3.5 w-3.5 text-gray-500 group-hover:text-black" /> <GeneralIcon icon="search" class="ml-1 h-3.5 w-3.5 text-gray-500 group-hover:text-black" />
<NcBadge color="purple">
<p class="pt-1 text-center text-xs font-regular text-gray-400"
>
in {{ displayColumnLabel }}
</p>
</NcBadge>
<component :is="iconMap.arrowDown" class="ml-1 text-gray-400 !text-sm" /> <component :is="iconMap.arrowDown" class="ml-1 text-gray-400 !text-sm" />
<a-select <a-select
@ -116,14 +126,13 @@ watchDebounced(
:style="{ :style="{
width: '12rem', width: '12rem',
}" }"
:placeholder="`${$t('general.search')} in ${displayColumnLabel}`" :placeholder="`${$t('general.search')}`"
:bordered="false" :bordered="false"
data-testid="search-data-input" data-testid="search-data-input"
@press-enter="onPressEnter" @press-enter="onPressEnter"
@focus="isFocused = true" @focus="isFocused = true"
@blur="isFocused = false" @blur="isFocused = false"
> >
<template #addonBefore> </template>
</a-input> </a-input>
</div> </div>
</template> </template>

Loading…
Cancel
Save