Quintiq file version 2.0
#parent: #root
Method UIEnableDisableComponent (
  Boolean isInit
) id:Method_DialogCreateEditProduct_UIEnableDisableComponent
{
  #keys: '[135040.0.219561692]'
  Body:
  [*
    // Enable/Disable components
    
    // Enable / disable shelf life
    batchShelfLifeActive := not CheckBoxBatchEditShelfLife.Visible() 
                            or CheckBoxBatchEditShelfLife.Checked();
    
    hasShelfLifeScrValue  := CheckBoxHasShelfLife.Checked();
    hasShelfLifeDataValue := guard( DataHolderDialogData.Data().HasShelfLife(), false );
    hasShelfLifeValue     := ifexpr( isInit
                                    ,hasShelfLifeDataValue
                                    ,hasShelfLifeScrValue );
    EditFieldShelfLife.Enabled( hasShelfLifeValue
                                and batchShelfLifeActive, "" );
    
    
    // Enable / disable maturation
    batchMaturationActive := not CheckBoxBatchEditMaturation.Visible() 
                            or CheckBoxBatchEditMaturation.Checked();
    
    hasMaturationScrValue  := CheckBoxHasMaturation.Checked();
    hasMaturationDataValue := guard( DataHolderDialogData.Data().HasMaturation(), false );
    hasMaturationValue     := ifexpr( isInit
                                    ,hasMaturationDataValue
                                    ,hasMaturationScrValue );
    EditFieldMaturation.Enabled( hasMaturationValue
                                and batchMaturationActive, "" );
    
    
    // Enable / disable Post processing
    batchExcludeOptiActive := not CheckBoxBatchEditExcludeFromOptimizer.Visible() 
                              or CheckBoxBatchEditExcludeFromOptimizer.Checked();
    
    hasExcludeScrValue  := CheckBoxExcludeFromOptimizer.Checked();
    hasExcludeDataValue := guard( DataHolderDialogData.Data().IsExcludedFromOptimization(), false );
    hasExcludeValue     := ifexpr( isInit
                                  ,hasExcludeDataValue
                                  ,hasExcludeScrValue );
    
    CheckBoxIsPlannedAfterOptimization.Enabled( hasExcludeValue
                                               and batchExcludeOptiActive, "" );
    
    // Enable / disable ExcludeFromOpti
    hasPlannedAfterScrValue   := CheckBoxIsPlannedAfterOptimization.Checked()
    hasPlannedAfterDataValue  := guard( DataHolderDialogData.Data().IsPlannedAfterOptimization(), false );
    hasPlannedAfterValue      := ifexpr( isInit
                                         ,hasPlannedAfterDataValue
                                         ,hasPlannedAfterScrValue );
    CheckBoxExcludeFromOptimizer.Enabled( not hasPlannedAfterValue
                                          and batchExcludeOptiActive, "" );
    
    
    // Enable / disable IsExcludedFromFulfillmentKPI
    if( not isnull( DataHolderDialogData.Data().Parent() ) and DataHolderDialogData.Data().Parent().IsDerivedExcludeFromFulfillmentKPI() )
    {
      CheckboxIsExcludedFromFulfillmentKPI.Enabled( not DataHolderDialogData.Data().Parent().IsDerivedExcludeFromFulfillmentKPI(),
                                                    Translations::MP_Designer_DialogProduct_DisableCheckBoxIsExcludedFromFulfillmentKPI() );
    }
  *]
}
