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