@@ -4,6 +4,7 @@ import DataTask from 'libs/components/viewport/DataTask';
4
4
import DateHelper from 'libs/helpers/DateHelper' ;
5
5
import sizeMe from 'react-sizeme' ;
6
6
import Config from 'libs/helpers/config/Config' ;
7
+ import Registry from 'libs/helpers/registry/Registry' ;
7
8
8
9
export class DataRow extends Component {
9
10
constructor ( props ) {
@@ -36,84 +37,41 @@ export class DataViewPort extends Component {
36
37
37
38
renderRows = ( ) => {
38
39
let result = [ ] ;
39
- if ( Config . data . dataViewPort . groupByName ) {
40
- const groups = { } ;
41
- for ( let i = this . props . startRow ; i < this . props . endRow + 1 ; i ++ ) {
42
- let item = this . props . data [ i ] ;
43
- if ( ! item ) break ;
44
- if ( groups [ item . name ] !== undefined ) {
45
- groups [ item . name ] . push ( item ) ;
46
- } else {
47
- groups [ item . name ] = [ item ] ;
48
- }
49
- }
50
- Object . keys ( groups ) . forEach ( ( key , i ) => {
51
- const group = groups [ key ]
52
- result . push (
53
- < DataRow key = { key } label = { key } top = { i * this . props . itemheight } left = { 20 } itemheight = { this . props . itemheight } >
54
- {
55
- group . map ( item => {
56
- let new_position = DateHelper . dateToPixel ( item . start , this . props . nowposition , this . props . dayWidth ) ;
57
- let new_width = DateHelper . dateToPixel ( item . end , this . props . nowposition , this . props . dayWidth ) - new_position ;
58
- return < DataTask
59
- key = { item . id }
60
- item = { item }
61
- label = { item . name }
62
- nowposition = { this . props . nowposition }
63
- dayWidth = { this . props . dayWidth }
64
- color = { item . color }
65
- left = { new_position }
66
- width = { new_width }
67
- height = { this . props . itemheight }
68
- onChildDrag = { this . onChildDrag }
69
- isSelected = { this . props . selectedItem == item }
70
- onSelectItem = { this . props . onSelectItem }
71
- onStartCreateLink = { this . props . onStartCreateLink }
72
- onFinishCreateLink = { this . props . onFinishCreateLink }
73
- onTaskChanging = { this . props . onTaskChanging }
74
- onUpdateTask = { this . props . onUpdateTask }
75
- >
76
- { ' ' }
77
- </ DataTask >
78
- } )
79
- }
80
- </ DataRow >
81
- ) ;
82
- } ) ;
83
- } else {
84
- for ( let i = this . props . startRow ; i < this . props . endRow + 1 ; i ++ ) {
85
- let item = this . props . data [ i ] ;
86
- if ( ! item ) break ;
87
- //FIXME PAINT IN BOUNDARIES
88
-
89
- let new_position = DateHelper . dateToPixel ( item . start , this . props . nowposition , this . props . dayWidth ) ;
90
- let new_width = DateHelper . dateToPixel ( item . end , this . props . nowposition , this . props . dayWidth ) - new_position ;
91
- result . push (
92
- < DataRow key = { i } label = { item . name } top = { i * this . props . itemheight } left = { 20 } itemheight = { this . props . itemheight } >
93
- < DataTask
94
- item = { item }
95
- label = { item . name }
96
- nowposition = { this . props . nowposition }
97
- dayWidth = { this . props . dayWidth }
98
- color = { item . color }
99
- left = { new_position }
100
- width = { new_width }
101
- height = { this . props . itemheight }
102
- onChildDrag = { this . onChildDrag }
103
- isSelected = { this . props . selectedItem == item }
104
- onSelectItem = { this . props . onSelectItem }
105
- onStartCreateLink = { this . props . onStartCreateLink }
106
- onFinishCreateLink = { this . props . onFinishCreateLink }
107
- onTaskChanging = { this . props . onTaskChanging }
108
- onUpdateTask = { this . props . onUpdateTask }
109
- >
110
- { ' ' }
111
- </ DataTask >
112
- </ DataRow >
113
- ) ;
114
- }
115
- }
40
+ const groups = Registry . groupData ( this . props . data , this . props . startRow , this . props . endRow + 1 ) ;
116
41
42
+ Object . keys ( groups ) . forEach ( ( key , i ) => {
43
+ const group = groups [ key ] ;
44
+ result . push (
45
+ < DataRow key = { key } label = { key } top = { i * this . props . itemheight } left = { 20 } itemheight = { this . props . itemheight } >
46
+ {
47
+ group . map ( item => {
48
+ let new_position = DateHelper . dateToPixel ( item . start , this . props . nowposition , this . props . dayWidth ) ;
49
+ let new_width = DateHelper . dateToPixel ( item . end , this . props . nowposition , this . props . dayWidth ) - new_position ;
50
+ return < DataTask
51
+ key = { item . id }
52
+ item = { item }
53
+ label = { item . name }
54
+ nowposition = { this . props . nowposition }
55
+ dayWidth = { this . props . dayWidth }
56
+ color = { item . color }
57
+ left = { new_position }
58
+ width = { new_width }
59
+ height = { this . props . itemheight }
60
+ onChildDrag = { this . onChildDrag }
61
+ isSelected = { this . props . selectedItem == item }
62
+ onSelectItem = { this . props . onSelectItem }
63
+ onStartCreateLink = { this . props . onStartCreateLink }
64
+ onFinishCreateLink = { this . props . onFinishCreateLink }
65
+ onTaskChanging = { this . props . onTaskChanging }
66
+ onUpdateTask = { this . props . onUpdateTask }
67
+ >
68
+ { ' ' }
69
+ </ DataTask >
70
+ } )
71
+ }
72
+ </ DataRow >
73
+ ) ;
74
+ } ) ;
117
75
return result ;
118
76
} ;
119
77
0 commit comments