Pman.Tab.MTrackTimeline.bjs
[Pman.MTrack] / Pman.Tab.MTrackTimeline.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.MTrackTimeline = new Roo.XComponent({
6     part     :  ["MTrack","Timeline"],
7     order    : '300-Pman.Tab.MTrackTimeline',
8     region   : 'center',
9     parent   : 'Pman.Tab.DocumentsTab',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function (_self)
22                 {
23                     // navigation..
24                     // a) record the fact we go here.. (for history)
25                     
26                     // when page loads, we have to go to this page..
27                     
28                     // at other times, we just check 
29                     //  a) project was the same as before... - do not change.
30                     //  b) 
31                     _this.project = _this.project || 0;
32                     
33                     
34                     if (typeof(MTrackWeb) != 'undefined' && !MTrackWeb.Layout) {
35                         return;
36                     }
37                     
38                     if (typeof(Pman.Tab.DocumentsTab) == 'undefined') {
39                         return;
40                     }
41                     /*
42                     if (!_this.iscroll) {  
43                     
44                         (function() {
45                  
46                             try {
47                                 _this.iscroll = new Roo.ux.Iscroll(_this.tpanel.el.dom);
48                             } catch(e) { 
49                                 Roo.log(e);
50                             }
51                         }).defer(100);    
52                 
53                     }
54                     _this.iscroll = true;    
55                     
56                     */
57                     var  chg_project =  (_this.project != Pman.Tab.DocumentsTab.panel.getProjectId());
58                     
59                    _this.project = Pman.Tab.DocumentsTab.panel.getProjectId();
60                     
61                    if (typeof(MTrackWeb) == 'undefined') {
62                         return;
63                     }
64                     try { 
65                          window.history.pushState( { url: '/Timeline' }, 'Timeline' , baseURL +  '/Timeline' );
66                     } catch (e) {}
67                     
68                     MTrack.currentURL = '/Timeline';
69                     if (chg_project) {
70                         (function() {
71                             _this.grid.ds.load({});
72                            //_this.tpanel.view.store.load({});
73                         }).defer(100);
74                     }
75                    
76                  
77                 }
78             },
79             background : true,
80             fitContainer : true,
81             fitToFrame : true,
82             region : 'center',
83             title : "Project Timeline",
84             layout : {
85                 xtype: 'BorderLayout',
86                 xns: Roo,
87                 items : [
88                     {
89                         xtype: 'ContentPanel',
90                         xns: Roo,
91                         listeners : {
92                             activate : function (_self)
93                             {
94                                 _this.tpanel = _self;
95                             }
96                         },
97                         autoScroll : true,
98                         background : true,
99                         fitContainer : true,
100                         fitToFrame : true,
101                         region : 'center',
102                         title : "Timeline",
103                         mload : function(url) {
104                         
105                           // can you actually link to this page..
106                           // perhaps a specific day..
107                         
108                             this._url = url;
109                            // this._project = MTrack.projectCombo.getValue();
110                            // MTrack.ajaxLoad(url, this);
111                            _this.grid.ds.load({});
112                             
113                         },
114                         items : [
115                             {
116                                 xtype: 'View',
117                                 xns: Roo,
118                                 singleSelect : true,
119                                 tpl : {
120                                     xtype: 'XTemplate',
121                                     xns: Roo,
122                                     url : rootURL + '/Pman/MTrack/templates/timeline.html'
123                                 },
124                                 store : {
125                                     xtype: 'Store',
126                                     xns: Roo.data,
127                                     listeners : {
128                                         beforeload : function (_self, o)
129                                         {
130                                             o = o || {};
131                                             o.params = o.params || {};
132                                             
133                                             var sel = _this.grid.selModel.getSelected();
134                                             o.params.from_date = sel.data.changeday.format("Y-m-d");
135                                             o.params.person_id = sel.data.person_id;
136                                            // o.params.viewtype = 'summary';    
137                                             o.params.timeline = 1;
138                                             // project?
139                                             o.params.project_id =  sel.data.project_id;
140                                         }
141                                     },
142                                     remoteSort : true,
143                                     sortInfo : { field : 'person_name', direction: 'ASC' },
144                                     proxy : {
145                                         xtype: 'HttpProxy',
146                                         xns: Roo.data,
147                                         method : 'GET',
148                                         url : baseURL + '/Roo/mtrack_change.php'
149                                     },
150                                     reader : {
151                                         xtype: 'JsonReader',
152                                         xns: Roo.data,
153                                         id : 'id',
154                                         root : 'data',
155                                         totalProperty : 'total',
156                                         fields : [
157                                             {
158                                                 'name': 'person_id',
159                                                 'type': 'int'
160                                             },
161                                             {
162                                                 'name': 'person_name',
163                                                 'type': 'string'
164                                             },
165                                             {
166                                                 'name': 'changeday',
167                                                 'type': 'date',
168                                                 'dateFormat': 'Y-m-d'
169                                             },
170                                             {
171                                                 'name': 'nchanges',
172                                                 'type': 'int'
173                                             },
174                                             'project_code',
175                                             'project_id',
176                                             
177                                         
178                                         ]
179                                     }
180                                 }
181                             }
182                         ],
183                         toolbar : {
184                             xtype: 'Toolbar',
185                             xns: Roo,
186                             items : [
187                                 {
188                                     xtype: 'Button',
189                                     xns: Roo.Toolbar,
190                                     text : "Select a date to refresh.."
191                                 }
192                             ]
193                         }
194                     },
195                     {
196                         xtype: 'NestedLayoutPanel',
197                         xns: Roo,
198                         region : 'west',
199                         layout : {
200                             xtype: 'BorderLayout',
201                             xns: Roo,
202                             items : [
203                                 {
204                                     xtype: 'GridPanel',
205                                     xns: Roo,
206                                     listeners : {
207                                         activate : function() {
208                                             _this.gridpanel = this;
209                                         
210                                         }
211                                     },
212                                     autoScroll : true,
213                                     background : false,
214                                     fitContainer : true,
215                                     fitToframe : true,
216                                     region : 'center',
217                                     tableName : 'Events',
218                                     title : "Events",
219                                     grid : {
220                                         xtype: 'Grid',
221                                         xns: Roo.grid,
222                                         listeners : {
223                                             render : function() 
224                                             {
225                                                 _this.grid = this; 
226                                                 //_this.dialog = Pman.Dialog.FILL_IN
227                                                    this.dataSource.load({});
228                                             
229                                             }
230                                         },
231                                         autoExpandColumn : 'person_id_name',
232                                         loadMask : true,
233                                         sm : {
234                                             xtype: 'RowSelectionModel',
235                                             xns: Roo.grid,
236                                             listeners : {
237                                                 afterselectionchange : function (_self)
238                                                 {
239                                                   // select the data..
240                                                   
241                                                   var r= _this.grid.sm.getSelected();
242                                                   
243                                                   
244                                                   _this.datePicker.setValue(r.data.changeday);
245                                                    _this.tpanel.view.store.load({});
246                                                    
247                                                 }
248                                             },
249                                             singleSelect : true
250                                         },
251                                         dataSource : {
252                                             xtype: 'Store',
253                                             xns: Roo.data,
254                                             listeners : {
255                                                 beforeload : function (_self, o)
256                                                 {
257                                                     o = o || {};
258                                                     o.params = o.params || {};
259                                                     
260                                                     if (!_this.datePicker || !_this.datePicker.getValue) {
261                                                         return false;
262                                                     }
263                                                     o.params.from_date = _this.datePicker.activeDate.format("Y-m-01");
264                                                     o.params.viewtype = 'summary';    
265                                                     o.params.timeline = 1;
266                                                     // project?
267                                                     o.params.project_id =  Pman.Tab.DocumentsTab ? Pman.Tab.DocumentsTab.panel.getProjectId() : 0;
268                                                 }
269                                             },
270                                             remoteSort : false,
271                                             sortInfo : { field : 'person_name', direction: 'ASC' },
272                                             proxy : {
273                                                 xtype: 'HttpProxy',
274                                                 xns: Roo.data,
275                                                 method : 'GET',
276                                                 url : baseURL + '/Roo/mtrack_change.php'
277                                             },
278                                             reader : {
279                                                 xtype: 'JsonReader',
280                                                 xns: Roo.data,
281                                                 id : 'id',
282                                                 root : 'data',
283                                                 totalProperty : 'total',
284                                                 fields : [
285                                                     {
286                                                         'name': 'person_id',
287                                                         'type': 'int'
288                                                     },
289                                                     {
290                                                         'name': 'person_name',
291                                                         'type': 'string'
292                                                     },
293                                                     {
294                                                         'name': 'changeday',
295                                                         'type': 'date',
296                                                         'dateFormat': 'Y-m-d'
297                                                     },
298                                                     {
299                                                         'name': 'nchanges',
300                                                         'type': 'int'
301                                                     },
302                                                     'project_code',
303                                                     'project_id',
304                                                     
305                                                 
306                                                 ]
307                                             }
308                                         },
309                                         colModel : [
310                                             {
311                                                 xtype: 'ColumnModel',
312                                                 xns: Roo.grid,
313                                                 dataIndex : 'changeday',
314                                                 header : 'Date',
315                                                 width : 30,
316                                                 renderer : function(v,x,r) { 
317                                                 
318                                                     return String.format('{0}',  v ? v.format('d') : '' );
319                                                  }
320                                             },
321                                             {
322                                                 xtype: 'ColumnModel',
323                                                 xns: Roo.grid,
324                                                 dataIndex : 'project_code',
325                                                 header : 'Project',
326                                                 width : 50,
327                                                 renderer : function(v,x,r) { 
328                                                     
329                                                     Roo.log(r);
330                                                     return String.format( '{0}' ,v );
331                                                  }
332                                             },
333                                             {
334                                                 xtype: 'ColumnModel',
335                                                 xns: Roo.grid,
336                                                 dataIndex : 'person_name',
337                                                 header : 'Who',
338                                                 width : 100,
339                                                 renderer : function(v,x,r) { 
340                                                     
341                                                     return String.format( '{0}' , v);
342                                                  }
343                                             },
344                                             {
345                                                 xtype: 'ColumnModel',
346                                                 xns: Roo.grid,
347                                                 align : 'right',
348                                                 dataIndex : 'nchanges',
349                                                 header : 'Changes',
350                                                 width : 30,
351                                                 renderer : function(v,x,r) { 
352                                                     return v * 1;
353                                                  }
354                                             }
355                                         ]
356                                     }
357                                 },
358                                 {
359                                     xtype: 'ContentPanel',
360                                     xns: Roo,
361                                     region : 'north',
362                                     items : [
363                                         {
364                                             xtype: 'DatePicker',
365                                             xns: Roo,
366                                             listeners : {
367                                                 render : function (_self)
368                                                 {
369                                                   _this.datePicker = _self;
370                                                 },
371                                                 select : function (_self, date)
372                                                 {
373                                                     if (!_this.tpanel) {
374                                                         return;
375                                                     }
376                                                     _this.tpanel.view.store.load({});
377                                                 },
378                                                 monthchange : function (_self, date)
379                                                 {
380                                                   if (_this.grid) {
381                                                      _this.grid.ds.load({   });
382                                                      }
383                                                 }
384                                             }
385                                         }
386                                     ]
387                                 }
388                             ],
389                             center : {
390                                 xtype: 'LayoutRegion',
391                                 xns: Roo
392                             },
393                             north : {
394                                 xtype: 'LayoutRegion',
395                                 xns: Roo,
396                                 height : 220
397                             }
398                         }
399                     }
400                 ],
401                 center : {
402                     xtype: 'LayoutRegion',
403                     xns: Roo,
404                     tabPosition : 'top'
405                 },
406                 west : {
407                     xtype: 'LayoutRegion',
408                     xns: Roo,
409                     width : 250
410                 }
411             }
412         };
413     }
414 });