From 2f92e407ccf42892675dc1583dfa057474cb2489 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 5 Jul 2024 14:44:26 +0200 Subject: [PATCH] feat: remove props destructuring from ViewEditForm --- .../components/project/views/ViewEditForm.vue | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/project/views/ViewEditForm.vue b/frontend/src/components/project/views/ViewEditForm.vue index 0dcb4b17b..d4edc3db9 100644 --- a/frontend/src/components/project/views/ViewEditForm.vue +++ b/frontend/src/components/project/views/ViewEditForm.vue @@ -8,17 +8,19 @@ import {useLabelStore} from '@/stores/labels' import {useProjectStore} from '@/stores/projects' import FilterInputDocs from '@/components/project/partials/FilterInputDocs.vue' -const { - modelValue, - loading = false, - showSaveButtons = false, -} = defineProps<{ +const props = withDefaults(defineProps<{ modelValue: IProjectView, - loading?: bool, - showSaveButtons?: bool, -}>() + loading?: boolean, + showSaveButtons?: boolean, +}>(), { + loading: false, + showSaveButtons: false, +}) -const emit = defineEmits(['update:modelValue', 'cancel']) +const emit = defineEmits<{ + 'update:modelValue': [value: IProjectView], + 'cancel': [], +}>() const view = ref() @@ -26,16 +28,16 @@ const labelStore = useLabelStore() const projectStore = useProjectStore() onBeforeMount(() => { - const transform = filterString => transformFilterStringFromApi( + const transform = (filterString: string) => transformFilterStringFromApi( filterString, labelId => labelStore.getLabelById(labelId)?.title, projectId => projectStore.projects[projectId]?.title || null, ) const transformed = { - ...modelValue, - filter: transform(modelValue.filter), - bucketConfiguration: modelValue.bucketConfiguration.map(bc => ({ + ...props.modelValue, + filter: transform(props.modelValue.filter), + bucketConfiguration: props.modelValue.bucketConfiguration.map(bc => ({ title: bc.title, filter: transform(bc.filter), })), @@ -47,7 +49,7 @@ onBeforeMount(() => { }) function save() { - const transformFilter = filterQuery => transformFilterStringForApi( + const transformFilter = (filterQuery: string) => transformFilterStringForApi( filterQuery, labelTitle => labelStore.filterLabelsByQuery([], labelTitle)[0]?.id || null, projectTitle => { @@ -73,7 +75,7 @@ function validateTitle() { } function handleBubbleSave() { - if (showSaveButtons) { + if (props.showSaveButtons) { return }