dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29034
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14598: grid filtering for numbers has now lower and upper limits
------------------------------------------------------------
revno: 14598
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-04-02 11:11:11 +0200
message:
grid filtering for numbers has now lower and upper limits
modified:
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/directives.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js
--
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-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-03-31 08:29:08 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-04-02 09:11:11 +0000
@@ -57,6 +57,8 @@
"periods": "Periods",
"start_date": "Start date",
"end_date": "End date",
+ "lower_limit": "Lower limit",
+ "upper_limit": "Upper limit",
"please_select": "[Please Select]",
"not_selected": "NOT_SELECTED",
"search": "Search",
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html 2014-04-02 06:12:40 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html 2014-04-02 09:11:11 +0000
@@ -1,5 +1,6 @@
<!DOCTYPE html>
-<html manifest="event-capture.appcache" ng-app="eventCapture">
+<!--<html manifest="event-capture.appcache" ng-app="eventCapture">-->
+<html ng-app="eventCapture">
<head>
<title>Event Capture</title>
@@ -44,7 +45,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
- <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
+ <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
<script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
@@ -181,30 +182,36 @@
<!-- filter icon begins -->
<span class='pull-right'>
- <span ng-show="eventGridColumn.type !=='date'">
+ <span ng-show="eventGridColumn.type !='date' && eventGridColumn.type !='int'">
<a href ng-click="searchInGrid(eventGridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [filterText[eventGridColumn.id] == undefined || filterText[eventGridColumn.id] == '']"><i class="fa fa-search"></i></span></a>
</span>
- <span ng-show="eventGridColumn.type ==='date'">
+ <span ng-show="eventGridColumn.type ==='date' || eventGridColumn.type ==='int'">
<a href ng-click="searchInGrid(eventGridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [(filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == '') && (filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == '')]"><i class="fa fa-search"></i></span></a>
</span>
</span>
<!-- filter icon ends -->
<!-- filter input field begins -->
- <span ng-show="eventGridColumn.showFilter">
- <span ng-show="eventGridColumn.type !=='date'">
- <input type="text" style="width: 90%;" ng-model="filterText[eventGridColumn.id]" ng-blur="searchInGrid(eventGridColumn)">
+ <span ng-show="eventGridColumn.showFilter">
+ <span ng-switch="eventGridColumn.type">
+ <span ng-switch-when="int">
+ <input style="width: 45%;" placeholder="{{'lower_limit' | translate}}" type="number" ng-model="filterText[eventGridColumn.id].start" ng-blur="searchInGrid(eventGridColumn)">
+ <input style="width: 45%;" placeholder="{{'upper_limit' | translate}}" type="number" ng-model="filterText[eventGridColumn.id].end" ng-blur="searchInGrid(eventGridColumn)">
+ </span>
+ <span ng-switch-when="date">
+ <input style="width: 70%;" placeholder="{{'start_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].start" data-ng-date readonly="readonly">
+ <span ng-hide="filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == ''">
+ <a href ng-click='removeStartFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>
+ </span>
+ <input style="width: 70%;" placeholder="{{'end_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].end" data-ng-date readonly="readonly">
+ <span ng-hide="filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == ''">
+ <a href ng-click='removeEndFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>
+ </span>
+ </span>
+ <span ng-switch-default>
+ <input type="text" style="width: 90%;" ng-model="filterText[eventGridColumn.id]" ng-blur="searchInGrid(eventGridColumn)">
+ </span>
</span>
- <span ng-show="eventGridColumn.type ==='date'">
- <input style="width: 70%;" placeholder="{{'start_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].start" data-ng-date readonly="readonly">
- <span ng-hide="filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == ''">
- <a href ng-click='removeStartFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>
- </span>
- <input style="width: 70%;" placeholder="{{'end_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].end" data-ng-date readonly="readonly">
- <span ng-hide="filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == ''">
- <a href ng-click='removeEndFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>
- </span>
- </span>
</span>
<!-- filter input field ends -->
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-04-02 06:12:40 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-04-02 09:11:11 +0000
@@ -118,10 +118,9 @@
$scope.filterTypes[dataElement.id] = dataElement.type;
- if(dataElement.type === 'date'){
+ if(dataElement.type === 'date' || dataElement.type === 'int' ){
$scope.filterText[dataElement.id]= {};
}
- //$scope.filterText[dataElement.id]= '';
});
@@ -142,7 +141,6 @@
Paginator.setPageCount($scope.pager.pageCount);
Paginator.setPageSize($scope.pager.pageSize);
Paginator.setItemCount($scope.pager.total);
-
}
//process event list for easier tabular sorting
@@ -383,9 +381,6 @@
var newValue = currentEvent[dataElement];
var oldValue = $scope.currentEventOrginialValue[dataElement];
- console.log('old: ', oldValue);
- console.log('new: ', newValue);
-
//check for form validity
$scope.outerForm.submitted = true;
if( $scope.outerForm.$invalid ){
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-03-31 08:29:08 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-04-02 09:11:11 +0000
@@ -150,16 +150,6 @@
};
})
-.directive('serversidePaginator', function factory() {
- return {
- restrict: 'E',
- controller: function ($scope, Paginator) {
- $scope.paginator = Paginator;
- },
- templateUrl: 'views/serverside-pagination.html'
- };
-})
-
.directive('draggableModal', function(){
return {
restrict: 'EA',
@@ -169,6 +159,16 @@
};
})
+.directive('serversidePaginator', function factory() {
+ return {
+ restrict: 'E',
+ controller: function ($scope, Paginator) {
+ $scope.paginator = Paginator;
+ },
+ templateUrl: 'views/serverside-pagination.html'
+ };
+})
+
.directive('clientsidePaginator', function factory() {
return {
restrict: 'E',
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js 2014-04-02 08:26:45 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js 2014-04-02 09:11:11 +0000
@@ -19,6 +19,7 @@
var dateFilter = {},
textFilter = {},
+ numberFilter = {},
filteredData = data;
for(var key in filters){
@@ -28,17 +29,19 @@
dateFilter[key] = filters[key];
}
}
- else if(filterTypes[key] === 'date'){
-
+ else if(filterTypes[key] === 'int'){
+ if(filters[key].start || filters[key].end){
+ numberFilter[key] = filters[key];
+ }
}
else{
textFilter[key] = filters[key];
}
}
- filteredData = $filter('filter')(filteredData, textFilter);
-
+ filteredData = $filter('filter')(filteredData, textFilter);
filteredData = $filter('filter')(filteredData, dateFilter, dateComparator);
+ filteredData = $filter('filter')(filteredData, numberFilter, numberComparator);
return filteredData;
}
@@ -54,6 +57,16 @@
}
return ( Date.parse(date) <= Date.parse(end) ) || (Date.parse(date) >= Date.parse(start));
}
+
+ function numberComparator(data,filter){
+ var start = filter.start;
+ var end = filter.end;
+
+ if(filter.start && filter.end){
+ return ( data <= end ) && ( data >= start );
+ }
+ return ( data <= end ) || ( data >= start );
+ }
})
.filter('paginate', function(Paginator) {