Quintiq file version 2.0
#parent: #root
Method OnUserUpdateUI (
  UnitOfMeasure_MP uom
) id:Method_DialogCreateEditSupplyTarget_OnUserUpdateUI
{
  #keys: '[139394.1.54631599]'
  Body:
  [*
    // Enable or disable components when user updates UI
    // Update date time selector value when we toggle the checkbox
    
    // CheckBox has start
    checked   := CheckboxStart.Checked();
    dateValue := DateTimeSelectorStart.DateTime();
    
    DateTimeSelectorStart.Enabled( checked, "" );
    
    if( checked )
    {
      start := ifexpr( dateValue.IsFinite(),
                       dateValue,
                       MacroPlan.Start() );
      DateTimeSelectorStart.DateTime( start );
    }
    else if( not checked )
    {
      DateTimeSelectorStart.DateTime( DateTime::MinDateTime() );
    }
    
    // Checkbox has end
    // Update end datetime when user toggles the checkbox
    checked := CheckboxEnd.Checked();
    dateValue := DateTimeSelectorEnd.DateTime();
    
    DateTimeSelectorEnd.Enabled( checked, "" ); 
    
    if( checked )
    {
      end := ifexpr( dateValue.IsFinite(),
                     dateValue,
                     MacroPlan.End() );
      DateTimeSelectorEnd.DateTime( end );
    }
    else if( not checked )
    {
      DateTimeSelectorEnd.DateTime( DateTime::MaxDateTime() );
    }
    
    // Max quantity
    EditFieldMaxQuantity.Enabled( CheckboxHasMaxQuantity.Checked(), '' );
    
    // Update labels
    this.SetLabels( uom );
  *]
}
