This commit is contained in:
philipp lang 2024-07-03 17:12:32 +02:00
parent 44a39fc5a8
commit aafef695aa
1 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@
<f-select id="country" v-model="values.country" :options="countries" name="country" label="Land" required></f-select>
<div class="border-gray-200 shadow shadow-primary-700 p-3 shadow-[0_0_4px_gray] col-span-2">
<f-text id="search_text" ref="searchTextField" v-model="searchText" class="col-span-2" label="Suchen …" size="sm" @keypress.enter.prevent="onSubmitFirstMemberResult"></f-text>
<f-text id="search_text" ref="searchInput" v-model="searchText" class="col-span-2" label="Suchen …" size="sm" @keypress.enter.prevent="onSubmitFirstMemberResult"></f-text>
<div class="mt-2 grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2 col-span-2">
<f-switch
v-for="member in results"
@ -44,9 +44,9 @@ const props = defineProps({
compilers: {},
});
const searchRaw = ref('');
const realSearchString = ref('');
const results = ref([]);
const searchTextField = ref([]);
const searchInput = ref([]);
const values = ref({
type: null,
members: [],
@ -59,9 +59,9 @@ const values = ref({
});
const searchText = computed({
get: () => searchRaw.value,
get: () => realSearchString.value,
set: async (v) => {
searchRaw.value = v;
realSearchString.value = v;
results.value = (await search(v, ['birthday IS NOT NULL', 'address IS NOT EMPTY'])).hits;
},
@ -80,12 +80,12 @@ function onSubmitMemberResult(selected) {
values.value.members.push(selected.id);
}
searchRaw.value = '';
searchTextField.value.$el.querySelector('input').focus();
realSearchString.value = '';
searchInput.value.$el.querySelector('input').focus();
}
function onSubmitFirstMemberResult() {
if (results.value.length === 0) {
searchRaw.value = '';
realSearchString.value = '';
return;
}