@@ -232,7 +232,8 @@ class EdgeEditor extends UNISYS.Component {
232
232
sourceIsEditable :false , // Source ndoe field is only editable when source is not parent
233
233
hasValidSource : false , // Used by SwapSourceAndTarget and the Change Source button
234
234
targetIsEditable :false , // Target ndoe field is only editable when target is not parent
235
- hasValidTarget : false // Used by SwapSourceAndTarget and the Change Target button
235
+ hasValidTarget : false , // Used by SwapSourceAndTarget and the Change Target button
236
+ placeholder : undefined
236
237
} ;
237
238
238
239
/// Initialize UNISYS DATA LINK for REACT
@@ -653,22 +654,26 @@ class EdgeEditor extends UNISYS.Component {
653
654
/*/ onChangeSource ( ) {
654
655
this . setState ( {
655
656
sourceIsEditable : true ,
656
- hasValidSource : false
657
+ hasValidSource : false ,
658
+ placeholder : this . state . sourceNode . label
657
659
} ) ;
658
660
this . AppCall ( 'AUTOCOMPLETE_SELECT' , { id :'edge' + this . props . edgeID + 'source' } ) ;
659
661
// Whenever we set the autocomplete to source, we have to update the label
660
- this . AppCall ( 'SOURCE_SEARCH' , { searchString : this . state . sourceNode . label } ) ;
662
+ // Clear the AutoComplete field so that onBlur does not select the same node
663
+ this . AppCall ( 'SOURCE_SEARCH' , { searchString : '' } ) ;
661
664
}
662
665
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
663
666
/*/
664
667
/*/ onChangeTarget ( ) {
665
668
this . setState ( {
666
669
targetIsEditable : true ,
667
- hasValidTarget : false
670
+ hasValidTarget : false ,
671
+ placeholder : this . state . targetNode . label
668
672
} ) ;
669
673
this . AppCall ( 'AUTOCOMPLETE_SELECT' , { id :'edge' + this . props . edgeID + 'target' } ) ;
670
674
// Whenever we set the autocomplete to target, we have to update the label
671
- this . AppCall ( 'SOURCE_SEARCH' , { searchString : this . state . targetNode . label } ) ;
675
+ // Clear the AutoComplete field so that onBlur does not select the same node
676
+ this . AppCall ( 'SOURCE_SEARCH' , { searchString : '' } ) ;
672
677
}
673
678
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
674
679
/*/
@@ -753,7 +758,10 @@ class EdgeEditor extends UNISYS.Component {
753
758
/*/ render ( ) {
754
759
const { edgeID, parentNodeLabel } = this . props ;
755
760
const { formData, sourceNode, targetNode, edgePrompts } = this . state ;
756
- const me = < span style = { { color :"rgba(0,0,0,0.2)" , fontStyle :"italic" } } > this node</ span > ;
761
+ const me = < span style = { { color : "rgba(0,0,0,0.2)" , fontStyle : "italic" } } > this node</ span > ;
762
+ // special override to allow editing an edge that has the same parent node for both source and target
763
+ let sameSourceAndTarget = ( sourceNode . label === this . props . parentNodeLabel ) &&
764
+ ( targetNode . label === this . props . parentNodeLabel ) ;
757
765
return (
758
766
< div >
759
767
@@ -782,6 +790,7 @@ class EdgeEditor extends UNISYS.Component {
782
790
disabledValue = { sourceNode . label }
783
791
inactiveMode = { parentNodeLabel === sourceNode . label ? 'static' : 'disabled' }
784
792
shouldIgnoreSelection = { ! this . state . sourceIsEditable }
793
+ placeholder = { this . state . placeholder }
785
794
/>
786
795
< Button outline size = "sm" className = "float-right"
787
796
hidden = { ! ( this . state . isEditable &&
@@ -816,13 +825,17 @@ class EdgeEditor extends UNISYS.Component {
816
825
< AutoComplete
817
826
identifier = { 'edge' + edgeID + 'target' }
818
827
disabledValue = { targetNode . label }
819
- inactiveMode = { parentNodeLabel === targetNode . label ? 'static' : 'disabled' }
828
+ inactiveMode = { ( parentNodeLabel === targetNode . label && ! sameSourceAndTarget ) ? 'static' : 'disabled' }
820
829
shouldIgnoreSelection = { ! this . state . targetIsEditable }
830
+ placeholder = { this . state . placeholder }
821
831
/>
822
832
< Button outline size = "sm" className = "float-right"
823
833
hidden = { ! ( this . state . isEditable &&
824
834
this . state . hasValidTarget &&
825
- ( targetNode . label !== this . props . parentNodeLabel ) ) }
835
+ ( ( targetNode . label !== this . props . parentNodeLabel ) ||
836
+ sameSourceAndTarget )
837
+ )
838
+ }
826
839
onClick = { this . onChangeTarget }
827
840
title = "Select a different target node"
828
841
> Change Target</ Button >
0 commit comments