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                                     listeners : {
123                                         beforeload : function (_self, o)
124                                         {
125                                             o = o || {};
126                                             o.params = o.params || {};
127                                             
128                                             var sel = _this.grid.selModel.getSelected();
129                                             o.params.from_date = sel.data.changeday.format("Y-m-d");
130                                             o.params.person_id = sel.data.person_id;
131                                             o.params.viewtype = 'summary';    
132                                             o.params.timeline = 1;
133                                             // project?
134                                             o.params.project =  sel.data.project_id;
135                                         }
136                                     },
137                                     remoteSort : true,
138                                     sortInfo : { field : 'person_name', direction: 'ASC' },
139                                     proxy : {
140                                         xtype: 'HttpProxy',
141                                         xns: Roo.data,
142                                         method : 'GET',
143                                         url : baseURL + '/Roo/mtrack_change.php'
144                                     },
145                                     reader : {
146                                         xtype: 'JsonReader',
147                                         xns: Roo.data,
148                                         id : 'id',
149                                         root : 'data',
150                                         totalProperty : 'total',
151                                         fields : [
152                                             {
153                                                 'name': 'person_id',
154                                                 'type': 'int'
155                                             },
156                                             {
157                                                 'name': 'person_name',
158                                                 'type': 'string'
159                                             },
160                                             {
161                                                 'name': 'changeday',
162                                                 'type': 'date',
163                                                 'dateFormat': 'Y-m-d'
164                                             },
165                                             {
166                                                 'name': 'nchanges',
167                                                 'type': 'int'
168                                             },
169                                             'project_code',
170                                             'project_id',
171                                             
172                                         
173                                         ]
174                                     }
175                                 }
176                             }
177                         ],
178                         toolbar : {
179                             xtype: 'Toolbar',
180                             xns: Roo,
181                             items : [
182                                 {
183                                     xtype: 'Button',
184                                     xns: Roo.Toolbar,
185                                     text : "Select a date to refresh.."
186                                 }
187                             ]
188                         }
189                     },
190                     {
191                         xtype: 'NestedLayoutPanel',
192                         xns: Roo,
193                         region : 'west',
194                         layout : {
195                             xtype: 'BorderLayout',
196                             xns: Roo,
197                             items : [
198                                 {
199                                     xtype: 'GridPanel',
200                                     xns: Roo,
201                                     listeners : {
202                                         activate : function() {
203                                             _this.gridpanel = this;
204                                         
205                                         }
206                                     },
207                                     autoScroll : true,
208                                     background : true,
209                                     fitContainer : true,
210                                     fitToframe : true,
211                                     region : 'center',
212                                     tableName : 'Events',
213                                     title : "Events",
214                                     grid : {
215                                         xtype: 'Grid',
216                                         xns: Roo.grid,
217                                         listeners : {
218                                             render : function() 
219                                             {
220                                                 _this.grid = this; 
221                                                 //_this.dialog = Pman.Dialog.FILL_IN
222                                                    this.dataSource.load({});
223                                             
224                                             }
225                                         },
226                                         autoExpandColumn : 'person_id_name',
227                                         loadMask : true,
228                                         sm : {
229                                             xtype: 'RowSelectionModel',
230                                             xns: Roo.grid,
231                                             listeners : {
232                                                 afterselectionchange : function (_self)
233                                                 {
234                                                   // select the data..
235                                                   
236                                                   var r= _this.grid.sm.getSelected();
237                                                   
238                                                   
239                                                   _this.datePicker.setValue(r.data.changeday);
240                                                    _this.tpanel.view.store.load({});
241                                                    
242                                                 }
243                                             },
244                                             singleSelect : true
245                                         },
246                                         dataSource : {
247                                             xtype: 'Store',
248                                             xns: Roo.data,
249                                             listeners : {
250                                                 beforeload : function (_self, o)
251                                                 {
252                                                     o = o || {};
253                                                     o.params = o.params || {};
254                                                     
255                                                     if (!_this.datePicker || !_this.datePicker.getValue) {
256                                                         return false;
257                                                     }
258                                                     o.params.from_date = _this.datePicker.activeDate.format("Y-m-01");
259                                                     o.params.viewtype = 'summary';    
260                                                     o.params.timeline = 1;
261                                                     // project?
262                                                     o.params.project =  Pman.Tab.DocumentsTab.panel.getProjectId();
263                                                 }
264                                             },
265                                             remoteSort : true,
266                                             sortInfo : { field : 'person_name', direction: 'ASC' },
267                                             proxy : {
268                                                 xtype: 'HttpProxy',
269                                                 xns: Roo.data,
270                                                 method : 'GET',
271                                                 url : baseURL + '/Roo/mtrack_change.php'
272                                             },
273                                             reader : {
274                                                 xtype: 'JsonReader',
275                                                 xns: Roo.data,
276                                                 id : 'id',
277                                                 root : 'data',
278                                                 totalProperty : 'total',
279                                                 fields : [
280                                                     {
281                                                         'name': 'person_id',
282                                                         'type': 'int'
283                                                     },
284                                                     {
285                                                         'name': 'person_name',
286                                                         'type': 'string'
287                                                     },
288                                                     {
289                                                         'name': 'changeday',
290                                                         'type': 'date',
291                                                         'dateFormat': 'Y-m-d'
292                                                     },
293                                                     {
294                                                         'name': 'nchanges',
295                                                         'type': 'int'
296                                                     },
297                                                     'project_code',
298                                                     'project_id',
299                                                     
300                                                 
301                                                 ]
302                                             }
303                                         },
304                                         colModel : [
305                                             {
306                                                 xtype: 'ColumnModel',
307                                                 xns: Roo.grid,
308                                                 dataIndex : 'changeday',
309                                                 header : 'Date',
310                                                 width : 30,
311                                                 renderer : function(v,x,r) { 
312                                                 
313                                                     return String.format('{0}',  v ? v.format('d') : '' );
314                                                  }
315                                             },
316                                             {
317                                                 xtype: 'ColumnModel',
318                                                 xns: Roo.grid,
319                                                 dataIndex : 'project_code',
320                                                 header : 'Project',
321                                                 width : 50,
322                                                 renderer : function(v,x,r) { 
323                                                     
324                                                     Roo.log(r);
325                                                     return String.format( '{0}' ,v );
326                                                  }
327                                             },
328                                             {
329                                                 xtype: 'ColumnModel',
330                                                 xns: Roo.grid,
331                                                 dataIndex : 'person_name',
332                                                 header : 'Who',
333                                                 width : 100,
334                                                 renderer : function(v,x,r) { 
335                                                     
336                                                     return String.format( '{0}' , v);
337                                                  }
338                                             },
339                                             {
340                                                 xtype: 'ColumnModel',
341                                                 xns: Roo.grid,
342                                                 align : 'right',
343                                                 dataIndex : 'nchanges',
344                                                 header : 'Changes',
345                                                 width : 30,
346                                                 renderer : function(v,x,r) { 
347                                                     return v * 1;
348                                                  }
349                                             }
350                                         ]
351                                     }
352                                 },
353                                 {
354                                     xtype: 'ContentPanel',
355                                     xns: Roo,
356                                     region : 'north',
357                                     items : [
358                                         {
359                                             xtype: 'DatePicker',
360                                             xns: Roo,
361                                             listeners : {
362                                                 render : function (_self)
363                                                 {
364                                                   _this.datePicker = _self;
365                                                 },
366                                                 select : function (_self, date)
367                                                 {
368                                                     if (_this.tpanel.view.store) {
369                                                         return;
370                                                     }
371                                                     _this.tpanel.view.store.load({});
372                                                 },
373                                                 monthchange : function (_self, date)
374                                                 {
375                                                   if (_this.grid) {
376                                                      _this.grid.ds.load({   });
377                                                      }
378                                                 }
379                                             }
380                                         }
381                                     ]
382                                 }
383                             ],
384                             center : {
385                                 xtype: 'LayoutRegion',
386                                 xns: Roo
387                             },
388                             north : {
389                                 xtype: 'LayoutRegion',
390                                 xns: Roo,
391                                 height : 220
392                             }
393                         }
394                     }
395                 ],
396                 center : {
397                     xtype: 'LayoutRegion',
398                     xns: Roo,
399                     tabPosition : 'top'
400                 },
401                 west : {
402                     xtype: 'LayoutRegion',
403                     xns: Roo,
404                     width : 250
405                 }
406             }
407         };
408     }
409 });