Search spelling suggestions across every list

This commit is contained in:
2026-08-21 11:15:06 -04:00
parent fdf3c51cb0
commit 04107ff8ab
18 changed files with 1005 additions and 82 deletions

View File

@@ -79,6 +79,7 @@
<tr v-if="machines.length === 0">
<td colspan="8" style="text-align: center; color: var(--text-light);">
No machines found
<SearchSuggestion :suggestion="suggestion" @pick="applySuggestion" />
</td>
</tr>
</tbody>
@@ -105,10 +106,22 @@ import { colorStyle } from "@/utils/colorStyle"
import { machinesApi } from '@/api'
import PaginationBar from '@/components/PaginationBar.vue'
import { useListQuery } from '@/composables/listQuery'
import SearchSuggestion from '@/components/SearchSuggestion.vue'
const machines = ref([])
const loading = ref(true)
const { page, search, setPage, setSearch } = useListQuery({ onChange: loadMachines })
const { page, search, setPage, setSearch, suggestion, reportCount } = useListQuery({ onChange: loadMachines })
// Take the offered spelling: put it in the box and search it, so what was
// searched is what the person sees.
function applySuggestion(word) {
search.value = word
setSearch(word)
// setSearch only syncs the URL, and the watcher that reloads is suppressed
// because search.value already holds the new term - the same trap the global
// search page documents. Load directly.
loadMachines()
}
const totalPages = ref(1)
const perPage = ref(20)
@@ -129,6 +142,7 @@ async function loadMachines() {
const response = await machinesApi.list(params)
machines.value = response.data.data || []
reportCount(machines.value.length)
totalPages.value = response.data.meta?.pagination?.totalpages || response.data.meta?.pagination?.total_pages || 1
} catch (error) {
console.error('Error loading machines:', error)