← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21558: tracker/event-capture: saving input field status => yellow = pending; green = success; red = failed

 

------------------------------------------------------------
revno: 21558
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-01 20:29:44 +0100
message:
  tracker/event-capture: saving input field status => yellow = pending; green = success; red = failed
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css


--
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-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-12-30 12:59:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2016-01-01 19:29:44 +0000
@@ -825,7 +825,7 @@
         $scope.updateSuccess = false;
         
         //get current element
-        $scope.currentElement = {id: dataElement};
+        $scope.currentElement = {id: dataElement, pending: true, updated: false, failed: false};
         
         //get new and old values
         var newValue = $scope.currentEvent[dataElement];        
@@ -833,7 +833,8 @@
         
         //check for form validity
         if( $scope.isFormInvalid() ){
-            $scope.currentElement.updated = false;            
+            $scope.currentElement.updated = false;
+            
             //reset value back to original
             $scope.currentEvent[dataElement] = oldValue;            
             $scope.dhis2Events = DHIS2EventService.refreshList($scope.dhis2Events, $scope.currentEvent);
@@ -842,6 +843,7 @@
         
         if( $scope.prStDes[dataElement].compulsory && !newValue ) {
             $scope.currentElement.updated = false;                        
+            
             //reset value back to original
             $scope.currentEvent[dataElement] = oldValue;            
             $scope.dhis2Events = DHIS2EventService.refreshList($scope.dhis2Events, $scope.currentEvent);
@@ -861,8 +863,13 @@
                 //update original value
                 $scope.currentEventOriginialValue = angular.copy($scope.currentEvent);      
                 
+                $scope.currentElement.pending = false;
                 $scope.currentElement.updated = true;
                 $scope.updateSuccess = true;
+            }, function(){
+                $scope.currentElement.pending = false;
+                $scope.currentElement.updated = false;
+                $scope.currentElement.failed = true;
             });
         }
     };
@@ -1111,13 +1118,19 @@
     
     $scope.getInputNotifcationClass = function(id, custom){
         if($scope.currentElement.id && $scope.currentElement.id === id){
+            if($scope.currentElement.pending){
+                if(custom){
+                    return 'input-pending';
+                }
+                return 'form-control input-pending';
+            }
             if($scope.currentElement.updated){
                 if(custom){
                     return 'input-success';
                 }
                 return 'form-control input-success';
-            }            
-            else{
+            }          
+            if($scope.currentElement.failed){
                 if(custom){
                     return 'input-error';
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css	2015-12-28 14:53:48 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css	2016-01-01 19:29:44 +0000
@@ -87,6 +87,10 @@
     cursor: default;
 }
 
+.input-pending {
+    background-color: #fffe8c !important;
+}
+
 .input-error {
     background-color: #ff8a8a !important;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-12-30 13:04:58 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-01-01 19:29:44 +0000
@@ -912,12 +912,11 @@
     $scope.saveDatavalueForEvent = function (prStDe, field, eventToSave) {
         //Blank out the input-saved class on the last saved due date:
         $scope.eventDateSaved = false;
-        $scope.currentElement = {};
+        $scope.currentElement = {id: prStDe.dataElement.id, pending: true, saved: false, failed: false, event: eventToSave.event};
         
         //check for input validity
         $scope.updateSuccess = false;
         if (field && field.$invalid) {
-            $scope.currentElement = {id: prStDe.dataElement.id, saved: false};
             return false;
         }
 
@@ -956,6 +955,8 @@
             return DHIS2EventFactory.updateForSingleValue(ev).then(function (response) {
 
                 $scope.currentElement.saved = true;
+                $scope.currentElement.pending = false;
+                $scope.currentElement.failed = false;
 
                 $scope.currentEventOriginal = angular.copy($scope.currentEvent);
 
@@ -1267,6 +1268,13 @@
             event = $scope.currentEvent;
         }
         if($scope.currentElement.id && $scope.currentElement.id === id && $scope.currentElement.event && $scope.currentElement.event === event.event){
+            if($scope.currentElement.pending){
+                if(custom){
+                    return 'input-pending';
+                }
+                return 'form-control input-pending';
+            }
+            
             if($scope.currentElement.saved){
                 if(custom){
                     return 'input-success';

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2015-12-29 10:18:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2016-01-01 19:29:44 +0000
@@ -239,6 +239,10 @@
     cursor: default;
 }
 
+.input-pending {
+    background-color: #fffe8c !important;
+}
+
 .input-error {
     background-color: #ff8a8a !important;
 }