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