Skip to content

Commit

Permalink
fix: search input
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Nov 16, 2023
1 parent 7f77d5e commit 1f8d58f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/ui/testApp/TestTableManualFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ref, watch } from 'vue'
import {
FiltersState,
FilterStateCheckboxes,
FilterStateInputValue,
FilterStateOption,
MagnetarTable,
MUIColumn,
Expand Down Expand Up @@ -126,7 +125,7 @@ const sValue = urlParams.get('s') || undefined
*/
const filtersState = ref<FiltersState>(new Map())
const searchInput = ref<FilterStateInputValue>(sValue || '')
const searchInput = ref<string>(sValue || '')
const checkboxesInput = ref<FilterStateCheckboxes>({ or: new Set() })
const selectInput = ref<FilterStateOption | null>(null)
Expand All @@ -135,10 +134,21 @@ const INDEX_SEARCH = 0
const INDEX_CHECKBOXES = 1
const INDEX_SELECT = 2
// prettier-ignore
watch(
searchInput,
(newValue) => filtersState.value.set(INDEX_SEARCH, newValue),
(newValue) => {
if (!newValue) filtersState.value.delete(INDEX_SEARCH)
if (newValue) {
/** Set it just like checkboxes */
const filterState: FilterStateCheckboxes = {
or: new Set([
['title', '==', newValue.trim()],
['id', '==', newValue.trim()],
]),
}
filtersState.value.set(INDEX_SEARCH, filterState)
}
},
{ immediate: true }
)
// prettier-ignore
Expand All @@ -155,6 +165,7 @@ watch(selectInput, (newValue) => {
const optionsCheckboxes: { label: string; where: WhereClause }[] = [
{ label: 'done', where: ['isDone', '==', true] },
{ label: 'not done', where: ['isDone', '==', false] },
{ label: 'id is 7xmxyIhKeXg1DFY7uS9m', where: ['id', '==', '7xmxyIhKeXg1DFY7uS9m'] },
]
const optionsSelect: { label: string; where: WhereClause }[] = [
Expand Down

0 comments on commit 1f8d58f

Please sign in to comment.