Quintiq file version 2.0
#parent: #root
Method EnableDisableComponents (
  Boolean isbatchedit
) id:Method_DialogCreateEditProduct_EnableDisableComponents
{
  #keys: '[124808.0.1285736463]'
  Body:
  [*
    // Enable/disable components
    issystem := guard( Dialog.Data().IsSystem(), false );
    
    if( issystem )
    {
      EditorID.DisableWithUserFeedback( Translations::MP_Designer_DialogCreateEditProduct_DisabledEditorID() );
    }
    
    EditorID.Enabled( not isbatchedit );
    EditorProductName.Enabled( not isbatchedit );
    CheckBoxHasParentProduct.Enabled( not isbatchedit or CheckBoxBatchEditParent.Checked() );
    SelectionUnitOfMeasurement.Enabled( not isbatchedit or CheckBoxBatchEditUnitOfMeasurement.Checked() );
    SelectionParentProduct.Enabled( not isbatchedit
                                    or ( CheckBoxBatchEditParent.Checked() and CheckBoxHasParentProduct.Checked() ) );
    
    CheckBoxIsByProduct.Enabled( not isbatchedit or CheckBoxBatchEditByProduct.Checked() );
    CheckBoxIsPlannedAfterOptimization.Enabled( CheckBoxIsExcludedFromOptimization.Checked() and ( not isbatchedit or CheckBoxBatchEditIsExcludedFromOptimization.Checked() ) );
    CheckBoxIsExcludedFromOptimization.Enabled( not CheckBoxIsPlannedAfterOptimization.Checked() and ( not isbatchedit or CheckBoxBatchEditIsExcludedFromOptimization.Checked() ) );
    
    
    EditorNotes.Enabled( not isbatchedit or this.CheckBoxBatchEditNotes().Checked() );
    
    
    CheckBoxHasShelfLife.Enabled( not isbatchedit or CheckBoxBatchEditHasShelfLife.Checked() );
    EditorShelfLife.Enabled( not isbatchedit 
                             or ( CheckBoxBatchEditHasShelfLife.Checked() and CheckBoxHasShelfLife.Checked() ) );
    
    CheckBoxHasMaturationDays.Enabled( not isbatchedit or CheckBoxBatchEditHasMaturationDays.Checked() );
    EditorMaturationDays.Enabled( not isbatchedit 
                                  or ( CheckBoxBatchEditHasMaturationDays.Checked() and CheckBoxHasMaturationDays.Checked() ) );
                                  
    CheckBoxIsExcludedFromFulfillmentKPI.Enabled( not isbatchedit or CheckBoxBatchEditIsExcludedFromFulfillmentKPI.Checked() );
    
    // Disable CheckBoxIsExcludedFromFulfillmentKPI when parent product is excluded from fulfillment KPI
    if( guard( Dialog.Data().Parent().IsDerivedExcludeFromFulfillmentKPI(), false ) )
    {
      feedback := Translations::MP_Designer_DialogProduct_DisableCheckBoxIsExcludedFromFulfillmentKPI()
      CheckBoxIsExcludedFromFulfillmentKPI.DisableWithUserFeedback( feedback ); 
    }
    
    // Disable cost-editing for
    if( isbatchedit )
    {
      TabPageCost.DisableWithUserFeedback( Translations::MP_Designer_DisableTabCostForBatchEdit() );
    }
  *]
}
