chore(views): use view id instead of passing whole view object
This commit is contained in:
parent
7368a51f18
commit
4c1a53beed
@ -12,7 +12,7 @@
|
|||||||
<BaseButton
|
<BaseButton
|
||||||
v-for="v in views"
|
v-for="v in views"
|
||||||
class="switch-view-button"
|
class="switch-view-button"
|
||||||
:class="{'is-active': v.id === view.id}"
|
:class="{'is-active': v.id === viewId}"
|
||||||
:to="{ name: 'project.view', params: { projectId, viewId: v.id } }"
|
:to="{ name: 'project.view', params: { projectId, viewId: v.id } }"
|
||||||
>
|
>
|
||||||
{{ getViewTitle(v) }}
|
{{ getViewTitle(v) }}
|
||||||
@ -57,10 +57,10 @@ import {useI18n} from 'vue-i18n'
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
projectId,
|
projectId,
|
||||||
view,
|
viewId,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
projectId: number,
|
projectId: IProject['id'],
|
||||||
view: IProjectView,
|
viewId: IProjectView['id'],
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -109,7 +109,7 @@ watch(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug(`Loading project, props.view = ${view}, $route.params =`, route.params, `, loadedProjectId = ${loadedProjectId.value}, currentProject = `, currentProject.value)
|
console.debug(`Loading project, $route.params =`, route.params, `, loadedProjectId = ${loadedProjectId.value}, currentProject = `, currentProject.value)
|
||||||
|
|
||||||
// Set the current project to the one we're about to load so that the title is already shown at the top
|
// Set the current project to the one we're about to load so that the title is already shown at the top
|
||||||
loadedProjectId.value = 0
|
loadedProjectId.value = 0
|
||||||
|
@ -98,7 +98,7 @@ type Options = Flatpickr.Options.Options
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
route: RouteLocationNormalized
|
route: RouteLocationNormalized
|
||||||
view: IProjectView
|
viewId: IProjectView['id']
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const GanttChart = createAsyncComponent(() => import('@/components/tasks/GanttChart.vue'))
|
const GanttChart = createAsyncComponent(() => import('@/components/tasks/GanttChart.vue'))
|
||||||
@ -115,7 +115,7 @@ const {
|
|||||||
isLoading,
|
isLoading,
|
||||||
addTask,
|
addTask,
|
||||||
updateTask,
|
updateTask,
|
||||||
} = useGanttFilters(route, props.view)
|
} = useGanttFilters(route, props.viewId)
|
||||||
|
|
||||||
const DEFAULT_DATE_RANGE_DAYS = 7
|
const DEFAULT_DATE_RANGE_DAYS = 7
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ProjectWrapper
|
<ProjectWrapper
|
||||||
class="project-kanban"
|
class="project-kanban"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view
|
:viewId
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
@ -307,10 +307,10 @@ import TaskPositionModel from '@/models/taskPosition'
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
projectId,
|
projectId,
|
||||||
view,
|
viewId,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
projectId: number,
|
projectId: number,
|
||||||
view: IProjectView,
|
viewId: IProjectView['id'],
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const DRAG_OPTIONS = {
|
const DRAG_OPTIONS = {
|
||||||
@ -399,14 +399,14 @@ watch(
|
|||||||
() => ({
|
() => ({
|
||||||
params: params.value,
|
params: params.value,
|
||||||
projectId,
|
projectId,
|
||||||
viewId: view.id,
|
viewId,
|
||||||
}),
|
}),
|
||||||
({params}) => {
|
({params}) => {
|
||||||
if (projectId === undefined || Number(projectId) === 0) {
|
if (projectId === undefined || Number(projectId) === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
collapsedBuckets.value = getCollapsedBucketState(projectId)
|
collapsedBuckets.value = getCollapsedBucketState(projectId)
|
||||||
kanbanStore.loadBucketsForProject(projectId, view.id, params)
|
kanbanStore.loadBucketsForProject(projectId, viewId, params)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
@ -431,7 +431,7 @@ function handleTaskContainerScroll(id: IBucket['id'], projectId: IProject['id'],
|
|||||||
|
|
||||||
kanbanStore.loadNextTasksForBucket(
|
kanbanStore.loadNextTasksForBucket(
|
||||||
projectId,
|
projectId,
|
||||||
view.id,
|
viewId,
|
||||||
params.value,
|
params.value,
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
@ -511,7 +511,7 @@ async function updateTaskPosition(e) {
|
|||||||
try {
|
try {
|
||||||
const newPosition = new TaskPositionModel({
|
const newPosition = new TaskPositionModel({
|
||||||
position,
|
position,
|
||||||
projectViewId: view.id,
|
projectViewId: viewId,
|
||||||
taskId: newTask.id,
|
taskId: newTask.id,
|
||||||
})
|
})
|
||||||
await taskPositionService.value.update(newPosition)
|
await taskPositionService.value.update(newPosition)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ProjectWrapper
|
<ProjectWrapper
|
||||||
class="project-list"
|
class="project-list"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view
|
:viewId
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
@ -123,10 +123,10 @@ import TaskPositionModel from '@/models/taskPosition'
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
projectId,
|
projectId,
|
||||||
view,
|
viewId,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
projectId: IProject['id'],
|
projectId: IProject['id'],
|
||||||
view: IProjectView,
|
viewId: IProjectView['id'],
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const ctaVisible = ref(false)
|
const ctaVisible = ref(false)
|
||||||
@ -145,7 +145,7 @@ const {
|
|||||||
loadTasks,
|
loadTasks,
|
||||||
params,
|
params,
|
||||||
sortByParam,
|
sortByParam,
|
||||||
} = useTaskList(() => projectId, () => view.id, {position: 'asc'})
|
} = useTaskList(() => projectId, () => viewId, {position: 'asc'})
|
||||||
|
|
||||||
const taskPositionService = ref(new TaskPositionService())
|
const taskPositionService = ref(new TaskPositionService())
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ async function saveTaskPosition(e) {
|
|||||||
|
|
||||||
await taskPositionService.value.update(new TaskPositionModel({
|
await taskPositionService.value.update(new TaskPositionModel({
|
||||||
position,
|
position,
|
||||||
projectViewId: view.id,
|
projectViewId: viewId,
|
||||||
taskId: task.id,
|
taskId: task.id,
|
||||||
}))
|
}))
|
||||||
tasks.value[e.newIndex] = {
|
tasks.value[e.newIndex] = {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ProjectWrapper
|
<ProjectWrapper
|
||||||
class="project-table"
|
class="project-table"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view
|
:viewId
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
@ -293,10 +293,10 @@ import type {IProjectView} from '@/modelTypes/IProjectView'
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
projectId,
|
projectId,
|
||||||
view,
|
viewId,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
projectId: IProject['id'],
|
projectId: IProject['id'],
|
||||||
view: IProjectView,
|
viewId: IProjectView['id'],
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const ACTIVE_COLUMNS_DEFAULT = {
|
const ACTIVE_COLUMNS_DEFAULT = {
|
||||||
@ -323,7 +323,7 @@ const SORT_BY_DEFAULT: SortBy = {
|
|||||||
const activeColumns = useStorage('tableViewColumns', {...ACTIVE_COLUMNS_DEFAULT})
|
const activeColumns = useStorage('tableViewColumns', {...ACTIVE_COLUMNS_DEFAULT})
|
||||||
const sortBy = useStorage<SortBy>('tableViewSortBy', {...SORT_BY_DEFAULT})
|
const sortBy = useStorage<SortBy>('tableViewSortBy', {...SORT_BY_DEFAULT})
|
||||||
|
|
||||||
const taskList = useTaskList(() => projectId, () => view.id, sortBy.value)
|
const taskList = useTaskList(() => projectId, () => viewId, sortBy.value)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
loading,
|
loading,
|
||||||
|
@ -51,22 +51,22 @@ const route = useRoute()
|
|||||||
<ProjectList
|
<ProjectList
|
||||||
v-if="currentView?.viewKind === 'list'"
|
v-if="currentView?.viewKind === 'list'"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view="currentView"
|
:viewId
|
||||||
/>
|
/>
|
||||||
<ProjectGantt
|
<ProjectGantt
|
||||||
v-if="currentView?.viewKind === 'gantt'"
|
v-if="currentView?.viewKind === 'gantt'"
|
||||||
:route
|
:route
|
||||||
:view="currentView"
|
:viewId
|
||||||
/>
|
/>
|
||||||
<ProjectTable
|
<ProjectTable
|
||||||
v-if="currentView?.viewKind === 'table'"
|
v-if="currentView?.viewKind === 'table'"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view="currentView"
|
:viewId
|
||||||
/>
|
/>
|
||||||
<ProjectKanban
|
<ProjectKanban
|
||||||
v-if="currentView?.viewKind === 'kanban'"
|
v-if="currentView?.viewKind === 'kanban'"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:view="currentView"
|
:viewId
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ export type UseGanttFiltersReturn =
|
|||||||
ReturnType<typeof useRouteFilters<GanttFilters>> &
|
ReturnType<typeof useRouteFilters<GanttFilters>> &
|
||||||
ReturnType<typeof useGanttTaskList<GanttFilters>>
|
ReturnType<typeof useGanttTaskList<GanttFilters>>
|
||||||
|
|
||||||
export function useGanttFilters(route: Ref<RouteLocationNormalized>, view: IProjectView): UseGanttFiltersReturn {
|
export function useGanttFilters(route: Ref<RouteLocationNormalized>, viewId: IProjectView['id']): UseGanttFiltersReturn {
|
||||||
const {
|
const {
|
||||||
filters,
|
filters,
|
||||||
hasDefaultFilters,
|
hasDefaultFilters,
|
||||||
@ -114,7 +114,7 @@ export function useGanttFilters(route: Ref<RouteLocationNormalized>, view: IProj
|
|||||||
isLoading,
|
isLoading,
|
||||||
addTask,
|
addTask,
|
||||||
updateTask,
|
updateTask,
|
||||||
} = useGanttTaskList<GanttFilters>(filters, ganttFiltersToApiParams, view)
|
} = useGanttTaskList<GanttFilters>(filters, ganttFiltersToApiParams, viewId)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filters,
|
filters,
|
||||||
|
@ -16,7 +16,7 @@ import type {IProjectView} from '@/modelTypes/IProjectView'
|
|||||||
export function useGanttTaskList<F extends Filters>(
|
export function useGanttTaskList<F extends Filters>(
|
||||||
filters: Ref<F>,
|
filters: Ref<F>,
|
||||||
filterToApiParams: (filters: F) => TaskFilterParams,
|
filterToApiParams: (filters: F) => TaskFilterParams,
|
||||||
view: IProjectView,
|
viewId: IProjectView['id'],
|
||||||
loadAll: boolean = true,
|
loadAll: boolean = true,
|
||||||
) {
|
) {
|
||||||
const taskCollectionService = shallowReactive(new TaskCollectionService())
|
const taskCollectionService = shallowReactive(new TaskCollectionService())
|
||||||
@ -33,7 +33,7 @@ export function useGanttTaskList<F extends Filters>(
|
|||||||
params.filter_timezone = authStore.settings.timezone
|
params.filter_timezone = authStore.settings.timezone
|
||||||
}
|
}
|
||||||
|
|
||||||
const tasks = await taskCollectionService.getAll({projectId: filters.value.projectId, viewId: view.id}, params, page) as ITask[]
|
const tasks = await taskCollectionService.getAll({projectId: filters.value.projectId, viewId}, params, page) as ITask[]
|
||||||
if (loadAll && page < taskCollectionService.totalPages) {
|
if (loadAll && page < taskCollectionService.totalPages) {
|
||||||
const nextTasks = await fetchTasks(params, page + 1)
|
const nextTasks = await fetchTasks(params, page + 1)
|
||||||
return tasks.concat(nextTasks)
|
return tasks.concat(nextTasks)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user