Quintiq file version 2.0
#parent: #root
Method EditUnitAvailability (
  internal[GUIComponent] parent,
  structured[UnitAvailability] selection
) id:Method_DialogCreateEditUnitAvailability_EditUnitAvailability
{
  #keys: '[11660.0.63829758]'
  Body:
  [*
    // Edit unit availabilities
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit, true, false );
    
    data := shadow( selection.Element( 0 ) );
    Dialog.Data( data );
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      UnitAvailability::Update( selection,
                                data.Unit(),
                                GUIStartDateTimeSelector.DateTime(), // Read-only, apply changes to shadow is not taking place for read-only attribute when editing.
                                CheckBoxBatchEditMaintenance.Checked(),
                                data.TimeUnit(),
                                data.Maintenance(),
                                CheckBoxBatchEditEfficiency.Checked(),
                                data.Efficiency(),
                                CheckBoxBatchEditAllocation.Checked(),
                                data.Allocation(),
                                CheckBoxBatchEditShiftPattern.Checked(),
                                data.ShiftPattern(),
                                CheckBoxBatchEditMaxLoadPercentage.Checked(),
                                data.MaximumLoadPercentage(),
                                CheckBoxBatchEditNrOfUnitsOpen.Checked(),
                                data.NrOfUnitsOpen(),
                                CheckBoxBatchEditMinimumLoadThreshold.Checked(),
                                data.MinimumLoadThreshold()
                              );
    }
  *]
}
