Quintiq file version 2.0
#parent: #root
Method EditUnitCapacity (
  internal[GUIComponent] parent,
  structured[UnitCapacity] selection
) id:Method_DialogCreateEditUnitCapacity_EditUnitCapacity
{
  #keys: '[107528.0.125617869]'
  Body:
  [*
    // Edit unit capacities
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit, true, false );
    
    data := shadow( selection.Element( 0 ) );
    Dialog.Data( data );
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      UnitCapacity::Update( selection,
                            data.Unit(),
                            GUIStartDateTimeSelector.DateTime(), // Read-only, apply changes to shadow is not taking place for read-only attribute when editing.
                            CheckBoxBatchEditCapacity.Checked(),
                            data.TimeUnit(),
                            data.MinCapacity(),
                            data.MaxCapacity(),
                            CheckBoxBatchEditMaxLoadPercentage.Checked(),
                            data.MaximumLoadPercentage(),
                            CheckBoxBatchEditNrOfUnitsOpen.Checked(),
                            data.NrOfUnitsOpen() );
    }
  *]
}
