34
34
NodeSelector's internal representation of form data up-to-date, we rely on
35
35
the SELECTION updates' searchLabel field to update the label.
36
36
37
+ There are two different levels of write-access:
38
+
39
+ isLocked Nodes can be selected for viewing, but editing
40
+ cannot be enabled.
41
+
42
+ isEditable The form fields are active and can be edited.
43
+
44
+
37
45
## STATES
38
46
39
47
formData Node data that is shown in the form
40
48
41
- isEditable If true, form is enabled for editing
49
+ isLocked If true (defauilt), nodes can be displayed, but
50
+ "Add New Node" and "Edit Node" buttons are hidden.
51
+ The state is unlocked when the user logs in.
52
+
53
+ isEditable If true, form fields are enabled for editing
42
54
If false, form is readonly
43
55
56
+
44
57
## TESTING
45
58
46
59
Edit Existing Node
@@ -126,6 +139,7 @@ class NodeSelector extends UNISYS.Component {
126
139
color : "#FF0000"
127
140
}
128
141
] ,
142
+ isLocked : true ,
129
143
isEditable : false ,
130
144
isValid : false
131
145
} ;
@@ -134,6 +148,7 @@ class NodeSelector extends UNISYS.Component {
134
148
this . getNewNodeID = this . getNewNodeID . bind ( this ) ;
135
149
this . handleSelection = this . handleSelection . bind ( this ) ;
136
150
this . onStateChange_SEARCH = this . onStateChange_SEARCH . bind ( this ) ;
151
+ this . onStateChange_SESSION = this . onStateChange_SESSION . bind ( this ) ;
137
152
this . loadFormFromNode = this . loadFormFromNode . bind ( this ) ;
138
153
this . validateForm = this . validateForm . bind ( this ) ;
139
154
this . onLabelChange = this . onLabelChange . bind ( this ) ;
@@ -148,9 +163,16 @@ class NodeSelector extends UNISYS.Component {
148
163
149
164
// NOTE: assign UDATA handlers AFTER functions have been bind()'ed
150
165
// otherwise they will lose context
166
+
167
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
168
+ /*/ SESSION is called by SessionSHell when the ID changes
169
+ set system-wide. data: { classId, projId, hashedId, groupId, isValid }
170
+ /*/ this . OnAppStateChange ( 'SESSION' , this . onStateChange_SESSION ) ;
171
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
151
172
this . OnAppStateChange ( 'SELECTION' , ( change ) => {
152
173
this . handleSelection ( change ) ;
153
174
} ) ;
175
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
154
176
this . OnAppStateChange ( 'SEARCH' , this . onStateChange_SEARCH ) ;
155
177
156
178
// Load Template
@@ -168,8 +190,6 @@ class NodeSelector extends UNISYS.Component {
168
190
169
191
} // constructor
170
192
171
-
172
-
173
193
/// UTILITIES /////////////////////////////////////////////////////////////////
174
194
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175
195
/*/ Clear the form with optional label
@@ -283,6 +303,17 @@ class NodeSelector extends UNISYS.Component {
283
303
284
304
} // handleSelection
285
305
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
306
+ /*/ Handle change in SESSION data
307
+ Called both by componentWillMount() and AppStateChange handler.
308
+ The 'SESSION' state change is triggered in two places in SessionShell during
309
+ its handleChange() when active typing is occuring, and also during
310
+ SessionShell.componentWillMount()
311
+ /*/ onStateChange_SESSION ( decoded ) {
312
+ let update = { isLocked : ! decoded . isValid } ;
313
+ this . setState ( update ) ;
314
+ }
315
+
316
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
286
317
/*/ Handle updated SEARCH
287
318
AutoComplete handles its internal updates, but we do need to validate the form
288
319
When AutoComplete's input field is updated, it sends a SOURCE_SEARCH to ACL
@@ -513,18 +544,13 @@ class NodeSelector extends UNISYS.Component {
513
544
514
545
515
546
/// REACT LIFECYCLE ///////////////////////////////////////////////////////////
516
- /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
517
- /*/
518
- /*/ componentWillMount ( ) {
519
- this . validateForm ( ) ;
520
- }
521
547
/*/ REACT calls this to receive the component layout and data sources
522
548
/*/ render ( ) {
523
549
return (
524
550
< div >
525
551
< FormGroup className = "text-right" style = { { paddingRight :'5px' } } >
526
552
< Button outline size = "sm"
527
- hidden = { this . state . isEditable }
553
+ hidden = { this . state . isLocked || this . state . isEditable }
528
554
onClick = { this . onNewNodeButtonClick }
529
555
> { "Add New Node" } </ Button >
530
556
</ FormGroup >
@@ -589,9 +615,9 @@ class NodeSelector extends UNISYS.Component {
589
615
</ FormGroup >
590
616
< FormGroup className = "text-right" style = { { paddingRight :'5px' } } >
591
617
< Button outline size = "sm"
592
- hidden = { this . state . isEditable || ( this . state . formData . id === '' ) }
618
+ hidden = { this . state . isLocked || this . state . isEditable || ( this . state . formData . id === '' ) }
593
619
onClick = { this . onEditButtonClick }
594
- > { " Edit Node" } </ Button >
620
+ > Edit Node</ Button >
595
621
< Button outline size = "sm"
596
622
hidden = { ! this . state . isEditable }
597
623
onClick = { this . onCancelButtonClick }
@@ -616,14 +642,22 @@ class NodeSelector extends UNISYS.Component {
616
642
) ) }
617
643
< FormGroup className = "text-right" >
618
644
< Button outline size = "sm"
619
- hidden = { this . state . formData . id === '' || this . state . isEditable }
645
+ hidden = { this . state . isLocked || this . state . formData . id === '' || this . state . isEditable }
620
646
onClick = { this . onAddNewEdgeButtonClick }
621
647
> Add New Edge</ Button >
622
648
</ FormGroup >
623
649
</ div >
624
650
</ div >
625
651
)
626
652
}
653
+
654
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
655
+ /*/
656
+ /*/ componentDidMount ( ) {
657
+ this . onStateChange_SESSION ( this . AppState ( 'SESSION' ) ) ;
658
+ this . validateForm ( ) ;
659
+ }
660
+
627
661
} // class NodeSelector
628
662
629
663
0 commit comments