Skip to content

Commit

Permalink
feat(core): Add Clear all filters to grid menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mboriani committed Aug 12, 2015
1 parent 6205b8c commit 77ffba5
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 105 deletions.
32 changes: 16 additions & 16 deletions src/features/cellnav/test/uiGridCellNavService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,20 @@ describe('ui.grid.edit uiGridCellNavService', function () {

describe('scrollTo', function () {
/*
* We have 11 rows (10 visible) and 11 columns (10 visible). The column widths are
* We have 11 rows (10 visible) and 11 columns (10 visible). The column widths are
* 100 for the first 5, and 200 for the second 5. Column 2 and row 2 are invisible.
*/
var evt;
var args;
var $scope;

beforeEach(function(){
var i, j, row;
grid.options.columnDefs = [];
for ( i = 0; i < 11; i++ ){
grid.options.columnDefs.push({name: 'col' + i});
}

grid.options.data = [];
for ( i = 0; i < 11; i++ ){
row = {};
Expand All @@ -184,16 +184,16 @@ describe('ui.grid.edit uiGridCellNavService', function () {
}
grid.options.data.push( row );
}

uiGridCellNavService.initializeGrid(grid);
grid.modifyRows(grid.options.data);
grid.modifyRows(grid.options.data);

grid.registerColumnBuilder(uiGridCellNavService.cellNavColumnBuilder);
grid.buildColumns();

grid.columns[2].visible = false;
grid.rows[2].visible = false;

grid.setVisibleColumns(grid.columns);
grid.setVisibleRows(grid.rows);

Expand All @@ -202,14 +202,14 @@ describe('ui.grid.edit uiGridCellNavService', function () {
for ( i = 0; i < 11; i++ ){
grid.columns[i].drawnWidth = i < 6 ? 100 : 200;
}

$scope = $rootScope.$new();

args = null;
grid.api.core.on.scrollEnd($scope, function( receivedArgs ){
args = receivedArgs;
});

});


Expand All @@ -232,7 +232,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
grid.scrollTo( grid.options.data[0], null);
});
$timeout.flush();

expect(Math.round(args.y.percentage * 10)/10).toBe(0.1);
});

Expand All @@ -241,7 +241,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
grid.scrollTo( grid.options.data[10], null);
});
$timeout.flush();

expect(args.y.percentage).toBeGreaterThan(0.5);
expect(args.x).toBe(null);
});
Expand All @@ -251,7 +251,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
grid.scrollTo( grid.options.data[5], null);
});
$timeout.flush();

expect(Math.round(args.y.percentage * 10)/10).toEqual( 0.5);
expect(args.x).toBe(null);
});
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
grid.scrollTo( null, grid.columns[8].colDef);
});
$timeout.flush();

expect(isNaN(args.x.percentage)).toEqual( true );
});

Expand All @@ -290,8 +290,8 @@ describe('ui.grid.edit uiGridCellNavService', function () {
grid.scrollTo( null, null );
});
$timeout.flush();

expect(args).toEqual( null );
});
});
});
});
12 changes: 12 additions & 0 deletions src/js/core/directives/ui-grid-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ angular.module('ui.grid')
}
}

var clearFilters = [{
title: i18nService.getSafeText('gridMenu.clearAllFilters'),
action: function ($event) {
$scope.grid.clearAllFilters(undefined, true, undefined);
},
shown: function() {
return $scope.grid.options.enableFiltering;
},
order: 100
}];
menuItems = menuItems.concat( clearFilters );

menuItems = menuItems.concat( $scope.registeredMenuItems );

if ( $scope.grid.options.gridMenuShowHideColumns !== false ){
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Exportovat vybranné data do csv',
exporterAllAsPdf: 'Exportovat všechny data do pdf',
exporterVisibleAsPdf: 'Exportovat viditelné data do pdf',
exporterSelectedAsPdf: 'Exportovat vybranné data do pdf'
exporterSelectedAsPdf: 'Exportovat vybranné data do pdf',
clearAllFilters: 'Vyčistěte všechny filtry'
},
importer: {
noHeaders: 'Názvy sloupců se nepodařilo získat, obsahuje soubor záhlaví?',
Expand Down
5 changes: 3 additions & 2 deletions src/js/i18n/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
exporterSelectedAsCsv: 'Export selected data as csv',
exporterAllAsPdf: 'Export all data as pdf',
exporterVisibleAsPdf: 'Export visible data as pdf',
exporterSelectedAsPdf: 'Export selected data as pdf'
exporterSelectedAsPdf: 'Export selected data as pdf',
clearAllFilters: 'Clear all filters'
},
importer: {
noHeaders: 'Column names were unable to be derived, does the file have a header?',
Expand All @@ -53,4 +54,4 @@
return $delegate;
}]);
}]);
})();
})();
3 changes: 2 additions & 1 deletion src/js/i18n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'markierte Daten als CSV exportieren',
exporterAllAsPdf: 'Alle Daten als PDF exportieren',
exporterVisibleAsPdf: 'sichtbare Daten als PDF exportieren',
exporterSelectedAsPdf: 'markierte Daten als CSV exportieren'
exporterSelectedAsPdf: 'markierte Daten als CSV exportieren',
clearAllFilters: 'Alle filter reinigen'
},
importer: {
noHeaders: 'Es konnten keine Spaltennamen ermittelt werden. Sind in der Datei Spaltendefinitionen enthalten?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
exporterSelectedAsCsv: 'Export selected data as csv',
exporterAllAsPdf: 'Export all data as pdf',
exporterVisibleAsPdf: 'Export visible data as pdf',
exporterSelectedAsPdf: 'Export selected data as pdf'
exporterSelectedAsPdf: 'Export selected data as pdf',
clearAllFilters: 'Clear all filters'
},
importer: {
noHeaders: 'Column names were unable to be derived, does the file have a header?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: 'Exportar selección como csv',
exporterAllAsPdf: 'Exportar todo como pdf',
exporterVisibleAsPdf: 'Exportar vista como pdf',
exporterSelectedAsPdf: 'Exportar selección como pdf'
exporterSelectedAsPdf: 'Exportar selección como pdf',
clearAllFilters: 'Limpiar todos los filtros'
},
importer: {
noHeaders: 'No fue posible derivar los nombres de las columnas, ¿tiene encabezados el archivo?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/fa.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
exporterSelectedAsCsv: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل csv',
exporterAllAsPdf: 'خروجی تمام داده\u200cها در فایل pdf',
exporterVisibleAsPdf: 'خروجی داده\u200cهای قابل مشاهده در فایل pdf',
exporterSelectedAsPdf: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل pdf'
exporterSelectedAsPdf: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل pdf',
clearAllFilters: 'پاک کردن تمام فیلتر'
},
importer: {
noHeaders: 'نام ستون قابل استخراج نیست. آیا فایل عنوان دارد؟',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Vie valittu tieto csv-muodossa',
exporterAllAsPdf: 'Vie tiedot pdf-muodossa',
exporterVisibleAsPdf: 'Vie näkyvä tieto pdf-muodossa',
exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa'
exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa',
clearAllFilters: 'Puhdista kaikki suodattimet'
},
importer: {
noHeaders: 'Sarakkeen nimiä ei voitu päätellä, onko tiedostossa otsikkoriviä?',
Expand Down
5 changes: 3 additions & 2 deletions src/js/i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: 'Exporter les données sélectionnées en CSV',
exporterAllAsPdf: 'Exporter toutes les données en PDF',
exporterVisibleAsPdf: 'Exporter les données visibles en PDF',
exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF'
exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF',
clearAllFilters: 'Nettoyez tous les filtres'
},
importer: {
noHeaders: 'Impossible de déterminer le nom des colonnes, le fichier possède-t-il une en-tête ?',
Expand Down Expand Up @@ -78,4 +79,4 @@
return $delegate;
}]);
}]);
})();
})();
5 changes: 3 additions & 2 deletions src/js/i18n/he.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
exporterSelectedAsCsv: 'Export selected data as csv',
exporterAllAsPdf: 'Export all data as pdf',
exporterVisibleAsPdf: 'Export visible data as pdf',
exporterSelectedAsPdf: 'Export selected data as pdf'
exporterSelectedAsPdf: 'Export selected data as pdf',
clearAllFilters: 'Clean all filters'
},
importer: {
noHeaders: 'Column names were unable to be derived, does the file have a header?',
Expand All @@ -61,4 +62,4 @@
return $delegate;
}]);
}]);
})();
})();
3 changes: 2 additions & 1 deletion src/js/i18n/hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Արտահանել ընտրված տվյալները CSV',
exporterAllAsPdf: 'Արտահանել PDF',
exporterVisibleAsPdf: 'Արտահանել երևացող տվյալները PDF',
exporterSelectedAsPdf: 'Արտահանել ընտրված տվյալները PDF'
exporterSelectedAsPdf: 'Արտահանել ընտրված տվյալները PDF',
clearAllFilters: 'Մաքրել բոլոր ֆիլտրերը'
},
importer: {
noHeaders: 'Հնարավոր չեղավ որոշել սյան վերնագրերը։ Արդյո՞ք ֆայլը ունի վերնագրեր։',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Esporta i dati selezionati in CSV',
exporterAllAsPdf: 'Esporta tutti i dati in PDF',
exporterVisibleAsPdf: 'Esporta i dati visibili in PDF',
exporterSelectedAsPdf: 'Esporta i dati selezionati in PDF'
exporterSelectedAsPdf: 'Esporta i dati selezionati in PDF',
clearAllFilters: 'Pulire tutti i filtri'
},
importer: {
noHeaders: 'Impossibile reperire i nomi delle colonne, sicuro che siano indicati all\'interno del file?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: '選択したデータをCSV形式でエクスポート',
exporterAllAsPdf: 'すべてのデータをPDF形式でエクスポート',
exporterVisibleAsPdf: '表示中のデータをPDF形式でエクスポート',
exporterSelectedAsPdf: '選択したデータをPDF形式でエクスポート'
exporterSelectedAsPdf: '選択したデータをPDF形式でエクスポート',
clearAllFilters: 'すべてのフィルタを清掃してください'
},
importer: {
noHeaders: '列名を取得できません。ファイルにヘッダが含まれていることを確認してください。',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: 'csv로 선택된 데이터 내보내기',
exporterAllAsPdf: 'pdf로 모든 데이터 내보내기',
exporterVisibleAsPdf: 'pdf로 보이는 데이터 내보내기',
exporterSelectedAsPdf: 'pdf로 선택 데이터 내보내기'
exporterSelectedAsPdf: 'pdf로 선택 데이터 내보내기',
clearAllFilters: '모든 필터를 청소'
},
importer: {
noHeaders: '컬럼명이 지정되어 있지 않습니다. 파일에 헤더가 명시되어 있는지 확인해 주세요.',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: 'Exporteer geselecteerde data als csv',
exporterAllAsPdf: 'Exporteer alle data als pdf',
exporterVisibleAsPdf: 'Exporteer zichtbare data als pdf',
exporterSelectedAsPdf: 'Exporteer geselecteerde data als pdf'
exporterSelectedAsPdf: 'Exporteer geselecteerde data als pdf',
clearAllFilters: 'Reinig alle filters'
},
importer: {
noHeaders: 'Kolomnamen kunnen niet worden afgeleid. Heeft het bestand een header?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/pt-br.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Exportar dados selecionados como csv',
exporterAllAsPdf: 'Exportar todos os dados como pdf',
exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',
exporterSelectedAsPdf: 'Exportar dados selecionados como pdf'
exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',
clearAllFilters: 'Limpar todos os filtros'
},
importer: {
noHeaders: 'Nomes de colunas não puderam ser derivados. O arquivo tem um cabeçalho?',
Expand Down
5 changes: 3 additions & 2 deletions src/js/i18n/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: 'Exportar dados selecionados como csv',
exporterAllAsPdf: 'Exportar todos os dados como pdf',
exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',
exporterSelectedAsPdf: 'Exportar dados selecionados como pdf'
exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',
clearAllFilters: 'Limpar todos os filtros'
},
importer: {
noHeaders: 'Nomes de colunas não puderam ser derivados. O ficheiro tem um cabeçalho?',
Expand All @@ -73,7 +74,7 @@
aggregate_min: 'Agr: Min',
aggregate_avg: 'Agr: Med',
aggregate_remove: 'Agr: Remover'
}
}
});
return $delegate;
}]);
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
exporterSelectedAsCsv: 'Экспортировать выбранные данные в CSV',
exporterAllAsPdf: 'Экспортировать всё в PDF',
exporterVisibleAsPdf: 'Экспортировать видимые данные в PDF',
exporterSelectedAsPdf: 'Экспортировать выбранные данные в PDF'
exporterSelectedAsPdf: 'Экспортировать выбранные данные в PDF',
clearAllFilters: 'Очистите все фильтры'
},
importer: {
noHeaders: 'Column names were unable to be derived, does the file have a header?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
exporterSelectedAsCsv: 'Export selected data as csv',
exporterAllAsPdf: 'Export all data as pdf',
exporterVisibleAsPdf: 'Export visible data as pdf',
exporterSelectedAsPdf: 'Export selected data as pdf'
exporterSelectedAsPdf: 'Export selected data as pdf',
clearAllFilters: 'Clear all filters'
},
importer: {
noHeaders: 'Column names were unable to be derived, does the file have a header?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'Exportera markerad data som CSV',
exporterAllAsPdf: 'Exportera all data som PDF',
exporterVisibleAsPdf: 'Exportera synlig data som PDF',
exporterSelectedAsPdf: 'Exportera markerad data som PDF'
exporterSelectedAsPdf: 'Exportera markerad data som PDF',
clearAllFilters: 'Rengör alla filter'
},
importer: {
noHeaders: 'Kolumnnamn kunde inte härledas. Har filen ett sidhuvud?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/ta.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
exporterSelectedAsCsv: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: csv',
exporterAllAsPdf: 'எல்லா தரவுகளையும் கோப்பாக்கு: pdf',
exporterVisibleAsPdf: 'இருக்கும் தரவுகளை கோப்பாக்கு: pdf',
exporterSelectedAsPdf: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: pdf'
exporterSelectedAsPdf: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: pdf',
clearAllFilters: 'Clear all filters'
},
importer: {
noHeaders: 'பத்தியின் தலைப்புகளை பெற இயலவில்லை, கோப்பிற்கு தலைப்பு உள்ளதா?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: '导出已选数据到CSV',
exporterAllAsPdf: '导出全部数据到PDF',
exporterVisibleAsPdf: '导出可见数据到PDF',
exporterSelectedAsPdf: '导出已选数据到PDF'
exporterSelectedAsPdf: '导出已选数据到PDF',
clearAllFilters: '清除所有过滤器'
},
importer: {
noHeaders: '无法获取列名,确定文件包含表头?',
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/zh-tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
exporterSelectedAsCsv: '導出已選數據到CSV',
exporterAllAsPdf: '導出全部數據到PDF',
exporterVisibleAsPdf: '導出可見數據到PDF',
exporterSelectedAsPdf: '導出已選數據到PDF'
exporterSelectedAsPdf: '導出已選數據到PDF',
clearAllFilters: '清除所有过滤器'
},
importer: {
noHeaders: '無法獲取列名,確定文件包含表頭?',
Expand Down
Loading

0 comments on commit 77ffba5

Please sign in to comment.