← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13104: disable buttons while saving ip header/comment

 

------------------------------------------------------------
revno: 13104
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-02 16:20:44 +0100
message:
  disable buttons while saving ip header/comment
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2013-12-02 14:23:07 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2013-12-02 15:20:44 +0000
@@ -128,6 +128,7 @@
   var saveButton = jQuery("<button/>")
     .text(i18n_save)
     .on('click', function( e ) {
+      disableButtons();
       var content = textArea.val().trim();
 
       if( ipCommentUid ) {
@@ -140,6 +141,8 @@
           $target.html(content);
         }).error(function() {
           setHeaderDelayMessage(i18n_could_not_save_interpretation);
+        }).always(function() {
+          enableButtons();
         });
       } else {
         $.ajax({
@@ -151,10 +154,22 @@
           $target.html(content);
         }).error(function() {
           setHeaderDelayMessage(i18n_could_not_save_interpretation);
+        }).always(function() {
+          enableButtons();
         });
       }
     });
 
+  function enableButtons() {
+    saveButton.removeAttr('disabled');
+    cancelButton.removeAttr('disabled');
+  }
+
+  function disableButtons() {
+    saveButton.attr('disabled', true);
+    cancelButton.attr('disabled', true);
+  }
+
   container.append(cancelButton);
   container.append(saveButton);