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"
class="filter-popup"
@update:modelValue="emitChanges"
@showResultsButtonClicked="() => modalOpen = false"
@showResults="() => modalOpen = false"
/>
</Modal>
</template>

View File

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