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