Skip to content

Commit

Permalink
clear alerts on close
Browse files Browse the repository at this point in the history
  • Loading branch information
devincowan committed Feb 26, 2024
1 parent fb85e93 commit 3fa9885
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion frontend/src/_helpers/hydroCron.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const queryHydroCron = async (swordFeature = null) => {
console.log('fake params', params)
}
let json = await fetchHydroCronData(url, params, swordFeature)
if (json == null) {
return
}
if (featuresStore.shouldFakeData) {
let fakeData = buildFakeData([...featuresStore.selectedFeatures, json])
// update the visData before selecting the feature otherwise it will show blank
Expand Down Expand Up @@ -65,7 +68,6 @@ const fetchHydroCronData = async (url, params, swordFeature) => {
console.log(result)
console.log('json', json)
let features = json.results.geojson.features
console.log('features', features)
if (features.length > 0) {
return json
}else{
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/AlertPopup.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<template>
<v-alert v-show="props.text != ''" class="zlert" :title="props.title" :text="props.text" :closeable="props.closeable"></v-alert>
<v-alert v-show="props.text != ''" class="zlert" :title="props.title" :text="props.text" :closeable="props.closeable" @click:close="closeEvent"></v-alert>
</template>

<script setup>
import { useAlertStore } from '@/stores/alerts'
const alertStore = useAlertStore()
const props = defineProps({ text: { type: String, default: "" }, title: { default: "Alert" }, closeable: { default: true } })
const closeEvent = () => {
alertStore.clearAlert()
}
</script>

<style scoped>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/stores/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const useAlertStore = defineStore('alerts', () => {
displayed.value = {}
}, alert.duration * 1000)
}

function clearAlert(){
displayed.value = {}
}

return { displayed, displayAlert }
return { displayed, displayAlert, clearAlert }
})

0 comments on commit 3fa9885

Please sign in to comment.