Quintiq file version 2.0
#parent: GanttChartUnitCalendar
Response OnClick (
  structured[UnitPeriod] selection
) id:Response_GanttChartUnitCalendar_MenuEditCapacityInPeriodInGanttChartUnitCalendar_OnClick
{
  #keys: '[112884.1.974878982]'
  Body:
  [*
    //Edit unit availabilities/capacities/transport capacity
    //One of these sets should be empty
    upt := selectset( selection, Elements.astype( UnitPeriodTime ), up, true );
    upq := selectset( selection, Elements.astype( UnitPeriodQuantity ), up, true );
    uptransport := selectset( selection, Elements.astype( UnitPeriodTransportBase ), up, true );
    if ( upq.Size() = 0 and uptransport.Size() = 0 )
    {
      //Edit unit availabilities of the unit period times.
      dlg := construct( DialogCreateEditUnitAvailability );
      dlg.EditUnitAvailabilityFromListUnitPeriodTime( this, upt );
    }
    else if ( upt.Size() = 0 and uptransport.Size() = 0 )
    {
      //Edit unit capacities of the unit period quantities.
      dlg := construct( DialogCreateEditUnitCapacity );
      dlg.EditUnitCapacityFromListUnitPeriodQuantity( this, upq );
    }
    else if ( upq.Size() = 0 and upt.Size() = 0 )
    {
    
      uptTime := selectset( uptransport, Elements.astype( UnitPeriodTransportTime ), up, true );
      uptQty  := selectset( uptransport, Elements.astype( UnitPeriodTransportQuantity ), up, true ); 
    
      if( uptTime.Size() > 0 )
      {
        //Edit transport availabilities of the unit period transport time
        dlg := construct( DialogCreateEditTransportAvailability );
        dlg.EditTransportAvailabilityFromListUnitPeriodTransportTime( this, uptTime );
      }
      else if( uptQty.Size() > 0 )
      {
          //Edit transport capacities of the unit period transport qty
        dlg := construct( DialogCreateEditTransportCapacity );
        dlg.EditTransportCapacityFromListUnitPeriodTransportQuantity( this, uptQty );
      }
    }
  *]
  CanBindMultiple: false
  DefinitionID => /GanttChartUnitCalendar/Responsedef_GanttChartUnitCalendar_Menu_OnClick
  Initiator: 'MenuEditCapacityInPeriodInGanttChartUnitCalendar'
  Precondition:
  [*
    return UnitPeriod::CanEditCapacities( selection, feedback );
  *]
}
