Skip to content

Commit

Permalink
reset search on click
Browse files Browse the repository at this point in the history
fix zoom bug
  • Loading branch information
Der-Alex-K committed Dec 19, 2024
1 parent 696849d commit 6fd1670
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<router-link
to="/"
style="text-decoration: none"
@click="resetSearch"
>
<v-toolbar-title class="text-white font-weight-medium">
<span class="font-weight-medium">DAVe</span>
Expand Down Expand Up @@ -79,6 +80,7 @@ import InfoMessage from "@/components/app/InfoMessage.vue";
import SearchInputField from "@/components/app/SearchInputField.vue";
import VisitHistory from "@/components/app/VisitHistory.vue";
import TheSnackbar from "@/components/common/TheSnackbar.vue";
import { useSearchStore } from "@/store/SearchStore";
import { useSnackbarStore } from "@/store/SnackbarStore";
import { useUserStore } from "@/store/UserStore";
import SsoUserInfoResponse from "@/types/app/SsoUserInfoResponse";
Expand All @@ -93,6 +95,7 @@ const frontendVersion = ref("");
const snackbarStore = useSnackbarStore();
const userStore = useUserStore();
const searchStore = useSearchStore();
const route = useRoute();
created();
Expand Down Expand Up @@ -157,6 +160,10 @@ function shortCuts(event: KeyboardEvent) {
}
}
}
function resetSearch() {
searchStore.resetAndTriggerSearch();
}
</script>

<style>
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/components/app/SearchInputField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import type SucheZaehlstelleSuggestDTO from "@/types/suche/SucheZaehlstelleSugge
import type SucheZaehlungSuggestDTO from "@/types/suche/SucheZaehlungSuggestDTO";
import { isEmpty, isNil } from "lodash";
import { onMounted, ref, watch } from "vue";
import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import SucheService from "@/api/service/SucheService";
Expand All @@ -98,10 +98,6 @@ const router = useRouter();
const snackbarStore = useSnackbarStore();
const searchStore = useSearchStore();
onMounted(() => {
clearSearch();
});
function suggest(query: string) {
if (!isEmpty(query)) {
lastSuggestQuery.value = query;
Expand Down Expand Up @@ -171,8 +167,7 @@ function suggest(query: string) {
function clearSearch(): void {
searchQuery.value = "";
selectedSuggestion.value = undefined;
searchStore.setLastSearchQuery(searchQuery.value);
search();
searchStore.resetAndTriggerSearch();
}
function searchOrShowSelectedSuggestion() {
Expand Down Expand Up @@ -272,9 +267,10 @@ function iconOfSuggestion(type: string) {
}
watch(
() => searchStore.getLastSearchQuery,
() => searchStore.getTriggerSearch,
() => {
searchQuery.value = searchStore.getLastSearchQuery;
selectedSuggestion.value = undefined;
search();
}
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/map/ZaehlstelleMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ function setMarkerToMap() {
// Zaehlartenmarker erzeugen
setZaehlartenmarkerToMap();
map.setView(center.value, zoomValue.value);
} else {
map.setView(center.value, zoomValue.value);
}
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/store/SearchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ import { computed, ref } from "vue";
export const useSearchStore = defineStore("searchStore", () => {
const searchResult = ref<Array<AnzeigeKarteDTO>>([]);
const lastSearchQuery = ref("");
const triggerSearch = ref(false);

const getSearchResult = computed(() => searchResult.value);
const getLastSearchQuery = computed(() => lastSearchQuery.value);
const getTriggerSearch = computed(() => triggerSearch.value);

function setSearchResult(payload: Array<AnzeigeKarteDTO>) {
searchResult.value = payload;
}
function setLastSearchQuery(payload: string) {
lastSearchQuery.value = payload;
}
function resetAndTriggerSearch() {
setSearchResult([]);
setLastSearchQuery("");
triggerSearch.value = !triggerSearch.value;
}

return {
getSearchResult,
getLastSearchQuery,
getTriggerSearch,
setSearchResult,
setLastSearchQuery,
resetAndTriggerSearch,
};
});

0 comments on commit 6fd1670

Please sign in to comment.