Quintiq file version 2.0
#parent: #root
Method OnUserUpdateUI (
  Unit unit
) id:Method_DialogCreateEditOperation_OnUserUpdateUI
{
  #keys: '[139394.0.1386330232]'
  Body:
  [*
    // Enable disable batch edit components
    
    isbatchedit := DataHolderDialogDatas.Data().Size() > 1;
    
    // Enable / disable components in general tab
    DurationSelectorLeadTime.Enabled( not isbatchedit or CheckBoxBatchEditLeadTime.Checked(), '' );
    
    istime := guard( unit.HasCapacityTypeTimeBase(), false );
    EditFieldThroughput.Enabled( istime and ( not isbatchedit or CheckBoxBatchEditThroughput.Checked() ),
                                 Translations::MP_Operation_InvalidCapacityType_Time() );
    
    // Enable / disable components in Lot size tab
    CheckboxHasUserLotSize.Enabled( not isbatchedit or CheckBoxBatchEditHasUserLotSize.Checked(), '' );
    CheckboxHasUserMaximumQuantity.Enabled( CheckboxHasUserLotSize.Checked() 
                                            and ( not isbatchedit or CheckBoxBatchEditHasUserLotSize.Checked() ), '' );
    EditFieldUserMinimumQuantity.Enabled( CheckboxHasUserLotSize.Checked() 
                                          and ( not isbatchedit or CheckBoxBatchEditHasUserLotSize.Checked() ), '' );
    EditFieldUserMaximumQuantity.Enabled( CheckboxHasUserLotSize.Checked()
                                          and CheckboxHasUserMaximumQuantity.Checked() 
                                          and (not isbatchedit or CheckBoxBatchEditHasUserLotSize.Checked() ), '' );
    EditFieldUserLotSize.Enabled( CheckboxHasUserLotSize.Checked() 
                                  and ( not isbatchedit or CheckBoxBatchEditHasUserLotSize.Checked() ), '' );
    
    this.SetLotSizeLabel(  ApplicationMacroPlanner.FormatStringToReal( EditFieldUserLotSize.Text() ) );
    
    // Enable / disable components in Advanced tab
    DurationSelectorSTDLeadTime.Enabled( not isbatchedit or CheckBoxBatchEditStandardDeviation.Checked(), '' );
    
    // Disable co2 field if global parameter CO2 emission was not defined or batch edit unchecked
    hasDefinedGlobalCO2 := ifexpr( isnull( MacroPlan ), false, MacroPlan.GlobalParameters_MP().DefaultCO2EmissionUoM().Length() > 0 );
    tooltip := ifexpr( hasDefinedGlobalCO2, '', Translations::MP_GlobalParameters_CO2GlobalDefined() );
    EditFieldCO2Emission.Enabled( (not isbatchedit or CheckboxBatchCO2.Checked() )and hasDefinedGlobalCO2, tooltip );
  *]
}
