Quintiq file version 2.0
#parent: #root
Method ToggleSettingsFormViaButtonMenu (
  internal[WebMenu] buttonMenu
) id:Method_ApplicationMacroPlanner_ToggleSettingsFormViaButtonMenu
{
  #keys: '[144528.5.1923940361]'
  Body:
  [*
    // Toggle settings form show/hide via action bar button menu
    // Reason we need these codes as we cannot pass in form instance thus need to track the form open/close via dataholder
    if( not isnull( buttonMenu ) )
    {  
      if( ApplicationMacroPlanner.MenuOptimizerSettings().Name() = buttonMenu.Name() )
      {
        // Check if form already opened (not null)
        frm := select( DataHolderSettingsForms.Data(), Elements.astype( FormOptimizerSettings ), webform, true );
        if( isnull( frm ) )
        {
          frm := construct( FormOptimizerSettings );
          frm.ShowDockRight();       
        }
        else
        {
          frm.Close();
        }
      }
      else if( ApplicationMacroPlanner.MenuOptimizerPuzzles().Name() = buttonMenu.Name() )
      {
        // Check if form already opened (not null)
        frm := select( DataHolderSettingsForms.Data(), Elements.astype( FormOptimizerPuzzles ), webform, true );
        if( isnull( frm ) )
        {
          frm := construct( FormOptimizerPuzzles );
          frm.ShowDockRight();     
        }
        else
        {
          frm.Close();
        }
      }
      else if( ApplicationMacroPlanner.MenuOptimizerStrategies().Name() = buttonMenu.Name() )
      {
        // Check if form already opened (not null)
        frm := select( DataHolderSettingsForms.Data(), Elements.astype( FormOptimizerStrategiesSlideIn ), webform, true );
        if( isnull( frm ) )
        {
          frm := construct( FormOptimizerStrategiesSlideIn );
          frm.ShowDockRight();       
        }
        else
        {
          frm.Close();
        }
      }
    }
  *]
}
