Quintiq file version 2.0
#parent: #root
Method EditOperation (
  internal[GUIComponent] parent,
  structured[Operation] selection
) id:Method_DialogCreateEditOperation_EditOperation
{
  #keys: '[109478.0.549376948]'
  Body:
  [*
    // Edit operation
    isbatchedit := selection.Size() > 1;
    
    data := shadow( selection.Element( 0 ) );
    
    Dialog.SetFilterForEdit( selection.Element( 0 ) );
    Dialog.Data( data );
    
    //moved here, dialog.data is referenced in this method
    Dialog.ShowHideComponentForBatchEdit( isbatchedit );
    Dialog.SetTooltips();
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      /* TWO Transaction is expected in editing single operation
         1. Update cost, we need to call Commit to commit the shadow costs
         2. Update operation, we need to call Update to updated the TypeIndex
      */
    
      if( not isbatchedit )
      {
        selection.Element( 0 ).UpdateTypeIndex( EditorID.Text() );      // Read-only, apply changes to shadow is not taking place for read-only attribute when editing.
        data.Commit();
      }
      else
      {
        Operation::Update( selection,
                           data.Unit(),
                           EditorID.Text(),
                           data.Name(),
                           CheckBoxBatchEditPreprocessingTime.Checked(),
                           data.UserLeadTime(),             
                           CheckBoxBatchEditStandardDeviation.Checked(),
                           data.StandardDeviationLeadTimeOperation(),
                           CheckBoxBatchEditThroughput.Checked(),
                           data.Throughput(),
                           CheckBoxBatchEditHasUserLotSize.Checked(),
                           data.HasUserLotSize(),
                           data.UserMinimumQuantity(),
                           data.HasUserMaximumQuantity(),
                           data.UserMaximumQuantity(),
                           data.UserLotSize(),
                           CheckBoxBatchEditCO2Emission.Checked(),
                           data.CO2Emission()
                         );
      }
    }
  *]
}
