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                                 
95                             }
96                         },
97                         region : 'center',
98                         title : "Code Changes",
99                         view : {
100                             xtype: 'View',
101                             xns: Roo,
102                             listeners : {
103                                 preparedata : function (_self, data, i, rec)
104                                 {
105                                     Roo.apply(data, rec.json);
106                                 }
107                             },
108                             tpl : new Roo.DomTemplate({url : rootURL +'/Pman/MTrack/domtemplates/dailychanges.html'}),
109                             store : {
110                                 xtype: 'Store',
111                                 xns: Roo.data,
112                                 listeners : {
113                                     beforeload : function (_self, o)
114                                     {
115                                         o.params = o.params || {};
116                                         o.params._daychanges = _this.dateField.getValue().format('Y-m-d') ;
117                                         var re = _this.repogrid.selModel.getSelected();
118                                         if (!re) {
119                                             return;
120                                         }
121                                         o.params.id = re.data.id;
122                                     }
123                                 },
124                                 proxy : {
125                                     xtype: 'HttpProxy',
126                                     xns: Roo.data,
127                                     method : 'GET',
128                                     url : baseURL + '/Roo/Mtrack_repos'
129                                 },
130                                 reader : {
131                                     xtype: 'JsonReader',
132                                     xns: Roo.data,
133                                     fields : [
134                                         {
135                                             'name': 'id',
136                                             'type': 'int'
137                                         },
138                                         'name'
139                                     ],
140                                     id : 'id',
141                                     root : 'data'
142                                 }
143                             }
144                         }
145                     },
146                     {
147                         xtype: 'ContentPanel',
148                         xns: Roo,
149                         listeners : {
150                             activate : function (_self)
151                             {
152                                 _this.tpanel = _self;
153                             }
154                         },
155                         autoScroll : true,
156                         background : true,
157                         fitContainer : true,
158                         fitToFrame : true,
159                         region : 'center',
160                         title : "Timeline",
161                         mload : function(url) {
162                         
163                           // can you actually link to this page..
164                           // perhaps a specific day..
165                         
166                             this._url = url;
167                            // this._project = MTrack.projectCombo.getValue();
168                            // MTrack.ajaxLoad(url, this);
169                            _this.grid.ds.load({});
170                             
171                         },
172                         items : [
173                             {
174                                 xtype: 'View',
175                                 xns: Roo,
176                                 listeners : {
177                                     beforeselect : function (_self, node, selections)
178                                     {
179                                        //Roo.log(node)
180                                        //Roo.log(this.indexOf(node));
181                                        var rec =  this.store.getAt(this.indexOf(node));
182                                        //Roo.log(data);
183                                        
184                                        new Pman.Request({
185                                              url : baseURL + '/Roo/mtrack_change',
186                                              method :'GET',
187                                              params : {
188                                                 _id : rec.data.id,
189                                                 _withdiff : 1
190                                             },
191                                             success : function (res) {
192                                             
193                                                //.. this.tpl.
194                                                //Roo.log( _this.tpanel.view.chgtmp.apply(res));
195                                                 
196                                             
197                                             }
198                                         });
199                                        
200                                        
201                                        
202                                        
203                                     },
204                                     beforeclick : function (_self, index, node, e)
205                                     {
206                                         Roo.log(node);
207                                         Roo.log(e);
208                                     }
209                                 },
210                                 multiSelect : true,
211                                 selectedClass : 'change-log-item-expanded',
212                                 singleSelect : false,
213                                 toggleSelect : true,
214                                 tpl : {
215                                     xtype: 'XTemplate',
216                                     xns: Roo,
217                                     url : rootURL + '/Pman/MTrack/templates/timeline.html'
218                                 },
219                                 store : {
220                                     xtype: 'Store',
221                                     xns: Roo.data,
222                                     listeners : {
223                                         beforeload : function (_self, o)
224                                         {
225                                             o = o || {};
226                                             o.params = o.params || {};
227                                             
228                                             var sel = _this.grid.selModel.getSelected();
229                                             if (!sel) {
230                                                 return false;
231                                             }
232                                             
233                                             
234                                             o.params.from_date =_this.datePicker.activeDate.format("Y-m-d");
235                                             o.params.person_id = sel.data.person_id;
236                                            // o.params.viewtype = 'summary';    
237                                             o.params.timeline = 1;
238                                             // project?
239                                             o.params.project_id =  sel.data.project_id;
240                                             o.params.limit = 9999;
241                                         }
242                                     },
243                                     remoteSort : true,
244                                     sortInfo : { field : 'person_name', direction: 'ASC' },
245                                     proxy : {
246                                         xtype: 'HttpProxy',
247                                         xns: Roo.data,
248                                         method : 'GET',
249                                         url : baseURL + '/Roo/mtrack_change.php'
250                                     },
251                                     reader : {
252                                         xtype: 'JsonReader',
253                                         xns: Roo.data,
254                                         id : 'id',
255                                         root : 'data',
256                                         totalProperty : 'total',
257                                         fields : [
258                                             {
259                                                 'name': 'person_id',
260                                                 'type': 'int'
261                                             },
262                                             {
263                                                 'name': 'person_name',
264                                                 'type': 'string'
265                                             },
266                                             {
267                                                 'name': 'changeday',
268                                                 'type': 'date',
269                                                 'dateFormat': 'Y-m-d'
270                                             },
271                                             {
272                                                 'name': 'nchanges',
273                                                 'type': 'int'
274                                             },
275                                             'project_code',
276                                             'project_id',
277                                             
278                                         
279                                         ]
280                                     }
281                                 },
282                                 chgtpl : {
283                                     xtype: 'XTemplate',
284                                     xns: Roo,
285                                     url : rootURL + '/Pman/MTrack/templates/timeline-changelog.html'
286                                 }
287                             }
288                         ],
289                         toolbar : {
290                             xtype: 'Toolbar',
291                             xns: Roo,
292                             items : [
293                                 {
294                                     xtype: 'Button',
295                                     xns: Roo.Toolbar,
296                                     text : "Select a date to refresh.."
297                                 }
298                             ]
299                         }
300                     },
301                     {
302                         xtype: 'NestedLayoutPanel',
303                         xns: Roo,
304                         region : 'west',
305                         layout : {
306                             xtype: 'BorderLayout',
307                             xns: Roo,
308                             items : [
309                                 {
310                                     xtype: 'GridPanel',
311                                     xns: Roo,
312                                     listeners : {
313                                         activate : function() {
314                                             _this.gridpanel = this;
315                                         
316                                         }
317                                     },
318                                     autoScroll : true,
319                                     background : false,
320                                     fitContainer : true,
321                                     fitToframe : true,
322                                     region : 'center',
323                                     tableName : 'Events',
324                                     title : "Events",
325                                     grid : {
326                                         xtype: 'Grid',
327                                         xns: Roo.grid,
328                                         listeners : {
329                                             render : function() 
330                                             {
331                                                 _this.grid = this; 
332                                                 //_this.dialog = Pman.Dialog.FILL_IN
333                                                    this.dataSource.load({});
334                                             
335                                             }
336                                         },
337                                         autoExpandColumn : 'person_id_name',
338                                         loadMask : true,
339                                         sm : {
340                                             xtype: 'RowSelectionModel',
341                                             xns: Roo.grid,
342                                             listeners : {
343                                                 afterselectionchange : function (_self)
344                                                 {
345                                                   // select the data..
346                                                   
347                                                   var r= _this.grid.sm.getSelected();
348                                                   
349                                                   
350                                                   _this.datePicker.setValue(r.data.changeday);
351                                                    _this.tpanel.view.store.load({});
352                                                    
353                                                 }
354                                             },
355                                             singleSelect : true
356                                         },
357                                         dataSource : {
358                                             xtype: 'Store',
359                                             xns: Roo.data,
360                                             listeners : {
361                                                 beforeload : function (_self, o)
362                                                 {
363                                                     o = o || {};
364                                                     o.params = o.params || {};
365                                                     
366                                                     if (!_this.datePicker || !_this.datePicker.getValue) {
367                                                         return false;
368                                                     }
369                                                     o.params.on_date = _this.datePicker.activeDate.format("Y-m-d");
370                                                     o.params.viewtype = 'summary';    
371                                                     o.params.timeline = 1;
372                                                     // project?
373                                                     o.params.project_id =  Pman.Tab.DocumentsTab ? 
374                                                                 Pman.Tab.DocumentsTab.panel.getProjectId() : 0;
375                                                 }
376                                             },
377                                             remoteSort : true,
378                                             sortInfo : { field : 'person_name', direction: 'ASC' },
379                                             proxy : {
380                                                 xtype: 'HttpProxy',
381                                                 xns: Roo.data,
382                                                 method : 'GET',
383                                                 url : baseURL + '/Roo/mtrack_change.php'
384                                             },
385                                             reader : {
386                                                 xtype: 'JsonReader',
387                                                 xns: Roo.data,
388                                                 id : 'id',
389                                                 root : 'data',
390                                                 totalProperty : 'total',
391                                                 fields : [
392                                                     {
393                                                         'name': 'person_id',
394                                                         'type': 'int'
395                                                     },
396                                                     {
397                                                         'name': 'person_name',
398                                                         'type': 'string'
399                                                     },
400                                                     {
401                                                         'name': 'changeday',
402                                                         'type': 'date',
403                                                         'dateFormat': 'Y-m-d'
404                                                     },
405                                                     {
406                                                         'name': 'nchanges',
407                                                         'type': 'int'
408                                                     },
409                                                     'project_code',
410                                                     'project_id',
411                                                     
412                                                 
413                                                 ]
414                                             }
415                                         },
416                                         colModel : [
417                                             {
418                                                 xtype: 'ColumnModel',
419                                                 xns: Roo.grid,
420                                                 dataIndex : 'changeday',
421                                                 header : 'Date',
422                                                 width : 30,
423                                                 renderer : function(v,x,r) { 
424                                                 
425                                                     return String.format('{0}',  v ? v.format('d') : '' );
426                                                  }
427                                             },
428                                             {
429                                                 xtype: 'ColumnModel',
430                                                 xns: Roo.grid,
431                                                 dataIndex : 'project_code',
432                                                 header : 'Project',
433                                                 width : 50,
434                                                 renderer : function(v,x,r) { 
435                                                     
436                                                     Roo.log(r);
437                                                     return String.format( '{0}' ,v );
438                                                  }
439                                             },
440                                             {
441                                                 xtype: 'ColumnModel',
442                                                 xns: Roo.grid,
443                                                 dataIndex : 'person_name',
444                                                 header : 'Who',
445                                                 width : 100,
446                                                 renderer : function(v,x,r) { 
447                                                     
448                                                     return String.format( '{0}' , v);
449                                                  }
450                                             },
451                                             {
452                                                 xtype: 'ColumnModel',
453                                                 xns: Roo.grid,
454                                                 align : 'right',
455                                                 dataIndex : 'nchanges',
456                                                 header : 'Changes',
457                                                 width : 30,
458                                                 renderer : function(v,x,r) { 
459                                                     return v * 1;
460                                                  }
461                                             }
462                                         ]
463                                     }
464                                 },
465                                 {
466                                     xtype: 'ContentPanel',
467                                     xns: Roo,
468                                     region : 'north',
469                                     items : [
470                                         {
471                                             xtype: 'DatePicker',
472                                             xns: Roo,
473                                             listeners : {
474                                                 render : function (_self)
475                                                 {
476                                                   _this.datePicker = _self;
477                                                 },
478                                                 select : function (_self, date)
479                                                 {
480                                                     if (! _this.grid) {
481                                                         return;
482                                                     }
483                                                     _this.grid.ds.load({});
484                                                 },
485                                                 monthchange : function (_self, date)
486                                                 {
487                                                    
488                                                 }
489                                             }
490                                         }
491                                     ]
492                                 }
493                             ],
494                             center : {
495                                 xtype: 'LayoutRegion',
496                                 xns: Roo
497                             },
498                             north : {
499                                 xtype: 'LayoutRegion',
500                                 xns: Roo,
501                                 height : 220
502                             }
503                         }
504                     }
505                 ],
506                 center : {
507                     xtype: 'LayoutRegion',
508                     xns: Roo,
509                     tabPosition : 'top'
510                 },
511                 west : {
512                     xtype: 'LayoutRegion',
513                     xns: Roo,
514                     width : 250
515                 }
516             }
517         };
518     }
519 });