← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22194: tracker-capture: it is not possible to send sms to TEI if phone number exists.

 

------------------------------------------------------------
revno: 22194
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-03-08 16:39:09 +0100
message:
  tracker-capture: it is not possible to send sms to TEI if phone number exists.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-notes.html
  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.html
  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_ar.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_in_ID.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/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-tracker-capture/components/dataentry/dataentry-notes.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-notes.html	2016-02-04 10:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-notes.html	2016-03-08 15:39:09 +0000
@@ -1,7 +1,7 @@
 <div ng-show="currentEvent" class='remove-default-padding overflow-ellipsis'>
 <div class='row'><hr></div>
 <div class="add-default-padding">
-    <textarea class="form-control" rows="3" ng-model="note.value" placeholder="{{'add_new_note_here'| translate}}"></textarea> 
+    <textarea class="form-control" rows="3" ng-model="note.value" placeholder="{{'your_note_here'| translate}}"></textarea> 
     <div class="vertical-spacing hideInPrint">
         <button type="button" 
                 class="btn btn-primary"

=== 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	2016-03-08 13:58:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js	2016-03-08 15:39:09 +0000
@@ -4,6 +4,7 @@
         function($scope,
                 DateUtils,
                 EnrollmentService,
+                MessagingService,
                 CurrentSelection,
                 DialogService,
                 SessionStorageService,
@@ -14,7 +15,9 @@
 
     var today = DateUtils.getToday();
     
+    //$scope.smsForm = {};
     $scope.note = {};
+    $scope.message = {};
     $scope.showMessagingDiv = false;
     $scope.showNotesDiv = true;
     
@@ -42,8 +45,9 @@
             //that can be used for communication
             var continueLoop = true;
             for(var i=0; i<$scope.selectedTei.attributes.length && continueLoop; i++){
-                if( $scope.selectedTei.attributes[i].valueType === 'PHONE_NUMBER' || $scope.selectedTei.attributes[i].valueType === 'EMAIL' ){
+                if( $scope.selectedTei.attributes[i].valueType === 'PHONE_NUMBER' /*|| $scope.selectedTei.attributes[i].valueType === 'EMAIL'*/ ){
                     $scope.messagingPossible = true;
+                    $scope.message.phoneNumber = $scope.selectedTei.attributes[i].value;
                     continueLoop = false;
                 }
             }
@@ -78,13 +82,35 @@
         }
         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(){
+            $scope.clear();
+        });
+    };
+    
+    $scope.sendSms = function(){
+        //check for form validity
+        $scope.smsForm.submitted = true;        
+        if( $scope.smsForm.$invalid ){
+            return false;
+        } 
+        
+        //form is valid...        
+        var smsMessage = {message: $scope.message.value, recipients: [$scope.message.phoneNumber]};        
+        MessagingService.sendSmsMessage(smsMessage).then(function(response){
+            var dialogOptions = {
+                headerText: 'sms_send_status',
+                bodyText: response.message
+            };                
+
+            DialogService.showDialog({}, dialogOptions);
+            $scope.clear();
+        });
+        
+    };
+    
+    $scope.clear = function(){
         $scope.note = {};
+        $scope.smsForm.submitted = false;
+        $scope.message.value = null;
     };
     
     $scope.showNotes = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html	2016-03-08 13:58:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html	2016-03-08 15:39:09 +0000
@@ -24,12 +24,13 @@
             <img id="ouwt_loader" src="../images/ajax-loader-bar.gif" alt="{{'loading'| translate}}"/>
         </div>
         
+        <!-- notes section begins -->
         <div ng-if="dashboardReady">
             <div ng-show="showNotesDiv">
                 <div ng-show="!selectedEnrollment" class="alert alert-danger">{{'not_yet_enrolled_note'| translate}}</div>
                 <div ng-show='selectedEnrollment' class='remove-default-padding overflow-ellipsis'>                
                     <div class="add-default-padding">
-                        <textarea class="form-control" rows="3" ng-model="note.value" placeholder="{{'add_new_note_here'| translate}}"></textarea> 
+                        <textarea class="form-control" rows="3" ng-model="note.value" placeholder="{{'your_note_here'| translate}}"></textarea> 
                         <div class="vertical-spacing">
                             <button type="button" 
                                     class="btn btn-primary"
@@ -38,7 +39,7 @@
                             </button>        
                             <button type="button" 
                                     class="btn btn-default small-horizonal-spacing" 
-                                    ng-click="clearNote()">
+                                    ng-click="clear()">
                                 {{'clear'| translate}}
                             </button>
                         </div>
@@ -64,10 +65,44 @@
                     </table>
                 </div>
                 <div ng-show="selectedEnrollment && !selectedEnrollment.notes" class="alert alert-warning">{{'no_notes_exist'| translate}}</div> 
-            </div>
-            <div ng-show="showMessagingDiv">
-                <div class="alert alert-warning">{{'under_construction'| translate}}</div> 
-            </div>
-        </div>        
+            </div>            
+        </div>
+        <!-- notes section ends -->
+        
+        <!-- sms section begins -->
+        <form name="smsForm" novalidate>
+            <div ng-if="dashboardReady">
+                <div ng-show="showMessagingDiv">
+                    <input type="text" 
+                           name="phoneNumber"
+                           class="form-control" 
+                           ng-required="true"     
+                           ng-model="message.phoneNumber"/>
+                    <span ng-show="smsForm.submitted && smsForm.phoneNumber.$invalid" class="error">{{'required'| translate}}</span>
+                    <textarea name="message"
+                              class="form-control" 
+                              rows="3" 
+                              maxlength="160"
+                              ng-model="message.value" 
+                              ng-required="true"     
+                              placeholder="{{'your_sms_message_here'| translate}}"></textarea>
+                    <span ng-show="smsForm.submitted && smsForm.message.$invalid" class="error">{{'required'| translate}}</span>
+                    <div class="vertical-spacing">
+                        <button type="button" 
+                                class="btn btn-primary"
+                                ng-click="sendSms()">
+                            {{'send'| translate}}
+                        </button>        
+                        <button type="button" 
+                                class="btn btn-default small-horizonal-spacing" 
+                                ng-click="clear()">
+                            {{'clear'| translate}}
+                        </button>
+                    </div>
+                </div>
+            </div>
+        </form>
+        <!-- sms section ends -->
+        
     </div>
 </div>

=== 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	2016-03-08 13:58:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2016-03-08 15:39:09 +0000
@@ -92,7 +92,9 @@
 add=Add
 add_note=Add note
 search_note=Search notes
-add_new_note_here=Add new note here
+your_note_here=Your note here
+your_sms_message_here=Your SMS message here
+sms_send_status=SMS sending status
 add_new_event=Add new event
 skip=Skip
 unskip=Schedule back

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties	2016-01-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties	2016-03-08 15:39:09 +0000
@@ -67,7 +67,7 @@
 add=\u0623\u0636\u0641
 add_note=\u0623\u0636\u0641 \u0645\u0644\u0627\u062d\u0638\u0629
 search_note=\u0627\u0628\u062d\u062b \u0639\u0646 \u0645\u0644\u0627\u062d\u0638\u0627\u062a
-add_new_note_here=\u0627\u0636\u0641 \u0645\u0644\u0627\u062d\u0638\u0629 \u062c\u062f\u064a\u062f\u0629 \u0647\u0646\u0627
+your_note_here=\u0627\u0636\u0641 \u0645\u0644\u0627\u062d\u0638\u0629 \u062c\u062f\u064a\u062f\u0629 \u0647\u0646\u0627
 skipped=\u0645\u062a\u062e\u0637\u0649
 skip=\u062a\u062e\u0637\u0649
 unskip=\u062c\u062f\u0648\u0644\u0629 \u0633\u0627\u0628\u0642\u0629

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_in_ID.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_in_ID.properties	2016-02-22 09:05:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_in_ID.properties	2016-03-08 15:39:09 +0000
@@ -298,6 +298,6 @@
 add=Tambah
 add_note=Tambah catatan
 search_note=Cari catatan
-add_new_note_here=Tambah catatan baru disini
+your_note_here=Tambah catatan baru disini
 unskip=Jadwal ulang
 complete=Lengkap

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-02-19 09:24:20 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-03-08 15:39:09 +0000
@@ -1962,3 +1962,14 @@
         this.eventCreationActions = { add: 'ADD',  schedule: 'SCHEDULE', referral: 'REFERRAL'};
 })
 
+.service('MessagingService', function($http){
+    return {
+        sendSmsMessage: function(message){    
+            var promise = $http.post('../api/sms/outbound', message).then(function(response){
+                return response.data;           
+            });
+            return promise;            
+        }
+    };
+});
+