mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import { ReloadViewDataHookInj, computed, inject, onClickOutside, ref, useSmartsheetStoreOrThrow } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
const reloadData = inject(ReloadViewDataHookInj)!
|
||
|
|
||
2 years ago
|
const { search, meta } = useSmartsheetStoreOrThrow()
|
||
2 years ago
|
|
||
|
// todo: where is this value supposed to come from? it's not in the store
|
||
|
const isDropdownOpen = ref(false)
|
||
2 years ago
|
|
||
2 years ago
|
const searchDropdown = ref(null)
|
||
2 years ago
|
|
||
2 years ago
|
onClickOutside(searchDropdown, () => (isDropdownOpen.value = false))
|
||
2 years ago
|
|
||
|
const columns = computed(() =>
|
||
2 years ago
|
meta.value?.columns?.map((c) => ({
|
||
2 years ago
|
value: c.id,
|
||
|
label: c.title,
|
||
|
})),
|
||
|
)
|
||
2 years ago
|
|
||
|
function onPressEnter() {
|
||
|
reloadData.trigger()
|
||
|
}
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div class="flex flex-row border-1 rounded-sm">
|
||
|
<div
|
||
|
ref="searchDropdown"
|
||
|
class="flex items-center relative bg-gray-50 px-2 cursor-pointer border-r-1"
|
||
|
:class="{ '!bg-gray-100 ': isDropdownOpen }"
|
||
|
@click="isDropdownOpen = !isDropdownOpen"
|
||
|
>
|
||
|
<MdiMagnify class="text-grey" />
|
||
|
<MdiMenuDown class="text-grey" />
|
||
2 years ago
|
|
||
2 years ago
|
<a-select
|
||
|
v-model:value="search.field"
|
||
|
:open="isDropdownOpen"
|
||
|
size="small"
|
||
|
:dropdown-match-select-width="false"
|
||
|
:options="columns"
|
||
2 years ago
|
dropdown-class-name="!py-0 !rounded nc-dropdown-toolbar-search-field-option"
|
||
2 years ago
|
class="!absolute top-0 left-0 w-full h-full z-10 !text-xs opacity-0"
|
||
2 years ago
|
/>
|
||
2 years ago
|
</div>
|
||
|
<a-input
|
||
|
v-model:value="search.query"
|
||
|
size="small"
|
||
|
class="max-w-[200px]"
|
||
2 years ago
|
:placeholder="$t('placeholder.filterQuery')"
|
||
2 years ago
|
:bordered="false"
|
||
|
@press-enter="onPressEnter"
|
||
|
>
|
||
|
<template #addonBefore> </template>
|
||
|
</a-input>
|
||
|
</div>
|
||
2 years ago
|
</template>
|