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