OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[Gantt-Chart] Scroll to Today's Position #40167 (#11573)
Svend429ea6b696c
diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-static-elements.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-static-elements.directive.tsindex f36cdf6aa7a..a89237b68bd 100644--- a/frontend/src/app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-static-elements.directive.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-static-elements.directive.ts@@ -32,7 +32,7 @@ import {} from '@angular/core';import { States } from 'core-app/core/states/states.service';import { WorkPackageTimelineTableController } from '../container/wp-timeline-container.directive';-import { TimelineViewParameters } from '../wp-timeline';+import { calculatePositionValueForDayCountingPx, TimelineViewParameters } from '../wp-timeline';import {TimelineStaticElement,timelineStaticElementCssClassname,@@ -82,5 +82,12 @@ export class WorkPackageTableTimelineStaticElements implements OnInit {for (const e of this.elements) {this.container.appendChild(e.render(vp));}+ const timelineSide = document.querySelector('.work-packages-tabletimeline--timeline-side');+ if (timelineSide !== null && vp.settings.zoomLevel !== 'auto') {+ const visibleMomentBeforeToday = vp.now.clone().subtract(vp.settings.visibleBeforeTodayInZoomLevel, vp.settings.zoomLevel)+ const visibleDaysBeforeToday = visibleMomentBeforeToday.diff(vp.dateDisplayStart, 'days');+ const visibleDaysBeforeTodayPositionPixels = calculatePositionValueForDayCountingPx(vp, visibleDaysBeforeToday);+ timelineSide.scrollLeft = visibleDaysBeforeTodayPositionPixels;+ }}}diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/wp-timeline.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/wp-timeline.tsindex 6aae88b34c1..7661863aede 100644--- a/frontend/src/app/features/work-packages/components/wp-table/timeline/wp-timeline.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/wp-timeline.ts@@ -44,6 +44,7 @@ export const timelineHeaderSelector = 'wp-timeline-header';*/export class TimelineViewParametersSettings {zoomLevel:TimelineZoomLevel = 'days';+ visibleBeforeTodayInZoomLevel:number = 2;}// Can't properly map the enum to a string arraydiff --git a/spec/features/work_packages/timeline/timeline_dates_spec.rb b/spec/features/work_packages/timeline/timeline_dates_spec.rbindex 7c56f6be28c..f667c7108b4 100644--- a/spec/features/work_packages/timeline/timeline_dates_spec.rb+++ b/spec/features/work_packages/timeline/timeline_dates_spec.rb@@ -174,6 +174,20 @@ RSpec.describe 'Work package timeline date formatting',let(:current_user) { create(:admin) }let(:row) { wp_timeline.timeline_row work_package_with_non_working_days.id }+ it 'today_line is in view' do+ row.wait_until_hoverable+ today_line_offsetLeft = page.evaluate_script <<~JS+ document.getElementById('wp-timeline-static-element-today-line').offsetLeft+ JS+ timeline_side_scrollLeft = page.evaluate_script <<~JS+ document.getElementsByClassName('work-packages-tabletimeline--timeline-side')[0].scrollLeft+ JS+ timeline_side_clientWidth = page.evaluate_script <<~JS+ document.getElementsByClassName('work-packages-tabletimeline--timeline-side')[0].clientWidth+ JS+ expect(today_line_offsetLeft).to be_between(timeline_side_scrollLeft, timeline_side_scrollLeft + timeline_side_clientWidth)+ end+shared_let(:non_working_day) docreate(:non_working_day,date: '06-01-2021')diff --git a/spec/support/components/timelines/timeline_row.rb b/spec/support/components/timelines/timeline_row.rbindex aaed9073dff..a6bd1c1cfe3 100644--- a/spec/support/components/timelines/timeline_row.rb+++ b/spec/support/components/timelines/timeline_row.rb@@ -75,6 +75,7 @@ module Componentsdef hover_bar(offset_days: 0)wait_until_hoverable+ scrollToLeftoffset_x = offset_days * 30page.driver.browser.action.move_to(@container.native, offset_x).performend@@ -106,6 +107,7 @@ module Componentsdef drag_and_drop(offset_days: 0, days: 1)wait_until_hoverable+ scrollToLeftoffset_x_start = offset_days * 30start_dragging(container, offset_x: offset_x_start)offset_x = ((days - 1) * 30) + offset_x_start@@ -113,14 +115,20 @@ module Componentsdrag_releaseend- private-def wait_until_hoverable# The timeline element and the mouse handlers are lazily loaded and can# be hidden if no dates are set. Finding it waits until the lazy loading# has completed.container.find('.timeline-element', visible: :all)end++ private++ def scrollToLeft+ # timeline being scrolled to today is potentially moving elements of the tests out of sight+ # thus, let's scroll back timeline to the far left in order to restore ability to use e.g. "driver.move_to"+ page.driver.execute_script("document.getElementsByClassName('work-packages-tabletimeline--timeline-side')[0].scrollLeft=0")+ endendendend