@@ -469,6 +469,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
469469 revisedValueDate : dv . target ?. revisedValueDate ? formatDate ( dv . target . revisedValueDate ) : null ,
470470 }
471471 } ) ) ;
472+ const hasDisagg = values . disaggregation && values . disaggregation . length > 0 ;
472473 const updatedIndicatorData = {
473474 id : indicator . id ,
474475 name : values . name ,
@@ -488,21 +489,21 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
488489 programId : values . programId ? values . programId : null ,
489490 ascending : values . ascending ,
490491 creationDate : values . creationDate && formatDate ( values . creationDate ) ,
491- base : checkObjectIsNull ( values . base ) ? null : {
492+ base : hasDisagg ? null : ( checkObjectIsNull ( values . base ) ? null : {
492493 originalValue : values . base . originalValue ? lodash . toNumber ( values . base . originalValue ) : null ,
493494 originalValueDate : values . base . originalValueDate ? formatDate ( values . base . originalValueDate ) : null ,
494495 revisedValue : values . base . revisedValue ? lodash . toNumber ( values . base . revisedValue ) : null ,
495496 revisedValueDate : values . base . revisedValueDate ? formatDate ( values . base . revisedValueDate ) : null ,
496- } ,
497- target : checkObjectIsNull ( values . target ) ? null : {
497+ } ) ,
498+ target : hasDisagg ? null : ( checkObjectIsNull ( values . target ) ? null : {
498499 originalValue : values . target . originalValue ? lodash . toNumber ( values . target . originalValue ) : null ,
499500 originalValueDate : values . target . originalValueDate ? formatDate ( values . target . originalValueDate ) : null ,
500501 revisedValue : values . target . revisedValue ? lodash . toNumber ( values . target . revisedValue ) : null ,
501502 revisedValueDate : values . target . revisedValueDate ? formatDate ( values . target . revisedValueDate ) : null ,
502- } ,
503+ } ) ,
503504 outcomeId : values . outcomeId ,
504505 outputId : values . outputId ,
505- disaggregationValues : formattedDisaggregationValues ,
506+ disaggregationValues : hasDisagg ? formattedDisaggregationValues : [ ] ,
506507 indicatorsCategory : indicator . indicatorsCategory || undefined ,
507508 } ;
508509
@@ -843,7 +844,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
843844 onBlur = { props . handleBlur }
844845 className = { `basic-multi-select ${ ( props . errors . disaggregation && props . touched . disaggregation ) && styles . text_is_invalid } ` }
845846 classNamePrefix = "select"
846- value = { disaggregationOptions . filter ( opt => props . values . disaggregation ?. includes ( opt . value ) ) }
847+ value = { ( props . values . disaggregation || [ ] ) . map ( id => disaggregationOptions . find ( opt => opt . value === id ) ) . filter ( Boolean ) }
847848 />
848849 </ Form . Group >
849850 </ Row >
@@ -1208,6 +1209,15 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
12081209 { /* Value Tracking */ }
12091210 < Row className = { styles . view_row } > < Col > < h5 className = { styles . sectionTitle } > { translations [ "amp.indicatormanager:value-tracking" ] } </ h5 > </ Col > </ Row >
12101211 < div className = { styles . sectionContainer } >
1212+ { props . values . disaggregation ?. length > 0 && (
1213+ < Row className = { styles . view_row } >
1214+ < Col >
1215+ < div style = { { color : '#856404' , background : '#fff3cd' , border : '1px solid #ffc107' , borderRadius : '4px' , padding : '0.5rem 1rem' , marginBottom : '0.5rem' } } >
1216+ { translations [ "amp.indicatormanager:value-tracking-disabled-disaggregation" ] || "Regular base/target values are disabled when disaggregation is active and will be cleared on save." }
1217+ </ div >
1218+ </ Col >
1219+ </ Row >
1220+ ) }
12111221 < Form . Group as = { Col } >
12121222 < Form . Label className = { styles . view_one_item } >
12131223 < h4 > { translations [ "amp.indicatormanager:base-values" ] } </ h4 >
@@ -1217,13 +1227,14 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
12171227 < Form . Group className = { styles . view_item } >
12181228 < Form . Label > { translations [ 'amp.indicatormanager:original-value' ] } </ Form . Label >
12191229 < Form . Control
1220- defaultValue = { props . values . base ?. originalValue }
1221- onChange = { props . handleChange }
1222- onBlur = { props . handleBlur }
1223- name = "base.originalValue"
1224- type = "number"
1225- className = { `${ styles . input_field } ${ ( props . errors . base ?. originalValue && props . touched . base ?. originalValue ) && styles . text_is_invalid } ` }
1226- placeholder = { translations [ "amp.indicatormanager:enter-original-value" ] } />
1230+ defaultValue = { props . values . base ?. originalValue }
1231+ onChange = { props . handleChange }
1232+ onBlur = { props . handleBlur }
1233+ name = "base.originalValue"
1234+ type = "number"
1235+ disabled = { props . values . disaggregation ?. length > 0 }
1236+ className = { `${ styles . input_field } ${ ( props . errors . base ?. originalValue && props . touched . base ?. originalValue ) && styles . text_is_invalid } ` }
1237+ placeholder = { translations [ "amp.indicatormanager:enter-original-value" ] } />
12271238
12281239 < Form . Control . Feedback type = "invalid" className = { styles . text_is_invalid } >
12291240 { props . errors . base ?. originalValue }
@@ -1245,7 +1256,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
12451256 } }
12461257 onBlur = { props . handleBlur }
12471258 name = "base.originalValueDate"
1248- disabled = { baseOriginalValueDateDisabled }
1259+ disabled = { props . values . disaggregation ?. length > 0 || baseOriginalValueDateDisabled }
12491260 className = { `${ styles . input_field } ${ ( props . errors . base ?. originalValueDate && props . touched . base ?. originalValueDate ) && styles . text_is_invalid } ` }
12501261 id = "baseOriginalValueDate"
12511262 inputRef = { baseOriginalValueDateRef }
@@ -1266,6 +1277,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
12661277 onBlur = { props . handleBlur }
12671278 name = "base.revisedValue"
12681279 type = "number"
1280+ disabled = { props . values . disaggregation ?. length > 0 }
12691281 className = { `${ styles . input_field } ${ ( props . errors . base ?. revisedValue && props . touched . base ?. revisedValue ) && styles . text_is_invalid } ` }
12701282 placeholder = { translations [ "amp.indicatormanager:enter-revised-value" ] } />
12711283
@@ -1289,6 +1301,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
12891301 } }
12901302 onBlur = { props . handleBlur }
12911303 name = "base.revisedValueDate"
1304+ disabled = { props . values . disaggregation ?. length > 0 }
12921305 className = { `${ styles . input_field } ${ ( props . errors . base ?. revisedValueDate && props . touched . base ?. revisedValueDate ) && styles . text_is_invalid } ` }
12931306 id = "baseRevisedValueDate"
12941307 inputRef = { baseRevisedValueDateRef }
@@ -1312,6 +1325,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
13121325 onBlur = { props . handleBlur }
13131326 name = "target.originalValue"
13141327 type = "number"
1328+ disabled = { props . values . disaggregation ?. length > 0 }
13151329 className = { `${ styles . input_field } ${ ( props . errors . target ?. originalValue && props . touched . target ?. originalValue ) && styles . text_is_invalid } ` }
13161330 placeholder = { translations [ "amp.indicatormanager:enter-target-value" ] } />
13171331
@@ -1332,7 +1346,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
13321346 onClear = { ( ) => {
13331347 props . setFieldValue ( "target.originalValueDate" , null ) ;
13341348 } }
1335- disabled = { targetOriginalValueDateDisabled }
1349+ disabled = { props . values . disaggregation ?. length > 0 || targetOriginalValueDateDisabled }
13361350 onBlur = { props . handleBlur }
13371351 name = "target.originalValueDate"
13381352 className = { `${ styles . input_field } ${ ( props . errors . target ?. originalValueDate && props . touched . target ?. originalValueDate ) && styles . text_is_invalid } ` }
@@ -1351,6 +1365,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
13511365 onBlur = { props . handleBlur }
13521366 name = "target.revisedValue"
13531367 type = "number"
1368+ disabled = { props . values . disaggregation ?. length > 0 }
13541369 className = { `${ styles . input_field } ${ ( props . errors . target ?. revisedValue && props . touched . target ?. revisedValue ) && styles . text_is_invalid } ` }
13551370 placeholder = { translations [ "amp.indicatormanager:enter-revised-value" ] } />
13561371
@@ -1374,6 +1389,7 @@ const EditIndicatorModal: React.FC<EditIndicatorModalProps> = (props) => {
13741389 } }
13751390 onBlur = { props . handleBlur }
13761391 name = "target.revisedValueDate"
1392+ disabled = { props . values . disaggregation ?. length > 0 }
13771393 className = { `${ styles . input_field } ${ ( props . errors . target ?. revisedValueDate && props . touched . target ?. revisedValueDate ) && styles . text_is_invalid } ` }
13781394 id = "targetRevisedValueDate"
13791395 inputRef = { targetRevisedValueDateRef }
0 commit comments