feat: search in current position

This commit is contained in:
Methapon2001 2023-12-15 16:16:43 +07:00
parent e73b51880f
commit 1cca7d45a0
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 20 additions and 3 deletions

View file

@ -105,7 +105,14 @@ const folderFormComponent = ref<InstanceType<typeof FolderFormWrapper>>()
>
<q-icon name="arrow_back" size="1rem" color="primary" />
</q-btn>
<span v-if="isSearch">ผลการค้นหา</span>
<span v-if="isSearch">
ผลการคนหา
<span class="text-grey text-body2 q-ml-md">{{
mode === 'admin' &&
currentInfo.path !== '/' &&
currentInfo.path.split('/').join(' / ')
}}</span>
</span>
<q-breadcrumbs
v-if="!isSearch"
active-color="grey"

View file

@ -10,8 +10,11 @@ import { useLoader } from '@/stores/loader'
import { useFileInfoStore } from '@/stores/file-info-data'
import AdvancedSearch from '@/modules/01_user/components/AdvancedSearch.vue'
import useStorage from '@/stores/storage'
const loaderStore = useLoader()
const storageStore = useStorage()
const { currentInfo } = storeToRefs(storageStore)
const { isFilePreview } = storeToRefs(useFileInfoStore())
const {
isExact,
@ -29,8 +32,9 @@ const optionsField = [
{ label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' },
]
const submitSearchData = ref<{
AND: { field: string; value: string; exact: boolean }[]
OR: { field: string; value: string; exact: boolean }[]
AND: { field: string; value: string; exact?: boolean }[]
OR: { field: string; value: string; exact?: boolean }[]
exact?: boolean
}>({
AND: [],
OR: [],
@ -61,6 +65,12 @@ async function submitSearch() {
value: mime.getType(searchData.value.value) || '',
exact: true,
})
if (currentInfo.value.path !== '/') {
submitSearchData.value.AND.push({
field: 'path',
value: currentInfo.value.path,
})
}
} else {
submitSearchData.value.OR.push({
field: searchData.value.field,