sync
[web.mtrack] / MTrackWeb / templates / images / js / mtrack.project.js
index ced17b4..728552a 100644 (file)
@@ -1,22 +1,22 @@
 
 
-MTrack.milestoneView = false;
+MTrack.milestoneViewer = false;
 MTrack.milestoneValues = false;
 MTrack.milestoneShow = function(url, a)
 {
     
     
-    if (MTrack.milestoneView) {
+    if (MTrack.milestoneViewer) {
         
         if (MTrack.milestoneValues &&
-                MTrack.milestoneValues != MTrack.milestoneView.find('.milestone-edit').serialize()) {
+                MTrack.milestoneValues != MTrack.milestoneViewer.find('.milestone-edit').serialize()) {
             // skip showing new form..
             alert("save or cancel first");
             return;
         }
         
-        MTrack.milestoneView.remove();
-        MTrack.milestoneView=  false;
+        MTrack.milestoneViewer.remove();
+        MTrack.milestoneViewer=  false;
     }
     
     MTrack.milestoneValues = false;
@@ -63,12 +63,106 @@ MTrack.register('.project-new-milestone', 'click', function(event) {
 MTrack.register('.mtrack-milestone-cancel', 'click', function(event) {
     event.preventDefault();
     if (MTrack.milestoneValues &&
-            MTrack.milestoneValues != MTrack.milestoneView.find('.milestone-edit').serialize()) {
+            MTrack.milestoneValues != MTrack.milestoneViewer.find('.milestone-edit').serialize()) {
         // skip showing new form..
         alert("save or cancel first");
         return;
     }
+    var id = $('.milestone-form').attr('id').split('-').pop();
+    if ((id*1) > 0) { // edit?!?
+        MTrack.ajaxLoad( '/Project.html' , true);
+        return;
+    }
+    $('.project-new-milestone').show();
+    MTrack.milestoneViewer.remove();
+    Track.milestoneValues= false;
+    MTrack.milestoneViewer=  false;
+});
+
+
+MTrack.register('.mtrack-milestone-save', 'click', function(event) {
+    event.preventDefault();
+    MTrack.milestoneViewer = false;
+    MTrack.milestoneValues= false;
+    var id = $('.milestone-form').attr('id').split('-').pop();
+    // reload the report..
+    jQuery.ajax({
+        url:  baseURL+'/Milestone/' + id,
+        type : 'POST',
+        data: $('.milestone-form').serializeArray(),
+        success : function() {
+            if ((id*1) > 0) { // edit?!?
+                MTrack.ajaxLoad( '/Project.html' , true);
+                return;
+            }
+            MTrack.ajaxLoad( MTrack.currentURL, true);
+            
+        }
+    });
+    
+});
+
+
+MTrack.register('.mtrack-perm', 'click', function(event) {
+    //console.log($(this).attr('name'));
+    var nar = $(this).attr('name').split('_');
+    jQuery.ajax({
+        url:  baseURL+'/core_project',
+        type : 'POST',
+        data: {
+            action : 'perm',
+            gid : nar[1],
+            uid : nar[0],
+            value : this.checked ? 1 : 0
+        },
+        success : function(d) {
+            // our failure value may appear here?
+           // console.log(d);
+        }
+        // failure??
+        
+    });
+    
+     
+});
+
+MTrack.Project = {
+    rolesave : function(e)
+    {
+        
+        var nar = $(e).attr('name').split('_');
+        jQuery.ajax({
+            url:  baseURL+'/core_project',
+            type : 'POST',
+            data: {
+                action : 'role',
+                pdid : nar[1],
+                value : e.value
+            },
+            success : function(d) {
+                // our failure value may appear here?
+               // console.log(d);
+            }
+            // failure??
+            
+        });
+        
+    }
+    
+}
+    
+    
+MTrack.register('.mtrack-project-person-role', 'keyup', function(event) {
+    //console.log($(this).attr('name'));
+    clearTimeout($.data(this, 'timer'));
+    var t = this;
+    
+    var wait = setTimeout(function() {
+        MTrack.Project.rolesave(t);
+    }, 1000);
+    
+    $(this).data('timer', wait);
+});
+
+    
     
-    MTrack.milestoneView.remove();
-    MTrack.milestoneView=  false;
-});
\ No newline at end of file