=== 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 2014-11-19 09:29:44 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-11-19 12:00:31 +0000 @@ -121,7 +121,10 @@ $scope.eventFetched = false; - if( $scope.selectedProgram && $scope.selectedProgram.programStages[0].id){ + if( $scope.selectedProgram && + $scope.selectedProgram.programStages && + $scope.selectedProgram.programStages[0] && + $scope.selectedProgram.programStages[0].id){ $scope.optionSets = []; OptionSetService.getAll().then(function(optionSets){ @@ -231,7 +234,10 @@ } } if($scope.prStDes[dataValue.dataElement].dataElement.type === 'string'){ - if($scope.prStDes[dataValue.dataElement].dataElement.optionSet ){ + if($scope.prStDes[dataValue.dataElement].dataElement.optionSet && + $scope.prStDes[dataValue.dataElement].dataElement.optionSet.id && + $scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id] && + $scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id].options ){ val = OptionSetService.getNameOrCode($scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id].options, val); } } === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-11-12 16:49:17 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-11-19 12:00:31 +0000 @@ -248,10 +248,26 @@ }; }) +.directive('d2TypeaheadValidation', function() { + + return { + require: 'ngModel', + restrict: 'A', + link: function (scope, element, attrs, ctrl) { + element.bind('blur', function () { + if(ctrl.$viewValue && !ctrl.$modelValue){ + ctrl.$setViewValue(); + ctrl.$render(); + } + }); + } + }; +}) + .directive('typeaheadOpenOnFocus', function () { return { require: ['typeahead', 'ngModel'], - link: function (scope, element, attr, ctrls) { + link: function (scope, element, attr, ctrls) { element.bind('focus', function () { ctrls[0].getMatchesAsync(ctrls[1].$viewValue); === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-11-19 09:55:11 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-11-19 12:00:31 +0000 @@ -391,6 +391,7 @@ ' ng-required="prStDes.' + deId + '.compulsory"' + ' typeahead="option.name as option.name for option in optionSets.'+optionSetId+'.options | filter:$viewValue | limitTo:20"' + ' typeahead-editable="false" ' + + ' d2-typeahead-validation ' + ' typeahead-open-on-focus ng-required="prStDes.'+deId+'.compulsory"> ' + '{{\'option_required\'| translate}}'; } @@ -400,7 +401,7 @@ ' ng-model="currentEvent.' + deId + '" ' + ' ng-disabled="currentEvent[uid] == \'uid\'" ' + ' ng-required="prStDes.' + deId + '.compulsory"> ' + - '{{\'text_required\'| translate}}'; + '{{\'string_required\'| translate}}'; } } if(programStageDataElements[deId].dataElement.type == "bool"){ === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2014-11-19 09:29:44 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2014-11-19 12:00:31 +0000 @@ -866,6 +866,25 @@ margin-right: 20px; } +input.typeahead::-webkit-input-placeholder { + font-family: fontAwesome; + content: "\f0d7"; + text-align: right; + font-weight: bold; +} +input.typeahead::-moz-placeholder { + font-family: fontAwesome; + content: "\f0d7"; + text-align: right; + font-weight: bold; +} +input.typeahead::-ms-input-placeholder { + font-family: fontAwesome; + content: "\f0d7"; + text-align: right; + font-weight: bold; +} + @media print { #header, #leftBar, .not-printable { === 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 2014-11-19 09:55:11 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2014-11-19 12:00:31 +0000 @@ -86,10 +86,13 @@
@@ -119,7 +122,7 @@ ng-required={{eventGridColumn.compulsory}} name="foo" style="width:99%;"/> - {{'text_required'| translate}} + {{'string_required'| translate}}
@@ -264,6 +267,7 @@ typeahead="option.name as option.name for option in prStDes[de.dataElement.id].dataElement.optionSet.options | filter:$viewValue | limitTo:20" typeahead-open-on-focus typeahead-editable="false" + d2-typeahead-validation ng-required={{prStDes[de.dataElement.id].compulsory}} name="foo" style="width:99%;"/> @@ -293,7 +297,7 @@ ng-required={{prStDes[de.dataElement.id].compulsory}} name="foo" style="width:99%;"/> - {{'text_required'| translate}} + {{'string_required'| translate}}