1
0

feat: remove props destructuring from ViewEditForm

This commit is contained in:
Dominik Pschenitschni 2024-07-05 14:44:26 +02:00 committed by konrad
parent 6e72606d74
commit 2f92e407cc

View File

@ -8,17 +8,19 @@ import {useLabelStore} from '@/stores/labels'
import {useProjectStore} from '@/stores/projects' import {useProjectStore} from '@/stores/projects'
import FilterInputDocs from '@/components/project/partials/FilterInputDocs.vue' import FilterInputDocs from '@/components/project/partials/FilterInputDocs.vue'
const { const props = withDefaults(defineProps<{
modelValue,
loading = false,
showSaveButtons = false,
} = defineProps<{
modelValue: IProjectView, modelValue: IProjectView,
loading?: bool, loading?: boolean,
showSaveButtons?: bool, showSaveButtons?: boolean,
}>() }>(), {
loading: false,
showSaveButtons: false,
})
const emit = defineEmits(['update:modelValue', 'cancel']) const emit = defineEmits<{
'update:modelValue': [value: IProjectView],
'cancel': [],
}>()
const view = ref<IProjectView>() const view = ref<IProjectView>()
@ -26,16 +28,16 @@ const labelStore = useLabelStore()
const projectStore = useProjectStore() const projectStore = useProjectStore()
onBeforeMount(() => { onBeforeMount(() => {
const transform = filterString => transformFilterStringFromApi( const transform = (filterString: string) => transformFilterStringFromApi(
filterString, filterString,
labelId => labelStore.getLabelById(labelId)?.title, labelId => labelStore.getLabelById(labelId)?.title,
projectId => projectStore.projects[projectId]?.title || null, projectId => projectStore.projects[projectId]?.title || null,
) )
const transformed = { const transformed = {
...modelValue, ...props.modelValue,
filter: transform(modelValue.filter), filter: transform(props.modelValue.filter),
bucketConfiguration: modelValue.bucketConfiguration.map(bc => ({ bucketConfiguration: props.modelValue.bucketConfiguration.map(bc => ({
title: bc.title, title: bc.title,
filter: transform(bc.filter), filter: transform(bc.filter),
})), })),
@ -47,7 +49,7 @@ onBeforeMount(() => {
}) })
function save() { function save() {
const transformFilter = filterQuery => transformFilterStringForApi( const transformFilter = (filterQuery: string) => transformFilterStringForApi(
filterQuery, filterQuery,
labelTitle => labelStore.filterLabelsByQuery([], labelTitle)[0]?.id || null, labelTitle => labelStore.filterLabelsByQuery([], labelTitle)[0]?.id || null,
projectTitle => { projectTitle => {
@ -73,7 +75,7 @@ function validateTitle() {
} }
function handleBubbleSave() { function handleBubbleSave() {
if (showSaveButtons) { if (props.showSaveButtons) {
return return
} }