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