Skip to content

Commit

Permalink
reset filtered column if it's been deselected from the column selector
Browse files Browse the repository at this point in the history
  • Loading branch information
iamisti committed Oct 24, 2016
1 parent 097879c commit 8a8c595
Show file tree
Hide file tree
Showing 6 changed files with 732 additions and 667 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@
}
};

service.resetFiltersForColumn = function(dataStorage, index){
if(dataStorage.header[index].columnFilter
&& dataStorage.header[index].columnFilter.isEnabled
&& dataStorage.header[index].columnFilter.filtersApplied.length){

dataStorage.header[index].columnFilter.filtersApplied = [];

return true;
}

return false;
};

/**
* Set the position of the column filter panel. It's required to attach it to the outer container
* of the component because otherwise some parts of the panel can became partially or fully hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
var rt = ($(window).width() - (elementPosition.left + elementToPosition.outerWidth()));

var targetMetrics = {
top: elementPosition.top + 60,
top: elementPosition.top + 55,
right: rt
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
'use strict';

function mdtColumnSelectorDirective(ColumnSelectorFeature){
function mdtColumnSelectorDirective(ColumnSelectorFeature, ColumnFilterFeature, PaginatorTypeProvider){
return{
restrict: 'E',
templateUrl: '/main/templates/mdtColumnSelector.html',
Expand Down Expand Up @@ -79,12 +79,31 @@
return result ? false : true;
};

$scope.confirmCallback = function(){
$scope.confirmCallback = function(params){
var paginator = params.paginator;
var isAnyResetHappened = false;

_.each($scope.dataStorage.header, function(item, index){
item.columnSelectorFeature.isVisible = $scope.headerRowsData[index].isVisible;

if(!item.columnSelectorFeature.isVisible){
var result = ColumnFilterFeature.resetFiltersForColumn($scope.dataStorage, index);

if(result){
isAnyResetHappened = true;
}
}
});

$scope.columnSelectorFeature.isActive = false;

if(isAnyResetHappened){
if(paginator.paginatorType === PaginatorTypeProvider.AJAX){
paginator.getFirstPage();
}else{
// no support for non-ajax yet
}
}
};

$scope.cancelCallback = function(){
Expand Down
2 changes: 1 addition & 1 deletion app/modules/main/templates/mdtColumnSelector.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>

<div class="p-b-sm p-t-sm p-l-sm" layout="row" layout-align="start center">
<md-button class="md-raised md-primary" ng-click="confirmCallback()">Ok</md-button>
<md-button class="md-raised md-primary" ng-click="confirmCallback({paginator: mdtPaginationHelper})">Ok</md-button>
<md-button class="md-raised" ng-click="cancelCallback()">Cancel</md-button>
</div>
</md-content>
Expand Down
2 changes: 1 addition & 1 deletion dist/md-data-table-templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a8c595

Please sign in to comment.