=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-05-14 13:04:39 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-05-15 12:45:17 +0000 @@ -12,6 +12,7 @@ "advanced_search": "Advanced search", "search_for": "Search for", "your_search_input_here": "Your search input here", + "search_input_required": "Please specify a search criteria", "registered_entities": "Registered Entities", "empty_entity_list": "There are no reigstered entities", "empty": "Empty", === modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-14 15:42:24 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-15 12:45:17 +0000 @@ -13,6 +13,7 @@ SelectedEntity, storage, AttributesFactory, + EntityQueryFactory, TrackedEntityInstanceService) { //Selection @@ -35,6 +36,7 @@ //Searching $scope.showSearchDiv = false; $scope.searchText = null; + $scope.emptySearchText = false; $scope.searchFilterExists = false; $scope.attributes = AttributesFactory.getWithoutProgram(); $scope.searchMode = {listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED'}; @@ -99,7 +101,9 @@ } }; - $scope.search = function(mode){ + $scope.search = function(mode){ + + $scope.emptySearchText = false; var queryUrl = null, programUrl = null, attributeUrl = null; @@ -125,52 +129,20 @@ if( mode === $scope.searchMode.freeText ){ $scope.trackedEntityList = null; - if(!$scope.searchText){ - console.log('empty search query'); + if(!$scope.searchText){ + $scope.emptySearchText = true; return; } $scope.showTrackedEntityDiv = true; - queryUrl = 'query=' + $scope.searchText; - + queryUrl = 'query=' + $scope.searchText; } else if( mode === $scope.searchMode.attributeBased ){ $scope.showTrackedEntityDiv = true; - angular.forEach($scope.attributes, function(attribute){ - - if(attribute.value && attribute.value !== ""){ - $scope.searchFilterExists = true; - if(angular.isArray(attribute.value)){ - angular.forEach(attribute.value, function(val){ - if(attributeUrl){ - attributeUrl = attributeUrl + '&attribute=' + attribute.id + ':EQ:' + val; - } - else{ - attributeUrl = 'attribute=' + attribute.id + ':EQ:' + val; - } - }); - } - else{ - if(attributeUrl){ - attributeUrl = attributeUrl + '&attribute=' + attribute.id + ':EQ:' + attribute.value; - } - else{ - attributeUrl = 'attribute=' + attribute.id + ':EQ:' + attribute.value; - } - } - } - else{ - if(attributeUrl){ - attributeUrl = attributeUrl + '&attribute=' + attribute.id; - } - else{ - attributeUrl = 'attribute=' + attribute.id; - } - } - }); - - if(!$scope.searchFilterExists){ + attributeUrl = EntityQueryFactory.getQueryForAttributes($scope.attributes); + + if(!attributeUrl.hasValue){ console.log('empty search filter'); return; } @@ -186,7 +158,7 @@ $scope.ouMode, queryUrl, programUrl, - attributeUrl).then(function(data){ + attributeUrl.url).then(function(data){ $scope.trackedEntityList = data; }); }; === modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-14 15:42:24 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-15 12:45:17 +0000 @@ -338,8 +338,52 @@ }; }) -.service('ProgramAttributes', function(){ - +.service('EntityQueryFactory', function(){ + + var query = {url: null, hasValue: false}; + + this.getQueryForAttributes = function(attributes){ + + angular.forEach(attributes, function(attribute){ + + //console.log('attribute', attribute.valueType); + + if(attribute.value && attribute.value !== ""){ + query.hasValue = true; + if(angular.isArray(attribute.value)){ + var index = 0; + + angular.forEach(attribute.value, function(val){ + if(query.url){ + query.url = query.url + '&attribute=' + attribute.id + ':LIKE:' + val; + } + else{ + query.url = 'attribute=' + attribute.id + ':LIKE:' + val; + } + index++; + }); + } + else{ + if(query.url){ + query.url = query.url + '&attribute=' + attribute.id + ':LIKE:' + attribute.value; + } + else{ + query.url = 'attribute=' + attribute.id + ':LIKE:' + attribute.value; + } + } + } + else{ + if(query.url){ + query.url = query.url + '&attribute=' + attribute.id; + } + else{ + query.url = 'attribute=' + attribute.id; + } + } + }); + + return query; + }; }) /* Modal service for user interaction */ === modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-05-14 13:04:39 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-05-15 12:45:17 +0000 @@ -776,6 +776,14 @@ padding-left: 5px; } +.invalid-input { + border-style:solid; + border-color:red; +} + +.alert { + padding: 5px; +} .input-field { border: 1px solid #aaa; padding: 4px 1px; === modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-05-14 13:09:15 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-05-15 12:45:17 +0000 @@ -22,11 +22,11 @@
- + -
+
+
+ +
+
+
{{'search_input_required' | translate}}
=== modified file 'dhis-2/dhis-web/pom.xml' --- dhis-2/dhis-web/pom.xml 2014-05-14 13:04:39 +0000 +++ dhis-2/dhis-web/pom.xml 2014-05-15 12:45:17 +0000 @@ -30,6 +30,7 @@ dhis-web-light dhis-web-mobile dhis-web-sms + dhis-web-event-capture dhis-web-event-reports dhis-web-tracker-capture dhis-web-portal