Uncommited changes synced
[Pman.MTrack] / Pman.MTrack.js
1 /**
2  * Helper methods..
3  *
4  */
5
6 Pman.MTrack = {
7     loaded : false,
8     
9     loadAudit : function (id, el)
10     {
11         new Pman.Request({
12             url : baseURL + '/Roo/mtrack_change',
13             method : 'GET',
14             params : { 
15                 onid : id,
16                 ontable : 'mtrack_ticket',
17                 sort : 'changedate',
18                 dir: 'ASC',
19                 limit : 9999
20             } ,
21             success : function(res) {
22                // Roo.log(res.data);
23                 // render it into a template..
24                 var out = '';
25                 Roo.each(res.data, function(cg) {
26                     
27                     if (cg.rev.length) {
28                         out+= Pman.MTrack.template.change_commit(cg);
29                         return;
30                     }
31                     if (!cg.reason.length && !cg.audit.length) {
32                         return;
33                     }
34                     
35                     if ( !cg.reason.length || cg.reason == 'Changed' || cg.reason == 'Created' || cg.reason.match(/Hours worked:/)) {
36                         out+= Pman.MTrack.template.change_simple(cg);
37                         return;
38                     }
39                     out+= Pman.MTrack.template.change_comment(cg);
40                 })
41                 
42                 el.dom.innerHTML = '<ul>' + out + '</ul>';
43                  
44                 el.select('.change-log-item').on('click', Pman.MTrack.auditToggle);
45             }
46         });
47         
48     },
49     auditToggle : function(e,y)
50     {
51        // Roo.log(this);
52         var id = this.id.split('-').pop();
53         Roo.get('change-expand-' + id).setVisibilityMode(Roo.Element.DISPLAY);
54         Roo.get('change-expand-' + id).toggle(true);
55         Roo.get('change-expander-' + id).toggleClass('change-log-item-expanded')
56         
57         
58     },
59     
60     pushState: function(cfg)
61     {
62         if (!this.loaded) {
63             return;
64         }
65         try { 
66             window.history.pushState( { url: cfg.url }, cfg.title, cfg.href);
67             Roo.log("MtrackWeb.pushState: history push state");
68         } catch (e) {
69             Roo.log(e);
70             
71         }
72             
73         
74     }
75     
76     
77     
78 }