Quintiq file version 2.0
#parent: #root
Method UIShowHideComponentForBatchEdit (
  Boolean isInit,
  Boolean isBatchEdit
) id:Method_DialogCreateEditUnit_UIShowHideComponentForBatchEdit
{
  #keys: '[135040.0.219771730]'
  Body:
  [*
    // Handles the toggling of the batch related component
    data := DataHolderDialogData.Data();
    if(  isInit )
    {
      //for initialize, control batch checkboxes visibility
      CheckBoxBatchEditValidity.Visible( isBatchEdit );
      CheckBoxBatchEditMisc.Visible( isBatchEdit );
      CheckBoxBatchEditNote.Visible( isBatchEdit );
      CheckBoxBatchEditUseShiftPatternOptimization.Visible( isBatchEdit );
    
      //disable all other component  
      if( isBatchEdit )
      {
        disableText := Translations::MP_Unit_DialogCreateEdit_DisableForBatchEdit();
        disableFlag := false;
        
        selParentUnit.Enabled( disableFlag, disableText );
        EditFieldID.Enabled( disableFlag, disableText );
        EditFieldName.Enabled( disableFlag, disableText );
        DropDownListUOM.Enabled( disableFlag, disableText );
        DropDownListCurrency.Enabled( disableFlag, disableText );
        RadioButtonGroupCapacityType.Enabled( disableFlag, disableText );
        
        EditFieldMinimumQuantity.Enabled( disableFlag, disableText );
        CheckboxMaximumQuantity.Enabled( disableFlag, disableText );
        EditFieldMaximumQuantity.Enabled( disableFlag, disableText );
        EditFieldLotSize.Enabled( disableFlag, disableText );
     
        RadioButtonGroupUsingOutputForCapacity.Enabled( disableFlag, disableText );
        CheckboxIsPlannedInfinite.Enabled( disableFlag, disableText );
        CheckBoxHasCapacitySmoothing.Enabled( disableFlag, disableText );
        EditFieldCapacitySmoothingPercentageDelta.Enabled( disableFlag, disableText );
        RadioButtonGroupIsSmoothCapacityOverAllPeriods.Enabled( disableFlag, disableText );
        EditFieldCapacitySmoothingLength.Enabled( disableFlag, disableText );
        CheckboxIsOverlapCapacitySmoothing.Enabled( disableFlag, disableText );
      }
    }
    
    //batch valididity
    batchValidActive:= ifexpr( isInit
                              ,not isBatchEdit //when isBatchEdit,default=disable all
                              ,CheckBoxBatchEditValidity.Checked() 
                              );
    
    CheckboxHasEnd.Enabled( batchValidActive, "" );
    CheckboxHasStart.Enabled( batchValidActive, "" );
    dsStart.Enabled( batchValidActive and guard( data.StartDate().IsFinite(), false ), "" );
    dsEnd.Enabled( batchValidActive and guard( data.EndDate().IsFinite(), false ), "" );
    
    //batch Misc
    batchMiscActive:= ifexpr( isInit
                              ,not isBatchEdit //when isBatchEdit,default=disable all
                              ,CheckBoxBatchEditMisc.Checked() 
                            ); 
    DurationSelectorCampaignTypeDuration.Enabled( batchMiscActive, "" );
    CheckboxUserFrozenFutureDuration.Enabled( batchMiscActive, "" );
    DurationSelectorUserFrozenFutureDuration.Enabled( batchMiscActive and guard( data.HasUserFrozenFutureDuration(), false ), "" );
    CheckboxSupplySpecification.Enabled( batchMiscActive, "" );
    CheckboxIsSupplier.Enabled( batchMiscActive, "" );
    
    
    //batch Note
    batchNoteActive:= ifexpr( isInit
                              ,not isBatchEdit //when sBatchEdit,default=disable all
                              ,CheckBoxBatchEditNote.Checked() 
                            ); 
    EditFieldNotes.Enabled( batchNoteActive, "" );
    
    //batch UseShiftOptimization
    batchuseshiftoptactive := ifexpr( isInit
                                      ,not isBatchEdit //when isBatchEdit,default=disable all
                                      ,CheckBoxBatchEditUseShiftPatternOptimization.Checked()
                                      );
    selectionistime :=  ifexpr( isBatchEdit, 
                                forall( DataHolderDialogDatas.Data(), Elements, unit,
                                        unit.HasCapacityTypeTime() or unit.HasCapacityTypeTimeAggregation() ),
                                guard( data.HasCapacityTypeTime() or data.HasCapacityTypeTimeAggregation(), false ) 
                                );
    
    disableText := ifexpr( not selectionistime, Translations::MP_Designer_WebDialogUnit_FeedbackDisableAllowShiftPatternOptimization(), "" );
    CheckBoxBatchEditUseShiftPatternOptimization.Enabled( selectionistime, disableText );
    CheckboxUseShiftPatternOptimization.Enabled( batchuseshiftoptactive and selectionistime, disableText );
  *]
}
