← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14611: event capture input validations - UI

 

------------------------------------------------------------
revno: 14611
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-04-02 15:20:51 +0200
message:
  event capture input validations - UI
modified:
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.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-event-capture/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html	2014-04-02 09:12:08 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html	2014-04-02 13:20:51 +0000
@@ -1,5 +1,6 @@
 <!DOCTYPE html>
-<html manifest="event-capture.appcache" ng-app="eventCapture">
+<!--<html manifest="event-capture.appcache" ng-app="eventCapture">-->
+<html ng-app="eventCapture">    
     <head>
         <title>Event Capture</title>
 
@@ -44,7 +45,7 @@
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
+        <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
         <script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
         
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
@@ -246,8 +247,8 @@
                                                                    ng-required={{eventGridColumn.compulsory}}
                                                                    name="foo" 
                                                                    style="width:98%;"
-                                                                   ng-class="{true: 'update-success'} [updateSuccess && currentGridColumnId == eventGridColumn.id]"
-                                                                   ng-class="{true: 'update-error'} [!updateSuccess && currentGridColumnId == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                             />                                                                   
                                                             <span ng-show="outerForm.submitted && innerFormGrid.foo.$invalid" class="red"><em title="{{'required'| translate}}" class="required">*</em></span>
                                                         </div>
@@ -261,8 +262,8 @@
                                                                        ng-required={{eventGridColumn.compulsory}}
                                                                        name="foo" 
                                                                        style="width:98%;"
-                                                                       ng-class="{true: 'update-success'} [updateSuccess && currentGridColumnId == eventGridColumn.id]"
-                                                                       ng-class="{true: 'update-error'} [!updateSuccess && currentGridColumnId == eventGridColumn.id]"
+                                                                       ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                       ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                                        />
                                                                 <span ng-show="outerForm.submitted && innerFormGrid.foo.$invalid" class="red"><em title="{{'required'| translate}}" class="required">*</em></span>
                                                             </div>
@@ -273,8 +274,8 @@
                                                                     ng-required={{eventGridColumn.compulsory}}
                                                                     name="foo" 
                                                                     style="width:98%;"
-                                                                    ng-class="{true: 'update-success'} [updateSuccess && currentGridColumnId == eventGridColumn.id]"
-                                                                    ng-class="{true: 'update-error'} [!updateSuccess && currentGridColumnId == eventGridColumn.id]"
+                                                                    ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                    ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                                     />
                                                                 <option value="">{{'please_select'| translate}}</option>                        
                                                                 <option value="0">{{'no'| translate}}</option>
@@ -291,8 +292,8 @@
                                                                    ng-required={{eventGridColumn.compulsory}}
                                                                    name="foo" 
                                                                    style="width:98%;"
-                                                                   ng-class="{true: 'update-success'} [updateSuccess && currentGridColumnId == eventGridColumn.id]"
-                                                                   ng-class="{true: 'update-error'} [!updateSuccess && currentGridColumnId == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                                    />
                                                             <span ng-show="outerForm.submitted && innerFormGrid.foo.$invalid" class="red"><em title="{{'required'| translate}}" class="required">*</em></span>
                                                         </div>
@@ -302,8 +303,8 @@
                                                                    ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
                                                                    ng-required={{eventGridColumn.compulsory}}
                                                                    name="foo" 
-                                                                   ng-class="{true: 'update-success'} [updateSuccess && currentGridColumnId == eventGridColumn.id]"
-                                                                   ng-class="{true: 'update-error'} [!updateSuccess && currentGridColumnId == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                                    />
                                                             <span ng-show="outerForm.submitted && innerFormGrid.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>
                                                         </div>
@@ -359,9 +360,11 @@
                                                                ng-required={{eventGridColumn.compulsory}}
                                                                name="foo" 
                                                                style="width:99%;" 
-                                                               ng-class="{true: 'update-success'} [updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
-                                                               ng-class="{true: 'update-error'} [!updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
+                                                               ng-class="{true: 'update-success'} [currentElement.updated === true && (currentElement.id === eventGridColumn.id)]"                                                               
+                                                               ng-class="{true: 'update-error'} [currentElement.updated === false && (currentElement.id === eventGridColumn.id)]"
                                                                />
+                                                        <span ng-show="currentElement.updated === false && (currentElement.id === eventGridColumn.id)" class="required">{{'required'| translate}}</span>
+
                                                     </div>
                                                     <div ng-switch-when="string">                                        
                                                         <div class="container-fluid">
@@ -373,9 +376,10 @@
                                                                    ng-required={{eventGridColumn.compulsory}}
                                                                    name="foo" 
                                                                    style="width:99%;"
-                                                                   ng-class="{true: 'update-success'} [updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
-                                                                   ng-class="{true: 'update-error'} [!updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
+                                                                   ng-class="{true: 'update-success'} [currentElement.updated === true && (currentElement.id === eventGridColumn.id)]"
+                                                                   ng-class="{true: 'update-error'} [currentElement.updated === false && (currentElement.id === eventGridColumn.id)]"
                                                                    />
+                                                            <span ng-show="currentElement.updated === false && (currentElement.id === eventGridColumn.id)" class="required">{{'required'| translate}}</span>
                                                         </div>
                                                     </div>
                                                     <div ng-switch-when="bool">
@@ -384,13 +388,14 @@
                                                                 ng-required={{eventGridColumn.compulsory}}
                                                                 name="foo" 
                                                                 style="width:99%;"
-                                                                ng-class="{true: 'update-success'} [updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
-                                                                ng-class="{true: 'update-error'} [!updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
+                                                                ng-class="{true: 'update-success'} [currentElement.updated === true && (currentElement.id === eventGridColumn.id)]"
+                                                                ng-class="{true: 'update-error'} [currentElement.updated === false && (currentElement.id === eventGridColumn.id)]"
                                                                 />
                                                             <option value="">{{'please_select'| translate}}</option>                        
                                                             <option value="0">{{'no'| translate}}</option>
                                                             <option value="1">{{'yes'| translate}}</option>
-                                                        </select>                                                        
+                                                        </select>
+                                                        <span ng-show="currentElement.updated === false && (currentElement.id === eventGridColumn.id)" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                     <div ng-switch-when="date">
                                                         <input type="text"                                                                
@@ -401,9 +406,10 @@
                                                                ng-required={{eventGridColumn.compulsory}}
                                                                name="foo" 
                                                                style="width:99%;"
-                                                               ng-class="{true: 'update-success'} [updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
-                                                               ng-class="{true: 'update-error'} [!updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
+                                                               
+                                                               ng-class="{true: 'update-error'} [currentElement.updated === false && (currentElement.id === eventGridColumn.id)]"
                                                                />
+                                                        <span ng-show="currentElement.updated === false && (currentElement.id === eventGridColumn.id)" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                     <div ng-switch-when="trueOnly">
                                                         <input type="checkbox"                                                                      
@@ -411,9 +417,10 @@
                                                                ng-change="updateEventDataValue(currentEvent, eventGridColumn.id)"
                                                                ng-required={{eventGridColumn.compulsory}}
                                                                name="foo" 
-                                                               ng-class="{true: 'update-success'} [updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
-                                                               ng-class="{true: 'update-error'} [!updateSuccess && (currentGridColumnId == eventGridColumn.id)]"
+                                                               ng-class="{true: 'update-success'} [currentElement.updated === true && (currentElement.id === eventGridColumn.id)]"
+                                                               ng-class="{true: 'update-error'} [currentElement.updated === false && (currentElement.id === eventGridColumn.id)]"
                                                                />
+                                                        <span ng-show="currentElement.updated === false && (currentElement.id === eventGridColumn.id)" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                 </div>
                                             </ng-form>
@@ -457,8 +464,8 @@
                                                    ng-model="currentEvent.eventDate" 
                                                    ng-required="true" 
                                                    name="eventDate" 
-                                                   ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                    style="width:99%;">
+                                            <span ng-show="outerForm.submitted && outerForm.eventDate.$invalid" class="required">{{'required'| translate}}</span>
                                         </td>
                                     </tr> 
                                     <tr ng-repeat="eventGridColumn in eventGridColumns">
@@ -473,9 +480,8 @@
                                                                ng-model="currentEvent[eventGridColumn.id]" 
                                                                ng-required={{eventGridColumn.compulsory}}
                                                                name="foo" 
-                                                               ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                                style="width:99%;"/>
-                                                        <!--<span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>-->
+                                                        <span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                     <div ng-switch-when="string">                                        
                                                         <div class="container-fluid">
@@ -485,22 +491,20 @@
                                                                    typeahead-open-on-focus
                                                                    ng-required={{eventGridColumn.compulsory}} 
                                                                    name="foo" 
-                                                                   ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                                    style="width:99%;">                                            
-                                                            <!--<span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>-->
+                                                            <span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid" class="required">{{'required'| translate}}</span>
                                                         </div>
                                                     </div>
                                                     <div ng-switch-when="bool">
                                                         <select ng-model="currentEvent[eventGridColumn.id]" 
                                                                 ng-required={{eventGridColumn.compulsory}}                                                                
                                                                 name="foo" 
-                                                                ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                                 style="width:99%;">
                                                             <option value="">{{'please_select'| translate}}</option>                        
                                                             <option value="0">{{'no'| translate}}</option>
                                                             <option value="1">{{'yes'| translate}}</option>
                                                         </select>
-                                                        <!--<span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>-->
+                                                        <span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                     <div ng-switch-when="date">
                                                         <input type="text" 
@@ -509,17 +513,15 @@
                                                                ng-model="currentEvent[eventGridColumn.id]" 
                                                                ng-required={{eventGridColumn.compulsory}}
                                                                name="foo" 
-                                                               ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                                style="width:99%;">
-                                                        <!--<span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>-->
+                                                        <span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                     <div ng-switch-when="trueOnly">
                                                         <input type="checkbox"       
                                                                ng-model="currentEvent[eventGridColumn.id]"
                                                                ng-required={{eventGridColumn.compulsory}}
-                                                               ng-class="{true: 'update-error'} [outerForm.submitted && outerForm.eventDate.$invalid]"
                                                                name="foo"/>
-                                                        <!--<span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid"><em title="{{'required'| translate}}" class="required">*</em></span>-->
+                                                        <span ng-show="outerForm.submitted && innerFormAdd.foo.$invalid" class="required">{{'required'| translate}}</span>
                                                     </div>
                                                 </div>
                                             </ng-form>

=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2014-04-02 09:11:11 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2014-04-02 13:20:51 +0000
@@ -374,8 +374,10 @@
        
     $scope.updateEventDataValue = function(currentEvent, dataElement){
 
-        //get current column
-        $scope.currentGridColumnId = dataElement;
+        $scope.updateSuccess = false;
+        
+        //get current element
+        $scope.currentElement = {id: dataElement};
         
         //get new and old values
         var newValue = currentEvent[dataElement];
@@ -384,18 +386,18 @@
         //check for form validity
         $scope.outerForm.submitted = true;        
         if( $scope.outerForm.$invalid ){
-            $scope.updateSuccess = false;
+            $scope.currentElement.updated = false;
             currentEvent[dataElement] = oldValue;
             return;
         }   
         
-        if( $scope.programStageDataElements[dataElement].compulsory && !newValue ) {
-            $scope.updateSuccess = false;
+        if( $scope.programStageDataElements[dataElement].compulsory && !newValue ) {            
             currentEvent[dataElement] = oldValue;
+            $scope.currentElement.updated = false;
             return;
         }        
                 
-        if( newValue !== oldValue ){                     
+        if( newValue != oldValue ){                     
             
             var updatedSingleValueEvent = {event: currentEvent.event, dataValues: [{value: newValue, dataElement: dataElement}]};
             var updatedFullValueEvent = reconstructEvent(currentEvent, $scope.selectedProgramStage.programStageDataElements);
@@ -412,6 +414,7 @@
                 //update original value
                 $scope.currentEventOrginialValue = angular.copy(currentEvent);      
                 
+                $scope.currentElement.updated = true;
                 $scope.updateSuccess = true;
             });    
         }