1
0

feat: remove props destructuring for Filters

This commit is contained in:
Dominik Pschenitschni 2024-07-05 15:01:12 +02:00 committed by konrad
parent 46aa2fff0f
commit 3ff56d7987
2 changed files with 18 additions and 13 deletions

View File

@ -20,7 +20,7 @@
:has-title="true" :has-title="true"
class="filter-popup" class="filter-popup"
@update:modelValue="emitChanges" @update:modelValue="emitChanges"
@showResultsButtonClicked="() => modalOpen = false" @showResults="() => modalOpen = false"
/> />
</Modal> </Modal>
</template> </template>

View File

@ -58,17 +58,19 @@ import {useProjectStore} from '@/stores/projects'
import {FILTER_OPERATORS, transformFilterStringForApi, transformFilterStringFromApi} from '@/helpers/filters' import {FILTER_OPERATORS, transformFilterStringForApi, transformFilterStringFromApi} from '@/helpers/filters'
import FilterInputDocs from '@/components/project/partials/FilterInputDocs.vue' import FilterInputDocs from '@/components/project/partials/FilterInputDocs.vue'
const { const props = withDefaults(defineProps<{
hasTitle = false, modelValue: TaskFilterParams,
hasFooter = true,
modelValue,
} = defineProps<{
hasTitle?: boolean, hasTitle?: boolean,
hasFooter?: boolean, hasFooter?: boolean,
modelValue: TaskFilterParams, }>(), {
}>() hasTitle: false,
hasFooter: true,
})
const emit = defineEmits(['update:modelValue', 'showResultsButtonClicked']) const emit = defineEmits<{
'update:modelValue': [value: TaskFilterParams],
'showResults': [],
}>()
const route = useRoute() const route = useRoute()
const projectId = computed(() => { const projectId = computed(() => {
@ -102,7 +104,7 @@ const projectStore = useProjectStore()
// Using watchDebounced to prevent the filter re-triggering itself. // Using watchDebounced to prevent the filter re-triggering itself.
watch( watch(
() => modelValue, () => props.modelValue,
(value: TaskFilterParams) => { (value: TaskFilterParams) => {
const val = {...value} const val = {...value}
val.filter = transformFilterStringFromApi( val.filter = transformFilterStringFromApi(
@ -112,7 +114,10 @@ watch(
) )
params.value = val params.value = val
}, },
{immediate: true}, {
immediate: true,
deep: true,
},
) )
function change() { function change() {
@ -139,7 +144,7 @@ function change() {
s, s,
} }
if (JSON.stringify(modelValue) === JSON.stringify(newParams)) { if (JSON.stringify(props.modelValue) === JSON.stringify(newParams)) {
return return
} }
@ -148,7 +153,7 @@ function change() {
function changeAndEmitButton() { function changeAndEmitButton() {
change() change()
emit('showResultsButtonClicked') emit('showResults')
} }
function clearFiltersAndEmit() { function clearFiltersAndEmit() {