44
44
index : 0
45
45
} ;
46
46
47
- function GanttItemViewer ( model , $container , options ) {
48
- Dashboard . CustomItemViewer . call ( this , model , $container , options ) ;
49
- this . dxGanttWidget = null ;
50
- }
47
+ class GanttItemViewer extends DevExpress . Dashboard . CustomItemViewer {
48
+ constructor ( model , $container , options ) {
49
+ super ( model , $container , options ) ;
50
+ this . dxGanttWidget = null ;
51
+ }
51
52
52
- GanttItemViewer . prototype = Object . create ( Dashboard . CustomItemViewer . prototype ) ;
53
- GanttItemViewer . prototype . constructor = GanttItemViewer ;
54
-
55
- GanttItemViewer . prototype . _getDataSource = function ( ) {
56
- var data = [ ] ;
57
- var datesValid = true ;
58
-
59
- this . iterateData ( function ( dataRow ) {
60
- data . push ( {
61
- id : dataRow . getValue ( 'ID' ) [ 0 ] ,
62
- parentId : dataRow . getValue ( 'ParentID' ) [ 0 ] ,
63
- title : dataRow . getValue ( 'Text' ) [ 0 ] ,
64
- start : dataRow . getValue ( 'StartDate' ) [ 0 ] ,
65
- end : dataRow . getValue ( 'FinishDate' ) [ 0 ] ,
66
- clientDataRow : dataRow
53
+ _getDataSource ( ) {
54
+ var data = [ ] ;
55
+ var datesValid = true ;
56
+
57
+ this . iterateData ( function ( dataRow ) {
58
+ data . push ( {
59
+ id : dataRow . getValue ( 'ID' ) [ 0 ] ,
60
+ parentId : dataRow . getValue ( 'ParentID' ) [ 0 ] ,
61
+ title : dataRow . getValue ( 'Text' ) [ 0 ] ,
62
+ start : dataRow . getValue ( 'StartDate' ) [ 0 ] ,
63
+ end : dataRow . getValue ( 'FinishDate' ) [ 0 ] ,
64
+ clientDataRow : dataRow
65
+ } ) ;
66
+
67
+ var currentItem = data [ data . length - 1 ] ;
68
+
69
+ if ( ( currentItem . start && ! ( currentItem . start instanceof Date ) ) || ( currentItem . end && ! ( currentItem . end instanceof Date ) ) )
70
+ datesValid = false ;
67
71
} ) ;
68
72
69
- var currentItem = data [ data . length - 1 ] ;
70
-
71
- if ( ( currentItem . start && ! ( currentItem . start instanceof Date ) ) || ( currentItem . end && ! ( currentItem . end instanceof Date ) ) )
72
- datesValid = false ;
73
- } ) ;
73
+ if ( ! datesValid ) {
74
+ DevExpress . ui . notify ( "Gantt: 'Start Date' or 'Finish Date' is not a Date object." , "warning" , 3000 ) ;
75
+ return [ ] ;
76
+ }
74
77
75
- if ( ! datesValid ) {
76
- DevExpress . ui . notify ( "Gantt: 'Start Date' or 'Finish Date' is not a Date object." , "warning" , 3000 ) ;
77
- return [ ] ;
78
+ return data ;
78
79
}
79
80
80
- return data ;
81
- } ;
82
-
83
- GanttItemViewer . prototype . _getDxGanttWidgetSettings = function ( ) {
84
- var _this = this ;
85
- return {
86
- rootValue : - 1 ,
87
- tasks : {
88
- dataSource : this . _getDataSource ( )
89
- } ,
90
- columns : [ {
91
- dataField : "title" ,
92
- caption : "Subject" ,
93
- width : 300 ,
94
- } , {
95
- dataField : "start" ,
96
- caption : "Start Date"
97
- } , {
98
- dataField : "end" ,
99
- caption : "End Date"
100
- } ] ,
101
- onTaskClick : function ( e ) {
102
- var tasks = e . component . option ( "tasks.dataSource" ) ;
103
- var clickedTask = tasks . filter ( item => item . id === e . key ) [ 0 ] ;
104
-
105
- _this . setMasterFilter ( clickedTask . clientDataRow ) ;
106
- } ,
107
- scaleType : "days" ,
108
- taskListWidth : 500 ,
109
- } ;
110
- } ;
81
+ _getDxGanttWidgetSettings ( ) {
82
+ var _this = this ;
83
+ return {
84
+ rootValue : - 1 ,
85
+ tasks : {
86
+ dataSource : this . _getDataSource ( )
87
+ } ,
88
+ columns : [ {
89
+ dataField : "title" ,
90
+ caption : "Subject" ,
91
+ width : 300 ,
92
+ } , {
93
+ dataField : "start" ,
94
+ caption : "Start Date"
95
+ } , {
96
+ dataField : "end" ,
97
+ caption : "End Date"
98
+ } ] ,
99
+ onTaskClick : function ( e ) {
100
+ var tasks = e . component . option ( "tasks.dataSource" ) ;
101
+ var clickedTask = tasks . filter ( item => item . id === e . key ) [ 0 ] ;
102
+
103
+ _this . setMasterFilter ( clickedTask . clientDataRow ) ;
104
+ } ,
105
+ scaleType : "days" ,
106
+ taskListWidth : 500 ,
107
+ } ;
108
+ }
111
109
112
- GanttItemViewer . prototype . setSelection = function ( values ) {
113
- Object . getPrototypeOf ( GanttItemViewer . prototype ) . setSelection . call ( this , values ) ;
110
+ setSelection ( values ) {
111
+ super . setSelection ( values ) ;
114
112
115
- var _this = this ;
116
- var tasks = _this . dxGanttWidget . option ( "tasks.dataSource" ) ;
113
+ var _this = this ;
114
+ var tasks = _this . dxGanttWidget . option ( "tasks.dataSource" ) ;
117
115
118
- tasks . forEach ( function ( item ) {
119
- if ( _this . isSelected ( item . clientDataRow ) )
120
- _this . dxGanttWidget . option ( "selectedRowKey" , item . id ) ;
121
- } ) ;
122
- } ;
116
+ tasks . forEach ( function ( item ) {
117
+ if ( _this . isSelected ( item . clientDataRow ) )
118
+ _this . dxGanttWidget . option ( "selectedRowKey" , item . id ) ;
119
+ } ) ;
120
+ }
123
121
124
- GanttItemViewer . prototype . clearSelection = function ( ) {
125
- Object . getPrototypeOf ( GanttItemViewer . prototype ) . clearSelection . call ( this ) ;
126
- this . dxGanttWidget . option ( "selectedRowKey" , null ) ;
127
- } ;
122
+ clearSelection ( ) {
123
+ super . clearSelection ( ) ;
124
+ this . dxGanttWidget . option ( "selectedRowKey" , null ) ;
125
+ }
128
126
129
- GanttItemViewer . prototype . setSize = function ( width , height ) {
130
- Object . getPrototypeOf ( GanttItemViewer . prototype ) . setSize . call ( this , width , height ) ;
131
- this . dxGanttWidget . repaint ( ) ;
132
- } ;
127
+ setSize ( width , height ) {
128
+ super . setSize ( width , height ) ;
129
+ this . dxGanttWidget . repaint ( ) ;
130
+ }
133
131
134
- GanttItemViewer . prototype . renderContent = function ( $element , changeExisting ) {
135
- if ( ! changeExisting ) {
136
- var element = $element . jquery ? $element [ 0 ] : $element ;
132
+ renderContent ( $element , changeExisting ) {
133
+ if ( ! changeExisting ) {
134
+ var element = $element . jquery ? $element [ 0 ] : $element ;
137
135
138
- while ( element . firstChild )
139
- element . removeChild ( element . firstChild ) ;
136
+ while ( element . firstChild )
137
+ element . removeChild ( element . firstChild ) ;
140
138
141
- this . dxGanttWidget = new DevExpress . ui . dxGantt ( element , this . _getDxGanttWidgetSettings ( ) ) ;
142
- } else {
143
- this . dxGanttWidget . option ( this . _getDxGanttWidgetSettings ( ) ) ;
139
+ this . dxGanttWidget = new DevExpress . ui . dxGantt ( element , this . _getDxGanttWidgetSettings ( ) ) ;
140
+ } else {
141
+ this . dxGanttWidget . option ( this . _getDxGanttWidgetSettings ( ) ) ;
142
+ }
144
143
}
145
- } ;
144
+ }
146
145
147
- function GanttItem ( dashboardControl ) {
148
- dashboardControl . registerIcon ( svgIcon ) ;
149
- this . name = GANTT_EXTENSION_NAME ;
150
- this . metaData = ganttItemMetadata ;
151
- this . createViewerItem = function ( model , $element , content ) {
146
+ class GanttItem {
147
+ constructor ( dashboardControl ) {
148
+ dashboardControl . registerIcon ( svgIcon ) ;
149
+ this . name = GANTT_EXTENSION_NAME ;
150
+ this . metaData = ganttItemMetadata ;
151
+ }
152
+ createViewerItem ( model , $element , content ) {
152
153
return new GanttItemViewer ( model , $element , content ) ;
153
154
}
154
- } ;
155
+ }
155
156
156
157
return GanttItem ;
157
158
} ) ( ) ;
0 commit comments