refactor: clean about search

This commit is contained in:
puri-ph4tt 2023-11-28 09:22:44 +07:00 committed by Methapon2001
parent 74c5115e95
commit aa63e9c8c5
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
3 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,11 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import { useTreeDataStore, type TreeDataFolder } from '@/stores/tree-data'
import { useSearchDataStore } from '@/stores/searched-data'
import { useFileInfoStore } from '@/stores/file-info-data'
const { isSearch } = storeToRefs(useSearchDataStore())
const { isPreview } = storeToRefs(useFileInfoStore())
const { getFolder } = useTreeDataStore()
const props = withDefaults(
@ -17,7 +23,13 @@ const props = withDefaults(
<div>
<q-list v-for="folder in data" class="rounded-borders">
<q-expansion-item
@click="() => getFolder(folder.pathname, false)"
@click="
() => {
getFolder(folder.pathname, false)
isSearch = false
isPreview = false
}
"
:header-inset-level="level * 0.25"
:group="level.toString()"
:hide-expand-icon="level === 4"

View file

@ -10,10 +10,9 @@ import { useSearchDataStore } from '@/stores/searched-data'
import { useLoader } from '@/stores/loader'
const loaderStore = useLoader()
const { isSearch } = storeToRefs(useSearchDataStore())
const { isSearch, isAdvSearchCall } = storeToRefs(useSearchDataStore())
const { getFoundFile } = useSearchDataStore()
const advSearchComp = ref<InstanceType<typeof AdvancedSearch>>()
const isAdvSearchCall = ref<boolean>(false)
const optionsField = [
{ label: 'ชื่อเรื่อง (title)', value: 'title' },
{ label: 'คำสำคัญ (keyword)', value: 'keyword' },

View file

@ -4,6 +4,7 @@ import type { EhrFile } from '@/stores/tree-data'
export const useSearchDataStore = defineStore('searched', () => {
const foundFile = ref<EhrFile[]>([])
const isAdvSearchCall = ref<boolean>(false)
const isSearch = ref<Boolean>(false)
async function getFoundFile(data: EhrFile[]) {
@ -11,8 +12,9 @@ export const useSearchDataStore = defineStore('searched', () => {
}
return {
isSearch,
foundFile,
isSearch,
isAdvSearchCall,
getFoundFile,
}
})