add abort controller to autocomplete fields

This commit is contained in:
ma0068
2024-11-21 15:53:58 +01:00
parent 94255709c7
commit f2b5c12e6d
2 changed files with 27 additions and 5 deletions
@@ -193,8 +193,9 @@ export default{
filteredFirmen: [], filteredFirmen: [],
abortController: { abortController: {
suggestions: null, suggestions: null,
places: null places: null,
} firmen: null
},
} }
}, },
computed:{ computed:{
@@ -306,7 +307,13 @@ export default{
}); });
}, },
search(event) { search(event) {
return this.$fhcApi.factory.stv.kontakt.getFirmen(event.query) if (this.abortController.firmen) {
this.abortController.firmen.abort();
}
this.abortController.firmen = new AbortController();
return this.$refs.addressData.factory.stv.kontakt.getFirmen(event.query)
.then(result => { .then(result => {
this.filteredFirmen = result.data.retval; this.filteredFirmen = result.data.retval;
}); });
@@ -140,6 +140,10 @@ export default{
firmen: [], firmen: [],
filteredFirmen: [], filteredFirmen: [],
filteredOrte: null, filteredOrte: null,
abortController: {
firmen: null,
standorte: null
},
} }
}, },
watch: { watch: {
@@ -234,13 +238,24 @@ export default{
this.$refs.table.reloadTable(); this.$refs.table.reloadTable();
}, },
searchFirma(event) { searchFirma(event) {
return this.$fhcApi if (this.abortController.firmen) {
.get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query) this.abortController.firmen.abort();
}
this.abortController.firmen = new AbortController();
return this.$fhcApi.factory.stv.kontakt.getFirmen(event.query)
.then(result => { .then(result => {
this.filteredFirmen = result.data.retval; this.filteredFirmen = result.data.retval;
}); });
}, },
loadStandorte(firmen_id) { loadStandorte(firmen_id) {
if (this.abortController.standorte) {
this.abortController.standorte.abort();
}
this.abortController.standorte = new AbortController();
return this.$fhcApi.factory.stv.kontakt.getStandorteByFirma(firmen_id) return this.$fhcApi.factory.stv.kontakt.getStandorteByFirma(firmen_id)
.then(result => { .then(result => {
this.filteredOrte = result.data; this.filteredOrte = result.data;