@@ -24,12 +24,6 @@ import {useRef} from 'react';
24
24
import { highlightOperation } from "@app/modules/crosswalk-editor/mappings-accordion" ;
25
25
import { useTranslation } from 'next-i18next' ;
26
26
27
- interface mappingOperationValue {
28
- operationId : string ;
29
- parameterId : string ;
30
- value : string ;
31
- }
32
-
33
27
export default function NodeMappings ( props : {
34
28
nodeSelections : CrosswalkConnectionNew [ ] ;
35
29
performMappingsModalAction : any ;
@@ -125,7 +119,6 @@ export default function NodeMappings(props: {
125
119
126
120
const [ isMappingOperationValuesInit , setMappingOperationValuesInit ] = useState < boolean > ( false ) ;
127
121
const [ isErrorBarVisible , setIsErrorBarVisible ] = useState < boolean > ( true ) ;
128
- const [ mappingOperationValues , setMappingOperationValues ] = useState < mappingOperationValue [ ] | undefined > ( undefined ) ;
129
122
const [ mappingOperationSelection , setMappingOperationSelection ] = useState < string | undefined > ( undefined ) ;
130
123
const [ mappingOperationFormatted , setMappingOperationFormatted ] = useState ( [ ] as any ) ;
131
124
const [ mappingFunctions , setMappingFunctions ] = useState ( [ ] as any ) ;
@@ -435,23 +428,8 @@ export default function NodeMappings(props: {
435
428
function updateMappingOperationValue ( operationKey : string , parameter : string , newValue : string ) {
436
429
setMappingOperationSelection ( operationKey ) ;
437
430
438
- if ( mappingOperationValues ) {
439
- const newValues = mappingOperationValues . map ( operation => {
440
- if ( operation . parameterId === parameter && operation . operationId === operationKey ) {
441
- operation . value = newValue ;
442
- operation . operationId = operationKey ;
443
- }
444
- return operation ;
445
- } ) ;
446
- setMappingOperationValues ( newValues ) ;
447
- } else {
448
- const operations : mappingOperationValue [ ] = [ ] ;
449
- operations . push ( { operationId : operationKey , parameterId : parameter , value : newValue } ) ;
450
- setMappingOperationValues ( operations ) ;
451
- }
452
-
453
- let formattedParams = generateMappingFunctionDefaultParams ( operationKey ) ;
454
- formattedParams [ parameter ] = newValue ;
431
+ const originalParams = mappingOperationFormatted ?. id === operationKey ? mappingOperationFormatted . params : generateMappingFunctionDefaultParams ( operationKey ) ;
432
+ const formattedParams = { ...originalParams , [ parameter ] : newValue } ;
455
433
let processing : any = {
456
434
id : operationKey ,
457
435
params : formattedParams ,
@@ -468,17 +446,10 @@ export default function NodeMappings(props: {
468
446
}
469
447
470
448
function isMappingOperationValueValid ( parameterName : string ) {
471
-
472
- let ret = false ;
473
- if ( mappingOperationValues ) {
474
- mappingOperationValues . filter ( x => x . parameterId === parameterName ) . map ( x => {
475
- if ( x . value ) {
476
- ret = x . value . length > 0 ;
477
- }
478
- }
479
- ) ;
480
- return ret ;
449
+ if ( mappingOperationFormatted && 'params' in mappingOperationFormatted ) {
450
+ return mappingOperationFormatted . params [ parameterName ] ?. length > 0 ;
481
451
}
452
+ return false ;
482
453
}
483
454
484
455
function generateMappingOperationFields ( operationKey : string | undefined ) {
0 commit comments