feat: remove props destructuring for ProjectWrapper
This commit is contained in:
parent
eb07be1a62
commit
38744dfd5d
@ -16,13 +16,13 @@
|
|||||||
class="switch-view"
|
class="switch-view"
|
||||||
>
|
>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-for="v in views"
|
v-for="view in views"
|
||||||
:key="v.id"
|
:key="view.id"
|
||||||
class="switch-view-button"
|
class="switch-view-button"
|
||||||
:class="{'is-active': v.id === viewId}"
|
:class="{'is-active': view.id === viewId}"
|
||||||
:to="{ name: 'project.view', params: { projectId, viewId: v.id } }"
|
:to="{ name: 'project.view', params: { projectId, viewId: view.id } }"
|
||||||
>
|
>
|
||||||
{{ getViewTitle(v) }}
|
{{ getViewTitle(view) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
@ -62,10 +62,7 @@ import type {IProject} from '@/modelTypes/IProject'
|
|||||||
import type {IProjectView} from '@/modelTypes/IProjectView'
|
import type {IProjectView} from '@/modelTypes/IProjectView'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
const {
|
const props = defineProps<{
|
||||||
projectId,
|
|
||||||
viewId,
|
|
||||||
} = defineProps<{
|
|
||||||
projectId: IProject['id'],
|
projectId: IProject['id'],
|
||||||
viewId: IProjectView['id'],
|
viewId: IProjectView['id'],
|
||||||
}>()
|
}>()
|
||||||
@ -88,7 +85,7 @@ const currentProject = computed<IProject>(() => {
|
|||||||
})
|
})
|
||||||
useTitle(() => currentProject.value?.id ? getProjectTitle(currentProject.value) : '')
|
useTitle(() => currentProject.value?.id ? getProjectTitle(currentProject.value) : '')
|
||||||
|
|
||||||
const views = computed(() => projectStore.projects[projectId]?.views)
|
const views = computed(() => projectStore.projects[props.projectId]?.views)
|
||||||
|
|
||||||
// watchEffect would be called every time the prop would get a value assigned, even if that value was the same as before.
|
// watchEffect would be called every time the prop would get a value assigned, even if that value was the same as before.
|
||||||
// This resulted in loading and setting the project multiple times, even when navigating away from it.
|
// This resulted in loading and setting the project multiple times, even when navigating away from it.
|
||||||
@ -96,7 +93,7 @@ const views = computed(() => projectStore.projects[projectId]?.views)
|
|||||||
// project background and then navigating to home. It also highlighted the project in the menu and didn't allow changing any
|
// project background and then navigating to home. It also highlighted the project in the menu and didn't allow changing any
|
||||||
// of it, most likely due to the rights not being properly populated.
|
// of it, most likely due to the rights not being properly populated.
|
||||||
watch(
|
watch(
|
||||||
() => projectId,
|
() => props.projectId,
|
||||||
// loadProject
|
// loadProject
|
||||||
async (projectIdToLoad: number) => {
|
async (projectIdToLoad: number) => {
|
||||||
const projectData = {id: projectIdToLoad}
|
const projectData = {id: projectIdToLoad}
|
||||||
@ -112,7 +109,7 @@ watch(
|
|||||||
)
|
)
|
||||||
&& typeof currentProject.value !== 'undefined' && currentProject.value.maxRight !== null
|
&& typeof currentProject.value !== 'undefined' && currentProject.value.maxRight !== null
|
||||||
) {
|
) {
|
||||||
loadedProjectId.value = projectId
|
loadedProjectId.value = projectIdToLoad
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +128,7 @@ watch(
|
|||||||
const loadedProject = await projectService.value.get(project)
|
const loadedProject = await projectService.value.get(project)
|
||||||
baseStore.handleSetCurrentProject({project: loadedProject})
|
baseStore.handleSetCurrentProject({project: loadedProject})
|
||||||
} finally {
|
} finally {
|
||||||
loadedProjectId.value = projectId
|
loadedProjectId.value = projectIdToLoad
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{immediate: true},
|
{immediate: true},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user