feat(schedule): make initial scroll to work start work

This commit is contained in:
Johannes Millan 2025-09-13 12:54:56 +02:00
parent db83f3f919
commit b72a9b169c
4 changed files with 50 additions and 17 deletions

View file

@ -50,6 +50,7 @@
<!-- Work Start and End -->
@if (workStartEnd()) {
<div
id="work-start"
class="work-start"
style="grid-row: {{ workStartEnd()!.workStartRow }}"
>
@ -64,6 +65,7 @@
}
<div
id="current-time"
class="current-time"
style="grid-column: 2; grid-row: {{ currentTimeRow() }} / span 1"
>

View file

@ -59,18 +59,20 @@
</div>
</header>
@if (isMonthView()) {
<schedule-month
[events]="events()"
[daysToShow]="daysToShow()"
[weeksToShow]="weeksToShow()"
></schedule-month>
} @else {
<schedule-week
[events]="events()"
[beyondBudget]="beyondBudget()"
[daysToShow]="daysToShow()"
[workStartEnd]="workStartEnd()"
[currentTimeRow]="currentTimeRow()"
></schedule-week>
}
<div class="scroll-wrapper">
@if (isMonthView()) {
<schedule-month
[events]="events()"
[daysToShow]="daysToShow()"
[weeksToShow]="weeksToShow()"
></schedule-month>
} @else {
<schedule-week
[events]="events()"
[beyondBudget]="beyondBudget()"
[daysToShow]="daysToShow()"
[workStartEnd]="workStartEnd()"
[currentTimeRow]="currentTimeRow()"
></schedule-week>
}
</div>

View file

@ -4,6 +4,16 @@
--nr-of-days: 5;
--nr-of-weeks: 6;
background: transparent;
display: flex;
flex-direction: column;
}
// we need this to prevent problems with route ani and scroll behavior
.scroll-wrapper {
position: absolute;
inset: 0;
height: 100%;
overflow-y: scroll;
}
header {

View file

@ -1,6 +1,14 @@
/* eslint-disable */
import { ChangeDetectionStrategy, Component, inject, computed } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
inject,
computed,
OnInit,
AfterViewInit,
} from '@angular/core';
import { fromEvent } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import { select, Store } from '@ngrx/store';
import { selectTimelineTasks } from '../../work-context/store/work-context.selectors';
import { selectPlannerDayMap } from '../../planner/store/planner.selectors';
@ -39,7 +47,7 @@ import { ScheduleService } from '../schedule.service';
'[style.--nr-of-days]': 'daysToShow().length',
},
})
export class ScheduleComponent {
export class ScheduleComponent implements AfterViewInit {
taskService = inject(TaskService);
layoutService = inject(LayoutService);
scheduleService = inject(ScheduleService);
@ -47,6 +55,7 @@ export class ScheduleComponent {
private _calendarIntegrationService = inject(CalendarIntegrationService);
private _store = inject(Store);
private _globalTrackingIntervalService = inject(GlobalTrackingIntervalService);
private _route = inject(ActivatedRoute);
private _currentTimeViewMode = computed(() => this.layoutService.selectedTimeView());
isMonthView = computed(() => this._currentTimeViewMode() === 'month');
@ -200,4 +209,14 @@ export class ScheduleComponent {
});
}
}
ngAfterViewInit(): void {
// Handle fragment scrolling manually as a fallback
setTimeout(() => {
const element = document.getElementById('work-start');
if (element) {
element.scrollIntoView({ behavior: 'instant', block: 'start' });
}
}); // Small delay to ensure DOM is fully rendered
}
}