Skip to content

Commit

Permalink
fix search filtering and keyup modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Jul 11, 2023
1 parent cdfd27c commit 0d1dd94
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
## TODO

* a11y
* keyup.esc modifiers
* responsiveness

## License
Expand Down
2 changes: 1 addition & 1 deletion src/components/rest/RestQueryFormTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<q-btn icon="edit" flat dense size="sm">
<q-popup-edit v-slot="scope" v-model="tab.label" auto-save anchor="top left"
@save="(v) => {updateTab(v, tab)}">
<q-input v-model="scope.value" dense autofocu outlined @keyup.enter="scope.set" />
<q-input v-model="scope.value" dense autofocu outlined @keydown.enter="scope.set" />
</q-popup-edit>
</q-btn>

Expand Down
2 changes: 1 addition & 1 deletion src/components/rest/RestQuerySavedQueriesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<q-btn icon="edit" color="dark-grey" dense>
<q-popup-edit v-slot="scope" v-model="row.name" auto-save anchor="center right"
@save="(v:string) => (renameSavedQuery(v, row))">
<q-input v-model="scope.value" dense autofocu outlined @keyup.enter="scope.set" />
<q-input v-model="scope.value" dense autofocu outlined @keydown.enter="scope.set" />
</q-popup-edit>
</q-btn>
<q-btn icon="delete" color="dark-grey" dense @click.stop="removeSavedQuery(row.id)" />
Expand Down
3 changes: 2 additions & 1 deletion src/components/search/SearchDocuments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<q-input v-model="searchStore.q"
outlined
autofocus
:label="t('search.form.query.label')" />
:label="t('search.form.query.label')"
@keydown.esc="searchStore.q = '*'" />
<!-- eslint-disable-next-line vue/no-v-html -->
<small v-html="t('search.form.query.messages')" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/search/SearchResultsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
:virtual-scroll="searchStore.stickyTableHeader"
:virtual-scroll-item-size="14"
:columns="tableColumns"
:rows="hits"
:rows="filteredHits"
:rows-per-page-options="rowsPerPage"
:visible-columns="searchStore.visibleColumns"
selection="multiple"
Expand Down Expand Up @@ -113,6 +113,7 @@
slicedTableColumns,
resizeStore,
hits,
filteredHits,
rowsPerPage,
onRequest,
reload,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/FilterInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<q-input v-model="filter" :label="t('defaults.filter.label')" dense outlined name="filter" @keyup.esc="filter = ''">
<q-input v-model="filter" :label="t('defaults.filter.label')" dense outlined name="filter" @keydown.esc="filter = ''">
<template #append>
<q-icon name="search" />
</template>
Expand Down
8 changes: 8 additions & 0 deletions src/composables/components/search/SearchResultsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SearchResults from '../../../models/SearchResults.ts'
import { sortableField } from '../../../helpers/search.ts'
import { EsSearchResult } from './SearchDocuments.ts'
import { ElasticsearchDocumentInfo } from './EditDocument.ts'
import { filterItems } from '../../../helpers/filters.ts'

export type SearchResultsTableProps = {
results: EsSearchResult
Expand Down Expand Up @@ -78,6 +79,12 @@ export const useSearchResultsTable = (props: SearchResultsTableProps, emit: any)
hits.value = results.docs
})

const filteredHits = computed(() => {
if (filter.value.trim().length === 0) return hits.value

return filterItems(hits.value, filter.value, tableColumns.value.map(c => c.field))
})

const slicedTableColumns = computed((): any[] => (tableColumns.value.slice(0, -1)))

const onRequest = (pagination: any) => (emit('request', pagination))
Expand All @@ -100,6 +107,7 @@ export const useSearchResultsTable = (props: SearchResultsTableProps, emit: any)
slicedTableColumns,
resizeStore,
hits,
filteredHits,
rowsPerPage,
onRequest,
reload,
Expand Down

0 comments on commit 0d1dd94

Please sign in to comment.