Quintiq file version 2.0
#parent: #root
Response OnOpenedView () id:Response_ApplicationLibMacroPlanner_OnOpenedView
{
  #keys: '[108486.0.1959235418]'
  Body:
  [*
    // Process initialization on open view
    this.InitializeNavigationPanel();
    
    // Only allows the dialog to open if opened from a form (frame) or opened from development preconfigure dialogs
    // These dialogs have to match the dialog in the Edit -> Pre-configure dialogs response.
    dlgs := selectset( Frame,
                       SubComponents.astype( Dialog ),
                       dlg,
                       dlg.istype( DialogShowProcessDependency  )
                       or dlg.istype( DialogEditKBCategoryAuthorization )
                       or dlg.istype( ScenarioManager_DialogEditScenarioAuthorization  )
                       or dlg.istype( ScenarioManager_DialogCreateEditStrategy  )
                       or dlg.istype( DialogSanityCheck )
                       or dlg.istype( DialogShowOperationFeedback )
                       or dlg.istype( DialogShowTripFeedback )
                       or dlg.istype( DialogCreateEditInventorySupply )
                       or dlg.istype( DialogCreateEditInventoryValueAndCost )
                       or dlg.istype( DialogCreateEditUnit )
                       or dlg.istype( DialogCreateEditStockingPoint )
                       or dlg.istype( DialogCreateEditPISPSpecification )
                       or dlg.istype( DialogCreateEditOperation )
                       or dlg.istype( DialogCreateEditLaneLeg )
                       or dlg.istype( DialogCreateEditLane )
                       or dlg.istype( DialogImportProfile )
                       or dlg.istype( DialogImportObjectGroupInProfile )
                       or dlg.istype( DialogEDIImport )
                       or dlg.istype( DialogEDIExport ),
                       true
                     );
    
    traverse( dlgs, Elements, dlg )
    {
       dlg.Close();
    }
    // End
    
    // Open the SanityCheckDialog if user switched view via the SanityCheckDialog
    if( [Boolean]ValueHolderShowSanityCheck.Value() )
    {
      ApplicationLibMacroPlanner.ShowSanityCheck();
      // Set nav to root to ensure the visibility of the erroneous instances
      ApplicationLibMacroPlanner.SetNavigationToRoot();
      ValueHolderShowSanityCheck.Value( false.AsQUILL() );
    }
    
    this.ReselectElementsInNavigationPanel();
    
    // Whenever user opens a view, we need to flush DataHolderHideUnits,
    // DataHolderHideUnits stores all child Units that's supposed to be hidden in FormCapacityPlanning when the user double clicks on a Unit
    // It is requested that when the view is changed or Stocking points and units in Navigation panel selection is changed,
    // we need to expand them all again, that's why we flush the data holder here whenever a view is opened
    form := Application.Frame().FindChildObject( typeof( FormCapacityPlanning ).Name() ).astype( FormCapacityPlanning )
    
    if( not isnull( form ) )
    {
      form.DataHolderHideUnits().Data().Flush();
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_Application_OnOpenedView'
}
