mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-02 02:28:40 +00:00
* fix: get rid of barrel files * chore: get rid of explicit imports * fix: use explicit import for classes and enums * fix: use explicit import for enum & class & aliases * fix: build issues
26 lines
844 B
TypeScript
26 lines
844 B
TypeScript
export function useFieldQuery() {
|
|
// initial search object
|
|
const emptyFieldQueryObj = {
|
|
field: '',
|
|
query: '',
|
|
}
|
|
|
|
// mapping view id (key) to corresponding emptyFieldQueryObj (value)
|
|
const searchMap = useState<Record<string, { field: string; query: string }>>('field-query-search-map', () => ({}))
|
|
|
|
// the fieldQueryObj under the current view
|
|
const search = useState<{ field: string; query: string }>('field-query-search', () => ({ ...emptyFieldQueryObj }))
|
|
|
|
// retrieve the fieldQueryObj of the given view id
|
|
// if it is not found in `searchMap`, init with emptyFieldQueryObj
|
|
const loadFieldQuery = (id?: string) => {
|
|
if (!id) return
|
|
if (!(id in searchMap.value)) {
|
|
searchMap.value[id] = { ...emptyFieldQueryObj }
|
|
}
|
|
search.value = searchMap.value[id]
|
|
}
|
|
|
|
return { search, loadFieldQuery }
|
|
}
|