Quintiq file version 2.0
#parent: #root
Method OnChangedRadioButton () id:Method_DialogCreateEditCampaign_OnChangedRadioButton
{
  #keys: '[150660.2.946354305]'
  Body:
  [*
    // Handle default dialog values when change of radio button selection
    checkedRadioButton := RadioButtonGroupQuantityDuration.BoundValue().TrimBoth();
    data := DataHolderDialogData.Data();
    if( not isnull( data ) )
    {
      quantitybased := checkedRadioButton = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity();
      durationbased := not quantitybased;
    
      // On changed radio button selection will reset min/max qty/duration to default values
      if( checkedRadioButton <> data.InputType() )
      {
        EditorCampaignMinQuantity.Text( ifexpr( quantitybased, ApplicationMacroPlanner.FormatRealToString( data.MinQuantity() ), '0' ) );
        DurationSelectorMinDuration.Duration( ifexpr( durationbased, data.MinDuration(), Duration::Zero() ) );
        Form.EnableDisableMaxQuantity( quantitybased and data.HasInputMaxQuantity() );
        Form.EnableDisableMaxDuration( durationbased and data.HasInputMaxDuration() );
        // Set input type ( workaround: retain earliest start before changing input type )
        data.EarliestStart( dsEarliestStart.DateTime() );
        data.InputType( checkedRadioButton );
        
      }
    }
  *]
}
