Skip to content

Commit

Permalink
fix: query presets cannot add new quick preset (#1164) (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo authored Mar 19, 2024
1 parent e90e3a1 commit 39603c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions variants/vueapp/src/components/FilterApp/Header.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, watch } from 'vue'
import { ref, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useCaseListStore } from '@cases/stores/caseList'
Expand All @@ -24,24 +24,36 @@ const presetSetLoading = ref(false)
/** The current preset set (if caseDetailsStore.caseObj.presetset !== null / factory presets). */
const presetSetLabel = ref(null)
/** Watch change of current case's preset set and load label if necessary. */
const updatePresetSetLoading = async () => {
if (!caseDetailsStore?.caseObj?.presetset) {
return // short circuit in case of factory defaults
}
const queryPresetsClient = new QueryPresetsClient(caseListStore.csrfToken)
presetSetLoading.value = true
await queryPresetsClient
.retrievePresetSet(caseDetailsStore.caseObj.presetset)
.then((presetSet) => {
presetSetLabel.value = presetSet.label
})
.catch((err) => {
console.error('Problem retrieving preset set', err)
})
.finally(() => {
presetSetLoading.value = false
})
}
watch(
() => caseDetailsStore?.caseObj?.presetset,
async (newValue, _oldValue) => {
if (!newValue) {
return // short circuit in case of factory defaults
}
const queryPresetsClient = new QueryPresetsClient(caseListStore.csrfToken)
presetSetLoading.value = true
try {
const presetSet = queryPresetsClient.retrievePresetSet(newValue)
presetSetLabel.value = presetSet.label
} catch (err) {
console.error('Problem retrieving preset set', err)
} finally {
presetSetLoading.value = false
}
await updatePresetSetLoading()
},
)
onMounted(() => {
updatePresetSetLoading()
})
</script>
<template>
Expand Down
2 changes: 1 addition & 1 deletion variants/vueapp/src/components/QueryPresets/SetEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const handleAddClicked = async (category) => {
try {
let payload = { label }
if (category === 'frequencypresets') {
if (category === 'frequencypresets' || category === 'quickpresets') {
payload = {
label,
frequency: null,
Expand Down

0 comments on commit 39603c9

Please sign in to comment.