dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39031
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19813: added support for showing error and warning messages in tracker capture, based on program rules
------------------------------------------------------------
revno: 19813
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-08-21 11:37:44 +0200
message:
added support for showing error and warning messages in tracker capture, based on program rules
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/dataentry/default-form.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-07-15 14:30:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-08-21 09:37:44 +0000
@@ -36,6 +36,9 @@
$scope.stagesCanBeShownAsTable = false;
$scope.showHelpText = {};
$scope.hiddenFields = {};
+ $scope.errorMessages = {};
+ $scope.warningMessages = {};
+
var userProfile = SessionStorageService.get('USER_PROFILE');
var storedBy = userProfile && userProfile.username ? userProfile.username : '';
@@ -78,7 +81,7 @@
angular.forEach($rootScope.ruleeffects[event], function (effect) {
if (effect.dataElement) {
- //in the data entry controller we only care about the "hidefield" actions
+ //in the data entry controller we only care about the "hidefield", showerror and showwarning actions
if (effect.action === "HIDEFIELD") {
if (effect.dataElement) {
if (effect.ineffect && affectedEvent[effect.dataElement.id]) {
@@ -102,6 +105,29 @@
else {
$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) {
+ $scope.errorMessages[effect.dataElement.id] = effect.content;
+ } else {
+ $scope.errorMessages[effect.dataElement.id] = false;
+ }
+ }
+ 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;
+ } else {
+ $scope.warningMessages[effect.dataElement.id] = false;
+ }
+ }
+ else {
+ $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined");
+ }
}
}
});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html 2015-08-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html 2015-08-21 09:37:44 +0000
@@ -151,6 +151,14 @@
</div>
</div>
<div ng-messages="innerForm.foo.$error" ng-if="interacted(innerForm.foo)" class="required" ng-messages-include="../dhis-web-commons/angular-forms/error-messages.html">
+ <div class="alert alert-warning alert-dismissible" role="alert" ng-if="warningMessages[prStDe.dataElement.id]">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
+ {{warningMessages[prStDe.dataElement.id]}}
+ </div>
+ <div class="alert alert-danger alert-dismissible" role="alert" ng-if="errorMessages[prStDe.dataElement.id]">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
+ {{errorMessages[prStDe.dataElement.id]}}
+ </div>
</div>
</ng-form>
</td>
@@ -319,9 +327,17 @@
ng-blur="saveDatavalue(prStDes[de.dataElement.id])"
name="foo"/>
</div>
- </div>
- <div ng-messages="innerForm.foo.$error" ng-if="interacted(innerForm.foo)" class="required" ng-messages-include="../dhis-web-commons/angular-forms/error-messages.html">
- </div>
+ <div ng-messages="innerForm.foo.$error" ng-if="interacted(innerForm.foo)" class="required" ng-messages-include="../dhis-web-commons/angular-forms/error-messages.html">
+ </div>
+ <div class="alert alert-warning alert-dismissible" role="alert" ng-if="warningMessages[de.dataElement.id]">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
+ {{warningMessages[de.dataElement.id]}}
+ </div>
+ <div class="alert alert-danger alert-dismissible" role="alert" ng-if="errorMessages[de.dataElement.id]">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
+ {{errorMessages[de.dataElement.id]}}
+ </div>
+ </div>
</ng-form>
</td>
<td ng-if="allowProvidedElsewhereExists">