4
4
5
5
EdgeTable is used to to display a table of edges for review.
6
6
7
+ It displays D3DATA.
8
+ But also read FILTEREDD3DATA to show highlight/filtered state
9
+
7
10
8
11
## TO USE
9
12
@@ -51,11 +54,13 @@ class EdgeTable extends UNISYS.Component {
51
54
this . state = {
52
55
edgePrompts : this . AppState ( 'TEMPLATE' ) . edgePrompts ,
53
56
edges : [ ] ,
57
+ filteredEdges : [ ] ,
54
58
isExpanded : true ,
55
59
sortkey : 'Relationship'
56
60
} ;
57
61
58
62
this . handleDataUpdate = this . handleDataUpdate . bind ( this ) ;
63
+ this . handleFilterDataUpdate = this . handleFilterDataUpdate . bind ( this ) ;
59
64
this . OnTemplateUpdate = this . OnTemplateUpdate . bind ( this ) ;
60
65
this . onButtonClick = this . onButtonClick . bind ( this ) ;
61
66
this . onToggleExpanded = this . onToggleExpanded . bind ( this ) ;
@@ -77,7 +82,48 @@ class EdgeTable extends UNISYS.Component {
77
82
78
83
// Handle Template updates
79
84
this . OnAppStateChange ( 'TEMPLATE' , this . OnTemplateUpdate ) ;
80
- } // constructor
85
+
86
+ // Track Filtered Data Updates too
87
+ this . OnAppStateChange ( 'FILTEREDD3DATA' , this . handleFilterDataUpdate ) ;
88
+
89
+ } // constructor
90
+
91
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
92
+ /*/
93
+ /*/ componentDidMount ( ) {
94
+ if ( DBG ) console . log ( 'EdgeTable.componentDidMount!' ) ;
95
+ // Explicitly retrieve data because we may not have gotten a D3DATA
96
+ // update while we were hidden.
97
+ // filtered data needs to be set before D3Data
98
+ const FILTEREDD3DATA = UDATA . AppState ( 'FILTEREDD3DATA' ) ;
99
+ this . setState ( { filteredEdges : FILTEREDD3DATA . edges } ,
100
+ ( ) => {
101
+ let D3DATA = this . AppState ( 'D3DATA' ) ;
102
+ this . handleDataUpdate ( D3DATA ) ;
103
+ }
104
+ )
105
+ }
106
+
107
+ componentWillUnmount ( ) {
108
+ this . AppStateChangeOff ( 'D3DATA' , this . handleDataUpdate ) ;
109
+ this . AppStateChangeOff ( 'FILTEREDD3DATA' , this . handleFilterDataUpdate ) ;
110
+ this . AppStateChangeOff ( 'TEMPLATE' , this . OnTemplateUpdate ) ;
111
+ }
112
+
113
+ displayUpdated ( nodeEdge ) {
114
+ var d = new Date ( nodeEdge . meta . revision > 0 ? nodeEdge . meta . updated : nodeEdge . meta . created ) ;
115
+
116
+ var year = "" + d . getFullYear ( ) ;
117
+ var date = ( d . getMonth ( ) + 1 ) + "/" + d . getDate ( ) + "/" + year . substr ( 2 , 4 ) ;
118
+ var time = d . toTimeString ( ) . substr ( 0 , 5 ) ;
119
+ var dateTime = date + ' at ' + time ;
120
+ var titleString = "v" + nodeEdge . meta . revision ;
121
+ if ( nodeEdge . _nlog )
122
+ titleString += " by " + nodeEdge . _nlog [ nodeEdge . _nlog . length - 1 ] ;
123
+ var tag = < span title = { titleString } > { dateTime } </ span > ;
124
+
125
+ return tag ;
126
+ }
81
127
82
128
83
129
@@ -94,11 +140,25 @@ class EdgeTable extends UNISYS.Component {
94
140
// {
95
141
96
142
if ( data && data . edges ) {
97
- const edges = this . sortTable ( this . state . sortkey , data . edges ) ;
143
+ let edges = this . sortTable ( this . state . sortkey , data . edges ) ;
144
+ const { filteredEdges } = this . state ;
145
+ // add highlight/filter status
146
+ if ( filteredEdges . length > 0 ) {
147
+ edges = edges . map ( edge => {
148
+ const filteredEdge = filteredEdges . find ( n => n . id === edge . id ) ;
149
+ if ( ! filteredEdge ) edge . isFiltered = true ;
150
+ return edge ;
151
+ } ) ;
152
+ }
98
153
this . setState ( { edges} ) ;
99
154
}
100
155
}
101
156
157
+ /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158
+ handleFilterDataUpdate ( data ) {
159
+ if ( data . edges ) this . setState ( { filteredEdges : data . edges } ) ;
160
+ }
161
+
102
162
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
103
163
OnTemplateUpdate ( data ) {
104
164
this . setState ( { edgePrompts : data . edgePrompts } ) ;
@@ -335,11 +395,11 @@ class EdgeTable extends UNISYS.Component {
335
395
336
396
337
397
let { tableHeight } = this . props ;
338
- let styles = `
339
- thead, tbody { }
398
+ let styles = `thead, tbody { font-size: 0.8em }
340
399
thead { position: relative; }
341
400
tbody { overflow: auto; }
342
- `
401
+ .btn-sm { font-size: 0.6rem; padding: 0.1rem 0.2rem }
402
+ `
343
403
return (
344
404
< div style = { { overflow :'auto' ,
345
405
position :'relative' , display : 'block' , left : '1px' , right :'10px' , maxHeight : tableHeight , backgroundColor :'#f3f3ff'
@@ -354,11 +414,11 @@ class EdgeTable extends UNISYS.Component {
354
414
>
355
415
< thead >
356
416
< tr >
357
- < th width = "5 %" hidden = { ! DBG } > < Button size = "sm"
417
+ < th width = "4 %" hidden = { ! DBG } > < Button size = "sm"
358
418
onClick = { ( ) => this . setSortKey ( "id" ) }
359
419
> ID { this . sortSymbol ( "id" ) } </ Button > </ th >
360
420
< th hidden = { ! DBG } > Size</ th >
361
- < th width = "5 %" > < div style = { { color : '#f3f3ff' } } > _Edit_</ div > </ th >
421
+ < th width = "4 %" > < div style = { { color : '#f3f3ff' } } > _Edit_</ div > </ th >
362
422
< th hidden = { ! DBG } > Src ID</ th >
363
423
< th width = "10%" > < Button size = "sm"
364
424
onClick = { ( ) => this . setSortKey ( "source" ) }
@@ -376,21 +436,25 @@ class EdgeTable extends UNISYS.Component {
376
436
< th width = "10%" hidden = { edgePrompts . citation . hidden } > < Button size = "sm"
377
437
onClick = { ( ) => this . setSortKey ( "Citations" ) }
378
438
> { edgePrompts . citation . label } { this . sortSymbol ( "Citations" ) } </ Button > </ th >
379
- < th width = "16 %" hidden = { edgePrompts . notes . hidden } > < Button size = "sm"
439
+ < th width = "20 %" hidden = { edgePrompts . notes . hidden } > < Button size = "sm"
380
440
onClick = { ( ) => this . setSortKey ( "Notes" ) }
381
441
> { edgePrompts . notes . label } { this . sortSymbol ( "Notes" ) } </ Button > </ th >
382
- < th width = "16 %" hidden = { edgePrompts . info . hidden } > < Button size = "sm"
442
+ < th width = "10 %" hidden = { edgePrompts . info . hidden } > < Button size = "sm"
383
443
onClick = { ( ) => this . setSortKey ( "Info" ) }
384
444
> { edgePrompts . info . label } { this . sortSymbol ( "Info" ) } </ Button > </ th >
385
- < th width = "16 %" hidden = { ! isLocalHost } > < Button size = "sm"
445
+ < th width = "10 %" hidden = { ! isLocalHost } > < Button size = "sm"
386
446
onClick = { ( ) => this . setSortKey ( "Updated" ) }
387
447
> Updated { this . sortSymbol ( "Updated" ) } </ Button > </ th >
388
448
389
449
</ tr >
390
450
</ thead >
391
451
< tbody style = { { maxHeight : tableHeight } } >
392
452
{ this . state . edges . map ( ( edge , i ) => (
393
- < tr key = { i } >
453
+ < tr key = { i }
454
+ style = { {
455
+ color : edge . isFiltered ? 'red' : 'black' ,
456
+ opacity : edge . filteredTransparency
457
+ } } >
394
458
< td hidden = { ! DBG } > { edge . id } </ td >
395
459
< td hidden = { ! DBG } > { edge . size } </ td >
396
460
< td > < Button size = "sm" outline
@@ -419,36 +483,6 @@ class EdgeTable extends UNISYS.Component {
419
483
</ div >
420
484
) ;
421
485
}
422
- /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
423
- /*/
424
- /*/ componentDidMount ( ) {
425
- if ( DBG ) console . log ( 'EdgeTable.componentDidMount!' ) ;
426
- // Explicitly retrieve data because we may not have gotten a D3DATA
427
- // update while we were hidden.
428
- let D3DATA = this . AppState ( 'D3DATA' ) ;
429
- this . handleDataUpdate ( D3DATA ) ;
430
- }
431
-
432
- componentWillUnmount ( ) {
433
- this . AppStateChangeOff ( 'D3DATA' , this . handleDataUpdate ) ;
434
- this . AppStateChangeOff ( 'TEMPLATE' , this . OnTemplateUpdate ) ;
435
- }
436
-
437
- displayUpdated ( nodeEdge )
438
- {
439
- var d = new Date ( nodeEdge . meta . revision > 0 ? nodeEdge . meta . updated : nodeEdge . meta . created ) ;
440
-
441
- var year = "" + d . getFullYear ( ) ;
442
- var date = ( d . getMonth ( ) + 1 ) + "/" + d . getDate ( ) + "/" + year . substr ( 2 , 4 ) ;
443
- var time = d . toTimeString ( ) . substr ( 0 , 5 ) ;
444
- var dateTime = date + ' at ' + time ;
445
- var titleString = "v" + nodeEdge . meta . revision ;
446
- if ( nodeEdge . _nlog )
447
- titleString += " by " + nodeEdge . _nlog [ nodeEdge . _nlog . length - 1 ] ;
448
- var tag = < span title = { titleString } > { dateTime } </ span > ;
449
-
450
- return tag ;
451
- }
452
486
} // class EdgeTable
453
487
454
488
0 commit comments