← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20826: Dialog when trying to complete an event with errors

 

------------------------------------------------------------
revno: 20826
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-21 14:12:37 +0200
message:
  Dialog when trying to complete an event with errors
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/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/views/dialog.html


--
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-10-20 12:18:23 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-10-21 12:12:37 +0000
@@ -18,6 +18,7 @@
                 ProgramStageFactory,
                 DHIS2EventFactory,
                 ModalService,
+                DialogService,
                 CurrentSelection,
                 TrackerRulesExecutionService,
                 CustomFormService,
@@ -122,23 +123,29 @@
                         $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined");
                     }
                 } else if (effect.action === "SHOWERROR") {
-                    if (effect.dataElement) {
+                    if (effect.ineffect) {
                         
-                        if(effect.ineffect) {
-                            $scope.errorMessages[effect.dataElement.id] = effect.content + (effect.data ? effect.data : "");
-                        } else {
-                            $scope.errorMessages[effect.dataElement.id] = false;
+                        if(effect.dataElement) {
+                            var message = effect.content + (effect.data ? effect.data : "");
+                            $scope.errorMessages[effect.dataElement.id] = message;
+                            $scope.errorMessages.push($translate.instant($scope.prStDes[effect.dataElement.id].dataElement.name) + ": " + message);
+                        }
+                        else
+                        {
+                            $scope.errorMessages.push(message);
                         }
                     }
                     else {
-                        $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined");
+                        
                     }
                 } else if (effect.action === "SHOWWARNING") {
-                    if (effect.dataElement) {
-                        if(effect.ineffect) {
-                            $scope.warningMessages[effect.dataElement.id] = effect.content + (effect.data ? effect.data : "");
+                    if (effect.ineffect) {
+                        if(effect.dataElement) {
+                            var message = effect.content + (effect.data ? effect.data : "");
+                            $scope.warningMessages[effect.dataElement.id] = effect.content + message;
+                            $scope.warningMessages.push($translate.instant($scope.prStDes[effect.dataElement.id].dataElement.name) + ": " + message);
                         } else {
-                            $scope.warningMessages[effect.dataElement.id] = false;
+                            $scope.warningMessages.push(message);
                         }
                     }
                     else {
@@ -819,17 +826,33 @@
             dhis2Event.status = 'ACTIVE';
         }
         else {//complete event
-            modalOptions = {
-                closeButtonText: 'cancel',
-                actionButtonText: 'complete',
-                headerText: 'complete',
-                bodyText: 'are_you_sure_to_complete_event'
-            };
-            dhis2Event.status = 'COMPLETED';
+            
+            if($scope.errorMessages && $scope.errorMessages.length > 0) {
+                //There is unresolved program rule errors - show error message.
+                var dialogOptions = {
+                    headerText: 'errors',
+                    bodyText: 'please_fix_errors_before_completing',
+                    bodyList: $scope.errorMessages
+                };
+
+                DialogService.showDialog({}, dialogOptions);
+                
+                return;
+            }
+            else
+            {
+                modalOptions = {
+                    closeButtonText: 'cancel',
+                    actionButtonText: 'complete',
+                    headerText: 'complete',
+                    bodyText: 'are_you_sure_to_complete_event'
+                };
+                dhis2Event.status = 'COMPLETED';
+            }
         }
 
         ModalService.showModal({}, modalOptions).then(function (result) {
-
+            
             DHIS2EventFactory.update(dhis2Event).then(function (data) {
 
                 if ($scope.currentEvent.status === 'COMPLETED') {//activiate event                    

=== 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-10-20 12:54:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-10-21 12:12:37 +0000
@@ -290,6 +290,7 @@
 delete_relationship=Delete relationship
 go_back=Go back
 cancel=Cancel
+errors=Errors
 are_you_sure_to_delete_relationship=Are you sure you want to delete the relationship?
 are_you_sure_to_delete_enrollment=Are you sure you want to delete the selected enrollment?
 would_you_like_to_complete_enrollment=Would you like to complete the current enrollment?
@@ -297,7 +298,8 @@
 are_you_sure_to_terminate_enrollment=Are you sure you want to terminate the selected enrollment?
 are_you_sure_to_delete_event=Are you sure you want to delete the selected event?
 are_you_sure_to_complete_event=Are you sure you want to complete the selected event?
-are_you_sure_to_incomplete_event=Are you sure you want to incomplete the selected event?
+please_fix_errors_before_completing=Please review and fix the following error(s) before completing the event:
+are_you_sure_to_incomplete_event=Are you sure you want to edit the selected event? 
 are_you_sure_to_skip_event=Are you sure you want to skip the selected event?
 are_you_sure_to_unskip_event=Are you sure you want to schedule back the selected event?
 do_you_want_to_proceed=Do you want to proceed with invalid criteria?

=== 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	2015-10-16 11:04:37 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties	2015-10-21 12:12:37 +0000
@@ -242,11 +242,13 @@
 save_relationship=\u0627\u062d\u0641\u0638 \u0627\u0644\u0639\u0644\u0627\u0642\u0629
 go_back=\u0627\u0631\u062c\u0639 \u0644\u0644\u062e\u0644\u0641
 cancel=\u0627\u0644\u063a\u0650
+errors=\u0627\u0644\u0623\u062e\u0637\u0627\u0621
 are_you_sure_to_delete_enrollment=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u062d\u0630\u0641 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u0645\u062e\u062a\u0627\u0631\u0629 \u061f
 are_you_sure_to_complete_enrollment=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u0627\u0643\u0645\u0627\u0644 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u0645\u062e\u062a\u0627\u0631\u0629 \u061f
 are_you_sure_to_terminate_enrollment=\u0647\u0644 \u0627\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u0627\u0646\u0647\u0627\u0621 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u0645\u062e\u062a\u0627\u0631\u0629 \u061f
 are_you_sure_to_delete_event=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u062d\u0630\u0641 \u0627\u0644\u062d\u062f\u062b \u0627\u0644\u0645\u062e\u062a\u0627\u0631 \u061f
 are_you_sure_to_complete_event=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u0627\u0643\u0645\u0627\u0644 \u0627\u0644\u062d\u062f\u062b \u0627\u0644\u0645\u062e\u062a\u0627\u0631 \u061f
+please_fix_errors_before_completing=\u0627\u0644\u0631\u062c\u0627\u0621 \u0645\u0631\u0627\u062c\u0639\u0629 \u0648 \u062a\u0635\u062d\u064a\u062d \u0627\u0644\u0627\u062e\u0637\u0627\u0621 \u0627\u0644\u062a\u0627\u0644\u064a\u0629 \u0642\u0628\u0644 \u0627\u0644\u0627\u0633\u062a\u0645\u0631\u0627\u0631
 are_you_sure_to_incomplete_event=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u0639\u062f\u0645 \u0627\u0643\u0645\u0627\u0644 \u0627\u0644\u062d\u062f\u062b \u0627\u0644\u0645\u062e\u062a\u0627\u0631 \u061f
 are_you_sure_to_skip_event=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u062a\u062e\u0637\u064a \u0627\u0644\u062d\u062f\u062b \u0627\u0644\u0645\u062e\u062a\u0627\u0631 \u061f
 are_you_sure_to_unskip_event=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f \u0645\u0646 \u0623\u0646\u0643 \u062a\u0631\u063a\u0628 \u0641\u064a \u062c\u062f\u0648\u0644\u0629 \u0627\u0644\u062d\u062f\u062b \u0627\u0644\u0645\u062e\u062a\u0627\u0631 \u0644\u0644\u0633\u0627\u0628\u0642 \u061f

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/dialog.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/dialog.html	2015-07-13 07:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/dialog.html	2015-10-21 12:12:37 +0000
@@ -3,6 +3,11 @@
 </div>
 <div class="modal-body">
     <p>{{dialogOptions.bodyText | translate}}</p>
+    <ul ng-if="dialogOptions && dialogOptions.bodyList.length > 0">
+        <li ng-repeat="item in dialogOptions.bodyList">
+            {{ item | translate }}
+        </li>
+    </ul>
 </div>
 
 <div class="modal-footer">