From 2dc36c032bad93654fbd64a68682685870972feb Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sat, 1 Oct 2022 15:02:35 +0000 Subject: [PATCH] feat: TaskDetail as script setup (#1792) Co-authored-by: Dominik Pschenitschni Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1792 Reviewed-by: konrad Co-authored-by: Dominik Pschenitschni Co-committed-by: Dominik Pschenitschni --- src/helpers/scrollIntoView.ts | 19 + src/router/index.ts | 3 +- src/views/tasks/TaskDetailView.vue | 573 ++++++++++++++--------------- 3 files changed, 303 insertions(+), 292 deletions(-) create mode 100644 src/helpers/scrollIntoView.ts diff --git a/src/helpers/scrollIntoView.ts b/src/helpers/scrollIntoView.ts new file mode 100644 index 000000000..1ef6bcdc2 --- /dev/null +++ b/src/helpers/scrollIntoView.ts @@ -0,0 +1,19 @@ +export function scrollIntoView(el: HTMLElement | null | undefined) { + if (!el) { + return + } + + const boundingRect = el.getBoundingClientRect() + const scrollY = window.scrollY + + if ( + boundingRect.top > (scrollY + window.innerHeight) || + boundingRect.top < scrollY + ) { + el.scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'nearest', + }) + } +} \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 014c32c0d..395e305e3 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -22,7 +22,8 @@ import DataExportDownload from '../views/user/DataExportDownload.vue' import UpcomingTasksComponent from '../views/tasks/ShowTasks.vue' import LinkShareAuthComponent from '../views/sharing/LinkSharingAuth.vue' import ListNamespaces from '../views/namespaces/ListNamespaces.vue' -import TaskDetailView from '../views/tasks/TaskDetailView.vue' +const TaskDetailView = () => import('../views/tasks/TaskDetailView.vue') + // Team Handling import ListTeamsComponent from '../views/teams/ListTeams.vue' // Label Handling diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 561b1a486..beb9f4546 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -1,7 +1,7 @@ -