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                             }
160                         ],
161                         toolbar : {
162                             xtype: 'Toolbar',
163                             xns: Roo,
164                             items : [
165                                 {
166                                     xtype: 'Button',
167                                     xns: Roo.Toolbar,
168                                     text : "Select a date to refresh.."
169                                 }
170                             ]
171                         }
172                     },
173                     {
174                         xtype: 'NestedLayoutPanel',
175                         xns: Roo,
176                         region : 'west',
177                         layout : {
178                             xtype: 'BorderLayout',
179                             xns: Roo,
180                             items : [
181                                 {
182                                     xtype: 'GridPanel',
183                                     xns: Roo,
184                                     listeners : {
185                                         activate : function() {
186                                             _this.gridpanel = this;
187                                         
188                                         }
189                                     },
190                                     autoScroll : true,
191                                     background : true,
192                                     fitContainer : true,
193                                     fitToframe : true,
194                                     region : 'center',
195                                     tableName : 'Events',
196                                     title : "Events",
197                                     grid : {
198                                         xtype: 'Grid',
199                                         xns: Roo.grid,
200                                         listeners : {
201                                             render : function() 
202                                             {
203                                                 _this.grid = this; 
204                                                 //_this.dialog = Pman.Dialog.FILL_IN
205                                                    this.dataSource.load({});
206                                             
207                                             }
208                                         },
209                                         autoExpandColumn : 'person_id_name',
210                                         loadMask : true,
211                                         sm : {
212                                             xtype: 'RowSelectionModel',
213                                             xns: Roo.grid,
214                                             listeners : {
215                                                 afterselectionchange : function (_self)
216                                                 {
217                                                   // select the data..
218                                                   
219                                                   var r= _this.grid.sm.getSelected();
220                                                   
221                                                   
222                                                   _this.datePicker.setValue(r.data.changeday);
223                                                    //   _this.tpanel.view.store.load({});
224                                                 }
225                                             },
226                                             singleSelect : true
227                                         },
228                                         dataSource : {
229                                             xtype: 'Store',
230                                             xns: Roo.data,
231                                             listeners : {
232                                                 beforeload : function (_self, o)
233                                                 {
234                                                     o = o || {};
235                                                     o.params = o.params || {};
236                                                     
237                                                     if (!_this.datePicker || !_this.datePicker.getValue) {
238                                                         return false;
239                                                     }
240                                                     o.params.from_date = _this.datePicker.activeDate.format("Y-m-01");
241                                                     o.params.viewtype = 'summary';    
242                                                     o.params.timeline = 1;
243                                                     // project?
244                                                     o.params.project =  Pman.Tab.DocumentsTab.panel.getProjectId();
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                                         colModel : [
287                                             {
288                                                 xtype: 'ColumnModel',
289                                                 xns: Roo.grid,
290                                                 dataIndex : 'changeday',
291                                                 header : 'Date',
292                                                 width : 30,
293                                                 renderer : function(v,x,r) { 
294                                                 
295                                                     return String.format('{0}',  v ? v.format('d') : '' );
296                                                  }
297                                             },
298                                             {
299                                                 xtype: 'ColumnModel',
300                                                 xns: Roo.grid,
301                                                 dataIndex : 'project_code',
302                                                 header : 'Project',
303                                                 width : 50,
304                                                 renderer : function(v,x,r) { 
305                                                     
306                                                     Roo.log(r);
307                                                     return String.format( '{0}' ,v );
308                                                  }
309                                             },
310                                             {
311                                                 xtype: 'ColumnModel',
312                                                 xns: Roo.grid,
313                                                 dataIndex : 'person_name',
314                                                 header : 'Who',
315                                                 width : 100,
316                                                 renderer : function(v,x,r) { 
317                                                     
318                                                     return String.format( '{0}' , v);
319                                                  }
320                                             },
321                                             {
322                                                 xtype: 'ColumnModel',
323                                                 xns: Roo.grid,
324                                                 align : 'right',
325                                                 dataIndex : 'nchanges',
326                                                 header : 'Changes',
327                                                 width : 30,
328                                                 renderer : function(v,x,r) { 
329                                                     return v * 1;
330                                                  }
331                                             }
332                                         ]
333                                     }
334                                 },
335                                 {
336                                     xtype: 'ContentPanel',
337                                     xns: Roo,
338                                     region : 'north',
339                                     items : [
340                                         {
341                                             xtype: 'DatePicker',
342                                             xns: Roo,
343                                             listeners : {
344                                                 render : function (_self)
345                                                 {
346                                                   _this.datePicker = _self;
347                                                 },
348                                                 select : function (_self, date)
349                                                 {
350                                                     if (_this.tpanel.view.store) {
351                                                         return;
352                                                     }
353                                                     _this.tpanel.view.store.load({});
354                                                 },
355                                                 monthchange : function (_self, date)
356                                                 {
357                                                   if (_this.grid) {
358                                                      _this.grid.ds.load({   });
359                                                      }
360                                                 }
361                                             }
362                                         }
363                                     ]
364                                 }
365                             ],
366                             center : {
367                                 xtype: 'LayoutRegion',
368                                 xns: Roo
369                             },
370                             north : {
371                                 xtype: 'LayoutRegion',
372                                 xns: Roo,
373                                 height : 220
374                             }
375                         }
376                     }
377                 ],
378                 center : {
379                     xtype: 'LayoutRegion',
380                     xns: Roo,
381                     tabPosition : 'top'
382                 },
383                 west : {
384                     xtype: 'LayoutRegion',
385                     xns: Roo,
386                     width : 250
387                 }
388             }
389         };
390     }
391 });