| Quintiq file version 2.0 | 
| #parent: #root | 
| Method UIEnableDisableComponent ( | 
|   Boolean isInit | 
| ) id:Method_DialogCreateEditUnit_UIEnableDisableComponent | 
| { | 
|   #keys: '[135040.0.219561692]' | 
|   Body: | 
|   [* | 
|     isBatchMode := DataHolderDialogDatas.Data().Size() > 1; | 
|      | 
|     batchValidityActive := not CheckBoxBatchEditValidity.Visible()  | 
|                            or CheckBoxBatchEditValidity.Checked(); | 
|      | 
|     // Enable / disable validity start | 
|     hasValidityStartScrValue  := CheckboxHasStart.Checked(); | 
|     hasValidityStartDataValue := guard( DataHolderDialogData.Data().StartDate().DateTime().IsFinite(), false ); | 
|     hasValidityStartValue     := ifexpr( isInit | 
|                                         ,hasValidityStartDataValue | 
|                                         ,hasValidityStartScrValue ); | 
|     dsStart.Enabled( hasValidityStartValue | 
|                      and batchValidityActive, "" ); | 
|      | 
|     validityStartScrValue  := dsStart.Date(); | 
|     validityStartDataValue := guard( DataHolderDialogData.Data().StartDate(), Date::MinDate() );  //todo!! setting DateTime::MinDateTime() into datetimeSelector return strange value "Jan-1-0001 00:08:39". potential RFC? | 
|     validityStartValue     := ifexpr( isInit | 
|                                      ,validityStartDataValue | 
|                                      ,validityStartScrValue ); | 
|      | 
|     if( hasValidityStartValue and not isInit ) //user action check | 
|     { | 
|       defaultStart := MacroPlan.Start().Date(); | 
|       if( not isnull( selParentUnit.Data() ) | 
|           and guard( selParentUnit.Data().StartDate().IsFinite(), false ) ) | 
|       { | 
|         defaultStart := selParentUnit.Data().StartDate(); | 
|       } | 
|      | 
|       start := ifexpr( validityStartValue.IsFinite()  //todo!! setting DateTime::MinDateTime() into datetimeSelector return strange value "Jan-1-0001 00:08:39", hence, only get Date. Potential RFC? | 
|                       ,validityStartValue | 
|                       ,defaultStart ); | 
|       dsStart.Date( start );  | 
|     } | 
|     else if( not hasValidityStartValue and not isInit ) //user action uncheck | 
|     { | 
|       dsStart.Date( Date::MinDate() );  | 
|     } | 
|      | 
|     // Enable / disable validity end | 
|     hasValidityEndScrValue  := CheckboxHasEnd.Checked(); | 
|     hasValidityEndDataValue := guard( DataHolderDialogData.Data().EndDate().DateTime().IsFinite(), false ); | 
|     hasValidityEndValue     := ifexpr( isInit | 
|                                       ,hasValidityEndDataValue | 
|                                       ,hasValidityEndScrValue ); | 
|     dsEnd.Enabled( hasValidityEndValue | 
|                    and batchValidityActive, "" ); | 
|      | 
|     validityEndScrValue  := dsEnd.Date(); | 
|     validityEndDataValue := guard( DataHolderDialogData.Data().EndDate(), Date::MaxDate() ); | 
|     validityEndValue     := ifexpr( isInit | 
|                                      ,validityEndDataValue | 
|                                      ,validityEndScrValue ); | 
|      | 
|     if( hasValidityEndValue and not isInit ) //user action check | 
|     { | 
|       defaultEnd := MacroPlan.End().Date(); | 
|      | 
|       if( not isnull( selParentUnit.Data() ) | 
|           and guard( selParentUnit.Data().EndDate().IsFinite(), false ) ) | 
|       { | 
|         defaultEnd := selParentUnit.Data().EndDate(); | 
|       }   | 
|        | 
|       end := ifexpr( validityEndValue.IsFinite() | 
|                     ,validityEndValue | 
|                     ,defaultEnd ); | 
|       dsEnd.Date( end );  | 
|     } | 
|     else if( not hasValidityEndValue and not isInit ) //user action uncheck | 
|     { | 
|       dsEnd.Date( Date::MaxDate() );  | 
|     } | 
|      | 
|     // Enable / disable UserFrozenFutureDuration | 
|     hasUserFrozenDurationScrValue  := CheckboxUserFrozenFutureDuration.Checked(); | 
|     hasUserFrozenDurationDataValue := guard( DataHolderDialogData.Data().HasUserFrozenFutureDuration(), false ); | 
|     hasUserFrozenDurationValue     := ifexpr( isInit | 
|                                              ,hasUserFrozenDurationDataValue | 
|                                              ,hasUserFrozenDurationScrValue ); | 
|      | 
|     batchMiscActive := not CheckBoxBatchEditMisc.Visible()  | 
|                        or CheckBoxBatchEditMisc.Checked(); | 
|      | 
|     DurationSelectorUserFrozenFutureDuration.Enabled( hasUserFrozenDurationValue | 
|                                                       and batchMiscActive | 
|                                                       , "" ); | 
|      | 
|     // Check Capacity type for TransportUnit, for disabling CapacitySmoothing & CapacityUsage  | 
|     capacityTypeScrValue  := RadioButtonGroupCapacityType.BoundValue() | 
|     capacityTypeDataValue := guard( DataHolderDialogData.Data().CapacityType(), GlobalParameters_MP::GetCapacityTypeInfinite() ); | 
|     capacityType          := ifexpr( isInit | 
|                                     ,capacityTypeDataValue | 
|                                     ,capacityTypeScrValue ); | 
|                                        | 
|     istransport  := capacityType    = GlobalParameters_MP::GetCapacityTypeTransportTime() | 
|                     or capacityType = GlobalParameters_MP::GetCapacityTypeTransportQuantity(); | 
|     // | 
|      | 
|     // Enable / disable capacity smoothing components  & EditFieldCapacitySmoothingLength | 
|     hasCapacitySmoothingScrValue   := CheckBoxHasCapacitySmoothing.Checked(); | 
|     hasCapacitySmoothingDataValue  := guard( DataHolderDialogData.Data().HasCapacitySmoothing(), false ); | 
|     hasCapacitySmoothingValue      := ifexpr( isInit | 
|                                              ,hasCapacitySmoothingDataValue | 
|                                              ,hasCapacitySmoothingScrValue ); | 
|      | 
|     isSmoothCapacityOverAllPeriodsScrValue  := [Boolean] RadioButtonGroupIsSmoothCapacityOverAllPeriods.BoundValue(); | 
|     isSmoothCapacityOverAllPeriodsDataValue := guard( DataHolderDialogData.Data().IsSmoothCapacityOverAllPeriods(), false ); | 
|      | 
|     isSmoothCapacityOverAllPeriodsValue     := ifexpr( isInit | 
|                                                        ,isSmoothCapacityOverAllPeriodsDataValue | 
|                                                        ,isSmoothCapacityOverAllPeriodsScrValue ); | 
|      | 
|     CheckBoxHasCapacitySmoothing.Enabled                  ( not istransport | 
|                                                             and not isBatchMode, "" ); | 
|     RadioButtonGroupUsingOutputForCapacity.Enabled        ( not istransport | 
|                                                             and not isBatchMode, "" ); | 
|      | 
|     EditFieldCapacitySmoothingPercentageDelta.Enabled     ( not istransport | 
|                                                             and not isBatchMode | 
|                                                             and hasCapacitySmoothingValue, "" ); | 
|     RadioButtonGroupIsSmoothCapacityOverAllPeriods.Enabled( not istransport | 
|                                                             and not isBatchMode | 
|                                                             and hasCapacitySmoothingValue, "" ); | 
|     CheckboxIsOverlapCapacitySmoothing.Enabled            ( not istransport | 
|                                                             and not isBatchMode | 
|                                                             and hasCapacitySmoothingValue, "" ); | 
|     EditFieldCapacitySmoothingLength.Enabled              ( not istransport | 
|                                                             and not isBatchMode | 
|                                                             and hasCapacitySmoothingValue  | 
|                                                             and not isSmoothCapacityOverAllPeriodsValue, "" ); | 
|      | 
|      | 
|     // Enable / disable lotSize maximum quantity editor | 
|     hasMaximumScrValue  := CheckboxMaximumQuantity.Checked(); | 
|     hasMaximumDataValue := guard( DataHolderDialogData.Data().HasMaximumQuantity(), false ); | 
|     hasMaximumValue     := ifexpr( isInit | 
|                                   ,hasMaximumDataValue | 
|                                   ,hasMaximumScrValue ); | 
|      | 
|      | 
|     EditFieldMaximumQuantity.Enabled( not istransport | 
|                                       and not isBatchMode | 
|                                       and hasMaximumValue ,"" ); | 
|      | 
|      | 
|     // Enable / disable LotSize tab's component (since we cannot disable tab pages) | 
|     disableLotSizeFeedback := ''; | 
|     if( istransport ) | 
|     { | 
|       disableLotSizeFeedback := ifexpr( capacityType = GlobalParameters_MP::GetCapacityTypeTransportTime()  | 
|                                        ,Translations::MP_Designer_WebDialogUnit_FeedbackDisableTransportTimeVolumeTab() | 
|                                        ,Translations::MP_Designer_WebDialogUnit_FeedbackDisableTransportQuantityVolumeTab() ); | 
|     } | 
|      | 
|     EditFieldMinimumQuantity.Enabled( not istransport | 
|                                       and not isBatchMode, disableLotSizeFeedback ); | 
|     EditFieldLotSize.Enabled        ( not istransport | 
|                                       and not isBatchMode, disableLotSizeFeedback ); | 
|     CheckboxMaximumQuantity.Enabled(  not istransport | 
|                                       and not isBatchMode, disableLotSizeFeedback ); | 
|      | 
|     // Enable / disable CheckboxUseShiftPatternOptimization | 
|     istime  :=  capacityType    = GlobalParameters_MP::GetCapacityTypeTime() | 
|                 or capacityType = GlobalParameters_MP::GetCapacityTypeTimeAggregation(); | 
|      | 
|     CheckboxUseShiftPatternOptimization.Enabled( istime, | 
|                                                  Translations::MP_Designer_WebDialogUnit_FeedbackDisableAllowShiftPatternOptimization() ); | 
|   *] | 
| } |