← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18040: event-capture - make sure form is reset when clicking save-and-add-new

 

------------------------------------------------------------
revno: 18040
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-01-19 00:24:46 +0100
message:
  event-capture - make sure form is reset when clicking save-and-add-new
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.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-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-01-16 15:40:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-01-18 23:24:46 +0000
@@ -527,17 +527,18 @@
                 
                 $scope.eventLength++;
                 
-                //decide whether to stay in the current screen or not.
-                if(!addingAnotherEvent){
-                    $scope.eventRegistration = false;
-                    $scope.editingEventInFull = false;
-                    $scope.editingEventInGrid = false;  
-                }
-
-                //reset form                
+                $scope.eventRegistration = false;
+                $scope.editingEventInFull = false;
+                $scope.editingEventInGrid = false;  
+                    
+                //reset form              
+                $scope.currentEvent = {};
                 $scope.currentEvent = angular.copy($scope.newDhis2Event); 
+                               
                 $scope.note = {};
                 $scope.outerForm.submitted = false;
+                $scope.outerForm.$setPristine();
+                $scope.outerForm.$setValidity();
                 $scope.disableSaveAndAddNew = false;
                 
                 //this is to hide typeAheadPopUps - shouldn't be an issue in 
@@ -545,6 +546,11 @@
                 $timeout(function() {
                     angular.element('#hideTypeAheadPopUp').trigger('click');
                 }, 10);
+                
+                //decide whether to stay in the current screen or not.
+                if(addingAnotherEvent){
+                    $scope.showEventRegistration();
+                }
             }
         });
     }; 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js	2015-01-17 10:50:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js	2015-01-18 23:24:46 +0000
@@ -246,7 +246,7 @@
                                                 ' ng-model="currentEvent.' + fieldId + '"' +
                                                 ' input-field-id="' + fieldId + '"' +
                                                 ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\'"' +
                                                 ' ng-blur="saveDatavalue(prStDes.'+ fieldId + ')"' + 
                                                 ' ng-required="{{prStDes.' + fieldId + '.compulsory}}">';
                             }
@@ -258,7 +258,7 @@
                                                 ' d2-validation ' +
                                                 ' ng-model="currentEvent.' + fieldId + '" ' +
                                                 ' input-field-id="' + fieldId + '"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\' || currentEvent[uid]==\'uid\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\' || currentEvent[uid]==\'uid\'"' +
                                                 ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"' +
                                                 ' typeahead="option.name as option.name for option in optionSets.'+optionSetId+'.options | filter:$viewValue | limitTo:20"' +
                                                 ' typeahead-editable="false" ' +
@@ -275,7 +275,7 @@
                                                 ' d2-validation ' +
                                                 ' ng-model="currentEvent.' + fieldId + '" ' +
                                                 ' input-field-id="' + fieldId + '"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\' || currentEvent[uid]==\'uid\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\' || currentEvent[uid]==\'uid\'"' +
                                                 ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
                                                 ' ng-blur="saveDatavalue(prStDes.'+ fieldId + ')"' +
                                                 ' ng-required="prStDes.' + fieldId + '.compulsory"> ';                                     
@@ -288,7 +288,7 @@
                                                 ' ng-model="currentEvent.' + fieldId + '" ' +
                                                 ' input-field-id="' + fieldId + '"' +
                                                 ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\'"' +
                                                 ' ng-change="saveDatavalue(prStDes.'+ fieldId + ')"' + 
                                                 ' ng-required="{{prStDes.' + fieldId + '.compulsory}}">' + 
                                                 '<option value="">{{\'please_select\'| translate}}</option>' +
@@ -306,7 +306,7 @@
                                                 ' d2-date ' +
                                                 ' max-date="' + maxDate + '"' +
                                                 ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\'"' +
                                                 ' blur-or-change="saveDatavalue(prStDes.'+ fieldId + ')"' + 
                                                 ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"> '; 
                             }
@@ -317,7 +317,7 @@
                                                 ' ng-model="currentEvent.' + fieldId + '"' +
                                                 ' input-field-id="' + fieldId + '"' +
                                                 ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
-                                                ' ng-disabled="currentEvent.enrollmentStatus!=\'ACTIVE\'"' +
+                                                ' ng-disabled="currentEvent.enrollmentStatus===\'CANCELLED\' || currentEvent.enrollmentStatus===\'COMPLETED\'"' +
                                                 ' ng-change="saveDatavalue(prStDes.'+ fieldId + ')"' +
                                                 ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"> ';
                             }