=== 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-06-27 10:57:20 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-06-27 13:33:07 +0000 @@ -90,14 +90,20 @@ "scheduling": "Scheduling", "reschedule": "Reschedule", "enroll": "Enroll", + "start_date": "Start date", + "end_date": "End date", "from": "From", "to": "To", + "exact_date": "Exact date", + "exact_value": "Exact value", "EQ": "Equals", "GT": "Greater than", "GE": "Greater equal", "LT": "Less than", "LE": "Less equal", "NE": "Not equal", + "IS": "Is", + "RANGE": "Range", "like": "Like", "not_like": "Not like", "boolean": "Boolean", === 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-06-26 13:35:30 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-06-27 13:33:07 +0000 @@ -12,6 +12,7 @@ Paginator, TranslationService, storage, + OperatorFactory, ProgramFactory, AttributesFactory, EntityQueryFactory, @@ -39,9 +40,9 @@ $scope.searchText = null; $scope.emptySearchText = false; $scope.searchFilterExists = false; - $scope.numberOperands = ['EQ', 'GT','GE', 'LT', 'LE', 'NE' ]; - $scope.boolOperands = ['yes', 'no']; - $scope.enrollment = {programStartDate: '', programEndDate: ''}; + $scope.defaultOperators = OperatorFactory.defaultOperators; + $scope.boolOperators = OperatorFactory.boolOperators; + $scope.enrollment = {programStartDate: '', programEndDate: '', operator: $scope.defaultOperators[0]}; $scope.searchMode = { listAll: 'LIST_ALL', @@ -184,8 +185,6 @@ else if( mode === $scope.searchMode.listAll ){ $scope.showTrackedEntityDiv = true; } - - //$scope.gridColumns = $scope.generateGridColumns($scope.attributes); //get events for the specified parameters TEIService.search($scope.selectedOrgUnit.id, @@ -200,39 +199,14 @@ $scope.generateAttributeFilters = function(attributes){ angular.forEach(attributes, function(attribute){ - var filter = {operand: '', value: ''}; - - if(attribute.valueType === 'number'){ - filter.operand = $scope.numberOperands[0]; - attribute.filters = [filter]; + if(attribute.valueType === 'number' || attribute.valueType === 'date'){ + attribute.operator = $scope.defaultOperators[0]; } }); return attributes; }; - - $scope.addFilter = function(attribute, filter){ - - var filter = { operand: '', value: ''}; - - if(attribute.valueType === 'number'){ - filter.operand = $scope.numberOperands[0]; - } - attribute.filters.push(filter); - }; - - $scope.removeFilter = function(filter, attribute){ - - var index = attribute.filters.indexOf(filter); - attribute.filters.splice(index, 1); - - //this is a bit strange, removing a filter toggles off search drop down. - //to avoid this, had to do stop poropagation. - if (window.event) { - window.event.stopPropagation(); - } - }; - + //generate grid columns from teilist attributes $scope.generateGridColumns = function(attributes){ var columns = attributes ? angular.copy(attributes) : []; === 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-06-27 10:57:20 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-06-27 13:33:07 +0000 @@ -442,37 +442,64 @@ }; }) -.service('EntityQueryFactory', function(){ +.factory('OperatorFactory', function(){ + + var defaultOperators = ['IS', 'RANGE' ]; + var boolOperators = ['yes', 'no']; + return{ + defaultOperators: defaultOperators, + boolOperators: boolOperators + }; +}) + +.service('EntityQueryFactory', function(OperatorFactory){ this.getQueryForAttributes = function(attributes, enrollment){ - + var query = {url: null, hasValue: false}; angular.forEach(attributes, function(attribute){ - if(attribute.valueType === 'date'){ + if(attribute.valueType === 'date' || attribute.valueType === 'number'){ var q = ''; - if(attribute.startDate && attribute.startDate !== ''){ + if(attribute.operator === OperatorFactory.defaultOperators[0]){ + if(attribute.exactValue && attribute.exactValue !== ''){ + query.hasValue = true; + q += 'EQ:' + attribute.exactValue + ':'; + } + } + if(attribute.operator === OperatorFactory.defaultOperators[1]){ + if(attribute.startValue && attribute.startValue !== ''){ + query.hasValue = true; + q += 'GT:' + attribute.startValue + ':'; + } + if(attribute.endValue && attribute.endValue !== ''){ + query.hasValue = true; + q += 'LT:' + attribute.endValue + ':'; + } + } + + /*if(attribute.startDate && attribute.startDate !== ''){ query.hasValue = true; q += 'GE:' + attribute.startDate + ':'; } if(attribute.endDate && attribute.endDate !== ''){ query.hasValue = true; - q += 'GE:' + attribute.endDate + ':'; - } + q += 'LE:' + attribute.endDate + ':'; + }*/ if(query.url){ if(q){ q = q.substr(0,q.length-1); - query.url = query.url + '&filter=' + attribute.id + q; + query.url = query.url + '&filter=' + attribute.id + ':' + q; } } else{ if(q){ q = q.substr(0,q.length-1); - query.url = 'filter=' + attribute.id + q; + query.url = 'filter=' + attribute.id + ':' + q; } } } @@ -510,11 +537,11 @@ } - if(attribute.filters){ + /*if(attribute.filters){ var q = ''; angular.forEach(attribute.filters, function(filter){ if(filter.value !== ''){ - q += filter.operand + ':' + filter.value + ':'; + q += filter.operator + ':' + filter.value + ':'; } }); q = q.substr(0,q.length-1); @@ -529,23 +556,39 @@ query.url = 'filter=' + attribute.id + ':' + q; } } - } + }*/ } }); if(enrollment){ - console.log('there is enrollment is: ', enrollment); var q = ''; - if(enrollment.programStartDate && enrollment.programStartDate !== ''){ + if(enrollment.operator === OperatorFactory.defaultOperators[0]){ + if(enrollment.programExactDate && enrollment.programExactDate !== ''){ + query.hasValue = true; + q += '&programStartDate=' + enrollment.programExactDate + '&programEndDate=' + enrollment.programExactDate; + } + } + if(enrollment.operator === OperatorFactory.defaultOperators[1]){ + if(enrollment.programStartDate && enrollment.programStartDate !== ''){ + query.hasValue = true; + q += '&programStartDate=' + enrollment.programStartDate; + } + if(enrollment.programEndDate && enrollment.programEndDate !== ''){ + query.hasValue = true; + q += '&programEndDate=' + enrollment.programEndDate; + } + } + + /*if(enrollment.programStartDate && enrollment.programStartDate !== ''){ query.hasValue = true; q += '&programStartDate=' + enrollment.programStartDate; } if(enrollment.programEndDate && enrollment.programEndDate !== ''){ query.hasValue = true; q += '&programEndDate=' + enrollment.programEndDate; - } + }*/ if(q){ if(query.url){ === 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-06-27 11:14:08 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-06-27 13:33:07 +0000 @@ -792,18 +792,19 @@ color: red; } -.filter-operand { - width: 45%; +.filter-operator { + width: 30%; float: left; font-size: 14px; line-height: 1.0; } .filter-value { - width: 40%; + width: 70%; float: left; font-size: 14px; line-height: 1.0; + padding-left: 4px; } .form-control-filter{ @@ -821,20 +822,6 @@ transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s } -.filter-add { - width: 7.5%; - float: left; - padding-top: 5px; - padding-left: 5px; -} - -.filter-remove { - width: 7.5%; - float: left; - padding-top: 5px; - padding-left: 5px; -} - .invalid-input { border-style:solid; border-color:red; === modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html' --- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html 2014-06-27 10:57:20 +0000 +++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html 2014-06-27 13:33:07 +0000 @@ -13,12 +13,21 @@ {{'enrollment_date'| translate}}
-
- -
-
- -
+
+ +
+
+ +
+
+
+ +
+
+ +
+
@@ -29,30 +38,41 @@
-
-
-
-
- -
-
- -
-
- -
+
+ +
+
+
+ +
+
+ +
+
-
- -
-
- -
+
+ +
+
+ +
+
+
+ +
+
+ +
+
@@ -65,7 +85,7 @@