← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21552: tracker-capture: make sure empty notes are not allowed.

 

------------------------------------------------------------
revno: 21552
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-12-30 14:04:58 +0100
message:
  tracker-capture: make sure empty notes are not allowed.
modified:
  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/notes/notes-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties


--
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-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 02:55:18 +0000
+++ 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
@@ -1133,30 +1133,37 @@
     };
 
     $scope.addNote = function () {
+        
+        if(!$scope.note.value){
+            var dialogOptions = {
+                headerText: 'error',
+                bodyText: 'please_add_some_text'
+            };                
 
-        if ($scope.note.value !== "" || !angular.isUndefined($scope.note.value)) {
-            var newNote = {value: $scope.note.value};
+            DialogService.showDialog({}, dialogOptions);
+            return;
+        }
+        var newNote = {value: $scope.note.value};
             
-            if (angular.isUndefined($scope.currentEvent.notes)) {
-                $scope.currentEvent.notes = [{value: newNote.value, storedDate: today, storedBy: storedBy}];
-            }
-            else {
-                $scope.currentEvent.notes.splice(0, 0, {value: newNote.value, storedDate: today, storedBy: storedBy});
-            }
-
-            var e = {event: $scope.currentEvent.event,
-                program: $scope.currentEvent.program,
-                programStage: $scope.currentEvent.programStage,
-                orgUnit: $scope.currentEvent.orgUnit,
-                trackedEntityInstance: $scope.currentEvent.trackedEntityInstance,
-                notes: [newNote]
-            };
-
-            DHIS2EventFactory.updateForNote(e).then(function (data) {
-
-                $scope.note = {};
-            });
-        }
+        if (angular.isUndefined($scope.currentEvent.notes)) {
+            $scope.currentEvent.notes = [{value: newNote.value, storedDate: today, storedBy: storedBy}];
+        }
+        else {
+            $scope.currentEvent.notes.splice(0, 0, {value: newNote.value, storedDate: today, storedBy: storedBy});
+        }
+
+        var e = {event: $scope.currentEvent.event,
+            program: $scope.currentEvent.program,
+            programStage: $scope.currentEvent.programStage,
+            orgUnit: $scope.currentEvent.orgUnit,
+            trackedEntityInstance: $scope.currentEvent.trackedEntityInstance,
+            notes: [newNote]
+        };
+
+        DHIS2EventFactory.updateForNote(e).then(function (data) {
+
+            $scope.note = {};
+        });
     };
     
     $scope.notesModal = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js	2015-12-16 09:43:38 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js	2015-12-30 13:04:58 +0000
@@ -5,6 +5,7 @@
                 DateUtils,
                 EnrollmentService,
                 CurrentSelection,
+                DialogService,
                 SessionStorageService,
                 orderByFilter) {
     $scope.dashboardReady = false;
@@ -50,25 +51,34 @@
     });
        
     $scope.addNote = function(){
-        if ($scope.note.value !== "" || !angular.isUndefined($scope.note.value)) {
-            var newNote = {value: $scope.note.value};
-
-            if(angular.isUndefined( $scope.selectedEnrollment.notes) ){
-                $scope.selectedEnrollment.notes = [{value: newNote.value, storedDate: DateUtils.formatFromUserToApi(today), storedBy: storedBy}];
-                
-            }
-            else{
-                $scope.selectedEnrollment.notes.splice(0,0,{value: newNote.value, storedDate: DateUtils.formatFromUserToApi(today), storedBy: storedBy});
-            }
-
-            var e = angular.copy($scope.selectedEnrollment);
-
-            e.notes = [newNote];
-            EnrollmentService.updateForNote(e).then(function(){
-                $scope.note = {};
-                $scope.addNoteField = false; //note is added, hence no need to show note field.                
-            });
-        }        
+        if(!$scope.note.value){
+            var dialogOptions = {
+                headerText: 'error',
+                bodyText: 'please_add_some_text'
+            };                
+
+            DialogService.showDialog({}, dialogOptions);
+            return;
+        }
+        
+
+        var newNote = {value: $scope.note.value};
+
+        if(angular.isUndefined( $scope.selectedEnrollment.notes) ){
+            $scope.selectedEnrollment.notes = [{value: newNote.value, storedDate: DateUtils.formatFromUserToApi(today), storedBy: storedBy}];
+
+        }
+        else{
+            $scope.selectedEnrollment.notes.splice(0,0,{value: newNote.value, storedDate: DateUtils.formatFromUserToApi(today), storedBy: storedBy});
+        }
+
+        var e = angular.copy($scope.selectedEnrollment);
+
+        e.notes = [newNote];
+        EnrollmentService.updateForNote(e).then(function(){
+            $scope.note = {};
+            $scope.addNoteField = false; //note is added, hence no need to show note field.                
+        });
     };
     
     $scope.clearNote = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-12-29 10:58:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-12-30 13:04:58 +0000
@@ -139,6 +139,7 @@
 a_is_to_b=A is to B
 b_is_to_a=B is to A
 select=Select
+please_add_some_text=Please add some text
 please_select_source=Please select source
 register_new=Register new
 search_from_existing=Search from existing