Quintiq file version 2.0
#parent: #root
Method SnapToGanttChart () id:Method_BaseFormCapacityPlanning_SnapToGanttChart
{
  #keys: '[136682.2.891037353]'
  Body:
  [*
    //Ensure visibility of gantt chart
    if( not isnull( MacroPlan ) )
    {
      futureperiods := selectset( ApplicationMacroPlanner.DataHolderPeriods().Data(), Elements, period, true, not period.IsHistorical() );
      
      start := min( futureperiods, Elements, period, true , period.Start() );
      end := max( futureperiods, Elements, period, true, period.End() ); 
      
      maxloop := minvalue( futureperiods.Size(), 12 );
      
      start := ifexpr( start.IsFinite(), start, MacroPlan.StartOfPlanning() );
      
      
      periodEnd := guard( futureperiods.Element( maxloop -1 ), null( Period_MP ) );
      
      end := guard( periodEnd.End(), start );
      
      GanttChartCapacityPlanning.Show( start, end );
    GanttChartCapacityPlanning.EnsureVisible( start, "left" );
    }
  *]
}
