@@ -687,6 +687,9 @@ export class NavigationManager {
687687 this . createTimelineSession ( session , date , timelineTrack , allSessions ) ;
688688 } ) ;
689689
690+ // Calculate and set timeline height after all sessions are added
691+ this . updateTimelineHeight ( timelineTrack , allSessions . length ) ;
692+
690693 // Initialize timeline interactions
691694 this . initializeTimelineInteractions ( ) ;
692695
@@ -843,6 +846,41 @@ export class NavigationManager {
843846 return TimeUtils . formatTime ( seconds ) ;
844847 }
845848
849+ updateTimelineHeight ( timelineTrack , totalSessions ) {
850+ const rowHeight = 20 ; // 15px session height + 5px spacing
851+ const baseHeight = 25 ; // Base padding
852+ const minHeight = 60 ; // Minimum height even with no sessions
853+ const requiredHeight = Math . max ( minHeight , baseHeight + ( totalSessions * rowHeight ) ) ;
854+
855+ timelineTrack . style . height = `${ requiredHeight } px` ;
856+
857+ // Add vertical grid lines
858+ this . addTimelineGridLines ( timelineTrack ) ;
859+ }
860+
861+ addTimelineGridLines ( timelineTrack ) {
862+ // Remove existing grid lines
863+ const existingLines = timelineTrack . querySelectorAll ( '.timeline-grid-line' ) ;
864+ existingLines . forEach ( line => line . remove ( ) ) ;
865+
866+ // Add grid lines for major hours: 0, 4, 8, 12, 16, 20
867+ const majorHours = [ 0 , 4 , 8 , 12 , 16 , 20 ] ;
868+ const timelineStartHour = 0 ;
869+ const timelineRangeHours = 24 ;
870+
871+ majorHours . forEach ( hour => {
872+ const line = document . createElement ( 'div' ) ;
873+ line . className = 'timeline-grid-line' ;
874+
875+ // Calculate position percentage
876+ const hoursFromStart = hour - timelineStartHour ;
877+ const percentage = ( hoursFromStart / timelineRangeHours ) * 100 ;
878+ line . style . left = `${ percentage } %` ;
879+
880+ timelineTrack . appendChild ( line ) ;
881+ } ) ;
882+ }
883+
846884 setupTimelineHours ( timelineHours ) {
847885 timelineHours . innerHTML = '' ;
848886
@@ -936,18 +974,6 @@ export class NavigationManager {
936974 sessionElement . classList . add ( 'session-stacked' ) ;
937975 }
938976
939- // Calculate required height for all sessions
940- const totalSessions = allSessions . length ;
941- const rowHeight = 20 ; // 15px session height + 5px spacing
942- const baseHeight = 20 ; // Base padding
943- const requiredHeight = baseHeight + ( totalSessions * rowHeight ) ;
944-
945- // Update timeline track height
946- const currentHeight = parseInt ( timelineTrack . style . height ) || 50 ;
947- if ( requiredHeight > currentHeight ) {
948- timelineTrack . style . height = `${ requiredHeight } px` ;
949- }
950-
951977 timelineTrack . appendChild ( sessionElement ) ;
952978 }
953979
@@ -1045,7 +1071,6 @@ export class NavigationManager {
10451071
10461072 contextMenu . innerHTML = `
10471073 <div class="context-menu-item edit-item">${ isHistorical ? 'Convert to Manual & Edit' : 'Edit Session' } </div>
1048- <div class="context-menu-item duplicate-item">Duplicate</div>
10491074 ${ isHistorical ? '' : '<div class="context-menu-item danger delete-item">Delete</div>' }
10501075 ` ;
10511076
@@ -1084,7 +1109,7 @@ export class NavigationManager {
10841109 const deleteItem = contextMenu . querySelector ( '.delete-item' ) ;
10851110 if ( deleteItem ) {
10861111 deleteItem . addEventListener ( 'click' , ( ) => {
1087- if ( window . sessionManager && confirm ( 'Are you sure you want to delete this session?' ) ) {
1112+ if ( window . sessionManager ) {
10881113 window . sessionManager . currentEditingSession = session ;
10891114 window . sessionManager . selectedDate = date ;
10901115 window . sessionManager . deleteCurrentSession ( ) ;
@@ -1093,12 +1118,6 @@ export class NavigationManager {
10931118 } ) ;
10941119 }
10951120
1096- contextMenu . querySelector ( '.duplicate-item' ) . addEventListener ( 'click' , ( ) => {
1097- // TODO: Implement session duplication
1098- console . log ( 'Duplicate session:' , session ) ;
1099- contextMenu . remove ( ) ;
1100- } ) ;
1101-
11021121 document . body . appendChild ( contextMenu ) ;
11031122 }
11041123
0 commit comments