dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40113
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20311: Now hiding a field if ANY programrule wants to hide it. Also removed isHidden(), binding directly...
------------------------------------------------------------
revno: 20311
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-23 13:27:46 +0200
message:
Now hiding a field if ANY programrule wants to hide it. Also removed isHidden(), binding directly to the model instead.
modified:
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/views/defaultForm.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-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-23 08:17:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-23 11:27:46 +0000
@@ -883,6 +883,8 @@
$scope.$on('ruleeffectsupdated', function(event, args) {
$scope.warningMessages = [];
$scope.hiddenSections = [];
+ $scope.hiddenFields = [];
+
//console.log('args.event: ', $rootScope.ruleeffects['SINGLE_EVENT'][0]);
if($rootScope.ruleeffects[args.event]) {
//Establish which event was affected:
@@ -897,11 +899,11 @@
}
angular.forEach($rootScope.ruleeffects[args.event], function(effect) {
- if( effect.dataElement ) {
+ if(effect.dataElement && effect.ineffect) {
//in the data entry controller we only care about the "hidefield" actions
if(effect.action === "HIDEFIELD") {
if(effect.dataElement) {
- if(effect.ineffect && affectedEvent[effect.dataElement.id]) {
+ if(affectedEvent[effect.dataElement.id]) {
//If a field is going to be hidden, but contains a value, we need to take action;
if(effect.content) {
//TODO: Alerts is going to be replaced with a proper display mecanism.
@@ -922,12 +924,12 @@
$log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined");
}
}
- if(effect.action === "HIDESECTION" && effect.ineffect) {
+ if(effect.action === "HIDESECTION") {
if(effect.programStageSection){
$scope.hiddenSections[effect.programStageSection] = effect.programStageSection;
}
}
- if(effect.action === "SHOWERROR" && effect.ineffect && effect.dataElement.id){
+ if(effect.action === "SHOWERROR" && effect.dataElement.id){
var dialogOptions = {
headerText: 'validation_error',
bodyText: effect.content
@@ -936,7 +938,7 @@
$scope.currentEvent[effect.dataElement.id] = $scope.currentEventOriginialValue[effect.dataElement.id];
}
- if(effect.action === "SHOWWARNING" && effect.ineffect){
+ if(effect.action === "SHOWWARNING"){
$scope.warningMessages.push(effect.content);
}
}
@@ -959,18 +961,6 @@
return dhis2.validation.isNumber(val) ? val : '';
};
- //check if field is hidden
- $scope.isHidden = function(id) {
- //In case the field contains a value, we cant hide it.
- //If we hid a field with a value, it would falsely seem the user was aware that the value was entered in the UI.
- if($scope.currentEvent[id]) {
- return false;
- }
- else {
- return $scope.hiddenFields[id];
- }
- };
-
$scope.saveDatavalue = function(){
$scope.executeRules();
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-21 16:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-23 11:27:46 +0000
@@ -69,7 +69,7 @@
</div>
</td>
</tr>
- <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid' && eventGridColumn.id !== 'event_date' && !isHidden(eventGridColumn.id)">
+ <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid' && eventGridColumn.id !== 'event_date' && !hiddenFields[eventGridColumn.id]">
<td >
{{eventGridColumn.name}}<span ng-if="eventGridColumn.compulsory" class="required">*</span>
</td>
@@ -330,7 +330,7 @@
</tr>
</thead>
<tbody>
- <tr ng-repeat="de in section.programStageDataElements" ng-if="!isHidden(de.dataElement.id)">
+ <tr ng-repeat="de in section.programStageDataElements" ng-if="!hiddenFields[de.dataElement.id]">
<td >
{{prStDes[de.dataElement.id].dataElement.formName ? prStDes[de.dataElement.id].dataElement.formName : prStDes[de.dataElement.id].dataElement.name}}
<span ng-if="prStDes[de.dataElement.id].compulsory" class="required">*</span>