2023-03-30 10:54:18 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: 2023 Andreas Palm
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import {ref} from "vue";
|
|
|
|
import AutoComplete from "primevue/autocomplete";
|
|
|
|
import axios from "axios";
|
2024-04-12 12:51:07 +02:00
|
|
|
import SearchIcon from "primevue/icons/search";
|
2023-03-30 10:54:18 +02:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
ajaxFilter: String,
|
|
|
|
modelValue: null,
|
|
|
|
forceSelection: Boolean
|
|
|
|
});
|
|
|
|
const emit = defineEmits(['update:modelValue']);
|
|
|
|
|
|
|
|
const items = ref([]);
|
|
|
|
async function search(event) {
|
|
|
|
await axios.get('index.php',
|
|
|
|
{
|
|
|
|
params: {
|
|
|
|
module: 'ajax',
|
|
|
|
action: 'filter',
|
|
|
|
filtername: props.ajaxFilter,
|
|
|
|
term: event.query,
|
|
|
|
object: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(response => items.value = response.data)
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<AutoComplete
|
|
|
|
:modelValue="modelValue"
|
|
|
|
@update:modelValue="value => emit('update:modelValue', value)"
|
|
|
|
:suggestions="items"
|
|
|
|
@complete="search"
|
|
|
|
dataKey="id"
|
|
|
|
:forceSelection="forceSelection"
|
2024-04-12 12:51:07 +02:00
|
|
|
dropdown
|
|
|
|
>
|
|
|
|
<template #dropdownicon>
|
|
|
|
<SearchIcon />
|
|
|
|
</template>
|
|
|
|
</AutoComplete>
|
2023-03-30 10:54:18 +02:00
|
|
|
</template>
|