mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Usprawienie podpowiedzi filtrów
This commit is contained in:
@@ -120,8 +120,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
currentOptionsActive: {
|
currentOptionsActive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@@ -171,41 +171,14 @@ export default defineComponent({
|
|||||||
if (!value || value == '') return;
|
if (!value || value == '') return;
|
||||||
if (value.length < 3) return;
|
if (value.length < 3) return;
|
||||||
|
|
||||||
this.searchTimeout = setTimeout(async () => {
|
this.startSearchTimeout('driver', value);
|
||||||
try {
|
|
||||||
const driverSuggestions: string[] = await (
|
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/getDriverSuggestions?name=${value}`)
|
|
||||||
).data;
|
|
||||||
|
|
||||||
this.driverSuggestions = driverSuggestions;
|
|
||||||
} catch (error) {
|
|
||||||
this.driverSuggestions = [];
|
|
||||||
}
|
|
||||||
}, 1500);
|
|
||||||
|
|
||||||
// this.loadingDriverSuggestions = true;
|
|
||||||
|
|
||||||
// this.loadingDriverSuggestions = false;
|
|
||||||
// this.nextSearchTimestamp = Date.now() + 100;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async 'searchersValues.search-dispatcher'(value: string | undefined) {
|
async 'searchersValues.search-dispatcher'(value: string | undefined) {
|
||||||
clearTimeout(this.searchTimeout);
|
|
||||||
|
|
||||||
if (!value || value == '') return;
|
if (!value || value == '') return;
|
||||||
if (value.length < 3) return;
|
if (value.length < 3) return;
|
||||||
|
|
||||||
this.searchTimeout = setTimeout(async () => {
|
this.startSearchTimeout('dispatcher', value);
|
||||||
try {
|
|
||||||
const dispatcherSuggestions: string[] = await (
|
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/getDispatcherSuggestions?name=${value}`)
|
|
||||||
).data;
|
|
||||||
|
|
||||||
this.dispatcherSuggestions = dispatcherSuggestions;
|
|
||||||
} catch (error) {
|
|
||||||
this.dispatcherSuggestions = [];
|
|
||||||
}
|
|
||||||
}, 1500);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -233,6 +206,24 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startSearchTimeout(type: 'driver' | 'dispatcher', value: string) {
|
||||||
|
if (this[`${type}Suggestions`].includes(value)) return;
|
||||||
|
|
||||||
|
window.clearTimeout(this.searchTimeout);
|
||||||
|
|
||||||
|
this.searchTimeout = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
const suggestions: string[] = await (
|
||||||
|
await axios.get(`${URLs.stacjownikAPI}/api/get${type}Suggestions?name=${value}`)
|
||||||
|
).data;
|
||||||
|
|
||||||
|
this[`${type}Suggestions`] = suggestions;
|
||||||
|
} catch (error) {
|
||||||
|
this[`${type}Suggestions`] = [];
|
||||||
|
}
|
||||||
|
}, 450);
|
||||||
|
},
|
||||||
|
|
||||||
// Override keyMixin function
|
// Override keyMixin function
|
||||||
onKeyDownFunction() {
|
onKeyDownFunction() {
|
||||||
this.showOptions = !this.showOptions;
|
this.showOptions = !this.showOptions;
|
||||||
|
|||||||
Reference in New Issue
Block a user