dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31205
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15884: tracker capture - simplified advanced tei search a bit
------------------------------------------------------------
revno: 15884
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2014-06-27 15:33:07 +0200
message:
tracker capture - simplified advanced tei search a bit
modified:
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/scripts/controllers.js
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/styles/style.css
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.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-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 @@
<td>{{'enrollment_date'| translate}}</td>
<td>
<div class="dataelement-filter">
- <div class="container-1-2">
- <input type="text" placeholder="{{'from'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programStartDate"/>
- </div>
- <div class="container-1-2">
- <input type="text" placeholder="{{'to'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programEndDate"/>
- </div>
+ <div class="filter-operator">
+ <select ng-model="enrollment.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
+ </select>
+ </div>
+ <div class="filter-value" ng-show="enrollment.operator === defaultOperators[0]">
+ <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programExactDate"/>
+ </div>
+ <div class="filter-value" ng-show="enrollment.operator === defaultOperators[1]">
+ <div class="container-1-2">
+ <input type="text" placeholder="{{'start_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programStartDate"/>
+ </div>
+ <div class="container-1-2">
+ <input type="text" placeholder="{{'end_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programEndDate"/>
+ </div>
+ </div>
</div>
</td>
</tr>
@@ -29,30 +38,41 @@
<td>
<div ng-switch="attribute.valueType">
<div ng-switch-when="number">
- <div class="dataelement-filter" ng-repeat="filter in attribute.filters">
- <div class="filter-operand">
- <select ng-model="filter.operand" class="form-control-select2" ng-options="operand | translate for operand in numberOperands">
+ <div class="dataelement-filter">
+ <div class="filter-operator">
+ <select ng-model="attribute.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
</select>
</div>
- <div class="filter-value">
- <input type="number" ng-model="filter.value" class="form-control-select2">
- </div>
- <div class="filter-add">
- <button class="btn-link" ng-click="addFilter(attribute)" title="{{'add_filter'| translate}}"><span class="black"><i class="fa fa-plus"></i></span></button>
- </div>
- <div class="filter-remove">
- <button class="btn-link" ng-click="removeFilter(filter, attribute)" title="{{'remove_filter'| translate}}" ng-disabled="attribute.filters.length < 2"><span class="black"><i class="fa fa-trash-o"></i></span></button>
- </div>
+ <div class="filter-value" ng-show="attribute.operator === defaultOperators[0]">
+ <input type="number" placeholder="{{'exact_value'| translate}}" class="form-control-select2" ng-model="attribute.exactValue"/>
+ </div>
+ <div class="filter-value" ng-show="attribute.operator === defaultOperators[1]">
+ <div class="container-1-2">
+ <input type="number" placeholder="{{'from'| translate}}" class="form-control-select2" ng-model="attribute.startValue"/>
+ </div>
+ <div class="container-1-2">
+ <input type="number" placeholder="{{'to'| translate}}" class="form-control-select2" ng-model="attribute.endValue"/>
+ </div>
+ </div>
</div>
</div>
<div ng-switch-when="date">
<div class="dataelement-filter">
- <div class="container-1-2">
- <input type="text" placeholder="{{'from'| translate}}" class="form-control-select2" ng-date ng-model="attribute.startDate"/>
- </div>
- <div class="container-1-2">
- <input type="text" placeholder="{{'to'| translate}}" class="form-control-select2" ng-date ng-model="attribute.endDate"/>
- </div>
+ <div class="filter-operator">
+ <select ng-model="attribute.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
+ </select>
+ </div>
+ <div class="filter-value" ng-show="attribute.operator === defaultOperators[0]">
+ <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.exactValue"/>
+ </div>
+ <div class="filter-value" ng-show="attribute.operator === defaultOperators[1]">
+ <div class="container-1-2">
+ <input type="text" placeholder="{{'start_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.startValue"/>
+ </div>
+ <div class="container-1-2">
+ <input type="text" placeholder="{{'end_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.endValue"/>
+ </div>
+ </div>
</div>
</div>
<div ng-switch-when="string">
@@ -65,7 +85,7 @@
</div>
<div ng-switch-when="bool">
<select multiple ui-select2 ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
- <option ng-repeat="option in boolOperands" value="{{option}}">{{option}}</option>
+ <option ng-repeat="option in boolOperators" value="{{option}}">{{option}}</option>
</select>
</div>
</div>