Skip to content

Commit

Permalink
feat: quick preset editor must force values to be set on creation (#2028
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stolpeo committed Oct 21, 2024
1 parent 6a7b1f7 commit ee015f5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
26 changes: 25 additions & 1 deletion frontend/src/variants/components/FilterForm/QuickPresets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,30 @@ const quickPresetWrapper = computed({
},
})
const quickPresetsComplete = computed(() => {
const result = {}
for (const [name, theQuickPresets] of Object.entries(props.quickPresets)) {
let skip = false
for (const key of [
'inheritance',
'frequency',
'impact',
'quality',
'chromosomes',
'flagsetc',
]) {
if (!theQuickPresets[key]) {
skip = true
break
}
}
if (!skip) {
result[name] = theQuickPresets
}
}
return result
})
/** Refresh all presets. */
const refreshAllRefs = () => {
refreshInheritanceRef()
Expand Down Expand Up @@ -366,7 +390,7 @@ onMounted(() => {
v-model="quickPresetWrapper"
class="custom-select custom-select-sm"
>
<option v-for="(value, name) in quickPresets" :value="name">
<option v-for="(value, name) in quickPresetsComplete" :value="name">
{{ value.label ?? name }}
</option>
<option disabled>custom</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ const handleAddClicked = async (category) => {
quality: null,
chromosome: null,
flagsetc: null,
inheritance: null,
}
} else if (category === 'qualitypresets') {
payload = {
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/variants/components/QueryPresets/SetQuickPresets.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script setup>
/** Editor component for quick presets.
*/
import { computed } from 'vue'
import { randomString } from '@/varfish/common'
/** Define props. */
Expand All @@ -15,11 +17,31 @@ const props = defineProps({
default: randomString(),
},
})
const isIncomplete = computed(() => {
for (const key of [
'inheritance',
'frequency',
'impact',
'quality',
'chromosome',
'flagsetc',
]) {
if (!props.querySettings[key]) {
return true
}
}
return false
})
</script>

<template>
<!-- eslint-disable -->
<div v-if="querySettings" class="mr-2 mt-2">
<div class="alert alert-warning" v-if="isIncomplete">
<strong>Warning!</strong> The query settings are incomplete and will not
be available in the filter form unless all values are set.
</div>
<div class="form-group">
<label :for="'inheritance' + idSuffix"> Inheritance </label>
<select
Expand Down

0 comments on commit ee015f5

Please sign in to comment.