@@ -8,27 +8,37 @@ import {parseTarget, getFeedback, formatPosForTextField} from './TargetPanelWork
8
8
import TargetFeedback from './TargetFeedback.jsx' ;
9
9
import { InputFieldView } from './InputFieldView.jsx' ;
10
10
import { fieldGroupConnector } from './FieldGroupConnector.jsx' ;
11
+ import FieldGroupUtils , { getFieldGroupState } from '../fieldGroup/FieldGroupUtils.js' ;
11
12
import { dispatchActiveTarget , getActiveTarget } from '../core/AppDataCntlr.js' ;
12
13
import { isValidPoint , parseWorldPt } from '../visualize/Point.js' ;
13
14
14
15
15
16
16
- function TargetPanelView ( { showHelp, feedback, valid, message, onChange, value, labelWidth} ) {
17
- return (
18
- < div >
19
- < InputFieldView
20
- valid = { valid }
21
- visible = { true }
22
- message = { message }
23
- onChange = { onChange }
24
- label = 'Name or Position:'
25
- value = { value }
26
- tooltip = 'Enter a target'
27
- labelWidth = { labelWidth }
28
- />
29
- < TargetFeedback showHelp = { showHelp } feedback = { feedback } />
30
- </ div >
31
- ) ;
17
+ class TargetPanelView extends Component {
18
+
19
+ componentWillUnmount ( ) {
20
+ const { onUnmountCB, fieldKey, groupKey} = this . props ;
21
+ if ( onUnmountCB ) onUnmountCB ( fieldKey , groupKey ) ;
22
+ }
23
+
24
+ render ( ) {
25
+ const { showHelp, feedback, valid, message, onChange, value, labelWidth} = this . props ;
26
+ return (
27
+ < div >
28
+ < InputFieldView
29
+ valid = { valid }
30
+ visible = { true }
31
+ message = { message }
32
+ onChange = { onChange }
33
+ label = 'Name or Position:'
34
+ value = { value }
35
+ tooltip = 'Enter a target'
36
+ labelWidth = { labelWidth }
37
+ />
38
+ < TargetFeedback showHelp = { showHelp } feedback = { feedback } />
39
+ </ div >
40
+ ) ;
41
+ }
32
42
}
33
43
34
44
@@ -39,10 +49,21 @@ TargetPanelView.propTypes = {
39
49
message : PropTypes . string . isRequired ,
40
50
onChange : PropTypes . func . isRequired ,
41
51
value : PropTypes . string . isRequired ,
42
- labelWidth : PropTypes . number
52
+ labelWidth : PropTypes . number ,
53
+ onUnmountCB : PropTypes . func ,
43
54
} ;
44
55
45
56
57
+ function didUnmount ( fieldKey , groupKey ) {
58
+ // console.log(`did unmount: ${fieldKey}, ${groupKey}`);
59
+ // console.log(`value: ${FieldGroupUtils.getFldValue(FieldGroupUtils.getGroupFields(groupKey),fieldKey)}`);
60
+
61
+ const wp = parseWorldPt ( FieldGroupUtils . getFldValue ( FieldGroupUtils . getGroupFields ( groupKey ) , fieldKey ) ) ;
62
+
63
+ if ( isValidPoint ( wp ) ) {
64
+ if ( wp ) dispatchActiveTarget ( wp ) ;
65
+ }
66
+ }
46
67
47
68
48
69
@@ -54,7 +75,7 @@ function getProps(params, fireValueChange) {
54
75
const wpStr = params . value ;
55
76
const wp = parseWorldPt ( wpStr ) ;
56
77
57
- if ( isValidPoint ( wp ) ) {
78
+ if ( isValidPoint ( wp ) && ! value ) {
58
79
feedback = getFeedback ( wp ) ;
59
80
value = wp . objName || formatPosForTextField ( wp ) ;
60
81
showHelp = false ;
@@ -68,7 +89,8 @@ function getProps(params, fireValueChange) {
68
89
tooltip : 'Enter a target' ,
69
90
value,
70
91
feedback,
71
- showHelp
92
+ showHelp,
93
+ onUnmountCB : didUnmount
72
94
} ) ;
73
95
}
74
96
@@ -103,7 +125,6 @@ function handleOnChange(ev, params, fireValueChange) {
103
125
function makePayloadAndUpdateActive ( displayValue , parseResults , resolvePromise ) {
104
126
const { wpt} = parseResults ;
105
127
const wpStr = parseResults && wpt ? wpt . toString ( ) : null ;
106
- if ( wpt ) dispatchActiveTarget ( wpt ) ;
107
128
108
129
return {
109
130
message : 'Could not resolve object: Enter valid object' ,
@@ -128,7 +149,7 @@ function replaceValue(v,props) {
128
149
const t = getActiveTarget ( ) ;
129
150
var retVal = v ;
130
151
if ( t && t . worldPt ) {
131
- console . log ( `value: ${ v } , but I could use: ${ t . worldPt } ` ) ;
152
+ // console.log(`value: ${v}, but I could use: ${t.worldPt}`);
132
153
if ( get ( t , 'worldPt' ) ) retVal = t . worldPt . toString ( ) ;
133
154
}
134
155
return retVal ;
0 commit comments