=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html 2015-08-26 12:29:22 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html 2015-08-27 19:05:47 +0000 @@ -1,6 +1,6 @@

{{'profile'| translate}}

- + === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2015-08-27 15:15:20 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2015-08-27 19:05:47 +0000 @@ -26,7 +26,10 @@ $scope.customForm = null; $scope.selectedTei = {}; $scope.tei = {}; - $scope.registrationMode = null; + $scope.registrationMode = null; + $scope.hiddenFields = {}; + $scope.errorMessages = {}; + $scope.warningMessages = {}; $scope.attributesById = CurrentSelection.getAttributesById(); if(!$scope.attributesById){ @@ -272,11 +275,11 @@ var processRuleEffect = function(){ angular.forEach($rootScope.ruleeffects['registration'], function (effect) { - if (effect.dataElement) { + if (effect.trackedEntityAttribute) { //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]) { + if (effect.trackedEntityAttribute) { + if (effect.ineffect && $scope.selectedTei[effect.trackedEntityAttribute.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. @@ -284,41 +287,40 @@ } else { //TODO: Alerts is going to be replaced with a proper display mecanism. - alert($scope.prStDes[effect.dataElement.id].dataElement.formName + "Was blanked out and hidden by your last action"); + alert($scope.attributesById[effect.trackedEntityAttribute.id].name + "Was blanked out and hidden by your last action"); } //Blank out the value: - affectedEvent[effect.dataElement.id] = ""; - $scope.saveDatavalueForEvent($scope.prStDes[effect.dataElement.id], null, affectedEvent); + $scope.selectedTei[effect.trackedEntityAttribute.id] = ""; } - $scope.hiddenFields[effect.dataElement.id] = effect.ineffect; + $scope.hiddenFields[effect.trackedEntityAttribute.id] = effect.ineffect; } else { - $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined"); + $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have an attribute defined"); } } else if (effect.action === "SHOWERROR") { - if (effect.dataElement) { + if (effect.trackedEntityAttribute) { if(effect.ineffect) { - $scope.errorMessages[effect.dataElement.id] = effect.content; + $scope.errorMessages[effect.trackedEntityAttribute.id] = effect.content; } else { - $scope.errorMessages[effect.dataElement.id] = false; + $scope.errorMessages[effect.trackedEntityAttribute.id] = false; } } else { - $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined"); + $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have an attribute defined"); } } else if (effect.action === "SHOWWARNING") { - if (effect.dataElement) { + if (effect.trackedEntityAttribute) { if(effect.ineffect) { - $scope.warningMessages[effect.dataElement.id] = effect.content; + $scope.warningMessages[effect.trackedEntityAttribute.id] = effect.content; } else { - $scope.warningMessages[effect.dataElement.id] = false; + $scope.warningMessages[effect.trackedEntityAttribute.id] = false; } } else { - $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have a dataelement defined"); + $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEFIELD, bot does not have an attribute defined"); } } } @@ -326,7 +328,7 @@ }; $scope.executeRules = function () { - var flag = {debug: true, verbose: true}; + var flag = {debug: true, verbose: false}; //repopulate attributes with updated values $scope.selectedTei.attributes = []; @@ -347,6 +349,13 @@ }; + //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. + return $scope.selectedTei[id] ? false : $scope.hiddenFields[id]; + }; + $scope.teiValueUpdated = function(tei, field){ $scope.executeRules(); }; === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2015-07-13 07:37:11 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2015-08-27 19:05:47 +0000 @@ -95,8 +95,8 @@ - - + + === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-08-27 15:15:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-08-27 19:05:47 +0000 @@ -395,7 +395,7 @@ this.getAttributesAsString(attributes) + ' d2-focus-next-on-enter' + ' ng-model="selectedTei.' + attId + '" ' + - ' ng-disabled="editingDisabled"' + + ' ng-disabled="editingDisabled || isHidden(attributesById.' + attId + '.id)"' + ' d2-validation ' + ' ng-required=" ' + (att.mandatory || att.unique) + '" '; @@ -762,6 +762,7 @@ return pushVariable(variables, variablename, variableValue, variableType, variablefound, variablePrefix); }, getVariables: function(allProgramRules, executingEvent, evs, allDes, selectedEntity, selectedEnrollment) { + var variables = {}; var programVariables = allProgramRules.programVariables; @@ -769,6 +770,7 @@ programVariables = programVariables.concat(allProgramRules.programIndicators.variables); angular.forEach(programVariables, function(programVariable) { + var dataElementId = programVariable.dataElement; if(programVariable.dataElement && programVariable.dataElement.id) { dataElementId = programVariable.dataElement.id; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm 2015-08-27 14:45:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm 2015-08-27 19:05:47 +0000 @@ -104,7 +104,7 @@ #if( $ruleVariable.sourceType == 'TEI_ATTRIBUTE') #set( $json_Data='{"name":"' + $ruleVariable.name + '"' + ',"sourceType":"' + $ruleVariable.sourceType + '"' - + ',"trackedEntityAttribute":{ "id":"' + $ruleVariable.trackedEntityAttribute.id + '"}' + + ',"trackedEntityAttribute":{ "id":"' + $ruleVariable.attribute.id + '"}' + ',"program":{"id":"' + $ruleVariable.program.id + '"}}' ) #else #set( $json_Data='{"name":"' + $ruleVariable.name + '"' === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm 2015-08-27 14:45:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm 2015-08-27 19:05:47 +0000 @@ -111,7 +111,7 @@ #if( $ruleVariable.sourceType == "TEI_ATTRIBUTE" ) #set( $json_Data='{"name":"' + $ruleVariable.name + '"' + ',"sourceType":"' + $ruleVariable.sourceType + '"' - + ',"trackedEntityAttribute":{ "id":"' + $ruleVariable.dataElement.id + '"}' + + ',"trackedEntityAttribute":{ "id":"' + $ruleVariable.attribute.id + '"}' + ',"program":{"id":"' + "$!ruleVariable.program.id" + '"}}' )
{{attribute.name}}*