Skip to content

Commit 77ffba5

Browse files
committed
feat(core): Add Clear all filters to grid menu
1 parent 6205b8c commit 77ffba5

File tree

26 files changed

+143
-105
lines changed

26 files changed

+143
-105
lines changed

src/features/cellnav/test/uiGridCellNavService.spec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,20 @@ describe('ui.grid.edit uiGridCellNavService', function () {
162162

163163
describe('scrollTo', function () {
164164
/*
165-
* We have 11 rows (10 visible) and 11 columns (10 visible). The column widths are
165+
* We have 11 rows (10 visible) and 11 columns (10 visible). The column widths are
166166
* 100 for the first 5, and 200 for the second 5. Column 2 and row 2 are invisible.
167167
*/
168168
var evt;
169169
var args;
170170
var $scope;
171-
171+
172172
beforeEach(function(){
173173
var i, j, row;
174174
grid.options.columnDefs = [];
175175
for ( i = 0; i < 11; i++ ){
176176
grid.options.columnDefs.push({name: 'col' + i});
177177
}
178-
178+
179179
grid.options.data = [];
180180
for ( i = 0; i < 11; i++ ){
181181
row = {};
@@ -184,16 +184,16 @@ describe('ui.grid.edit uiGridCellNavService', function () {
184184
}
185185
grid.options.data.push( row );
186186
}
187-
187+
188188
uiGridCellNavService.initializeGrid(grid);
189-
grid.modifyRows(grid.options.data);
190-
189+
grid.modifyRows(grid.options.data);
190+
191191
grid.registerColumnBuilder(uiGridCellNavService.cellNavColumnBuilder);
192192
grid.buildColumns();
193-
193+
194194
grid.columns[2].visible = false;
195195
grid.rows[2].visible = false;
196-
196+
197197
grid.setVisibleColumns(grid.columns);
198198
grid.setVisibleRows(grid.rows);
199199

@@ -202,14 +202,14 @@ describe('ui.grid.edit uiGridCellNavService', function () {
202202
for ( i = 0; i < 11; i++ ){
203203
grid.columns[i].drawnWidth = i < 6 ? 100 : 200;
204204
}
205-
205+
206206
$scope = $rootScope.$new();
207207

208208
args = null;
209209
grid.api.core.on.scrollEnd($scope, function( receivedArgs ){
210210
args = receivedArgs;
211211
});
212-
212+
213213
});
214214

215215

@@ -232,7 +232,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
232232
grid.scrollTo( grid.options.data[0], null);
233233
});
234234
$timeout.flush();
235-
235+
236236
expect(Math.round(args.y.percentage * 10)/10).toBe(0.1);
237237
});
238238

@@ -241,7 +241,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
241241
grid.scrollTo( grid.options.data[10], null);
242242
});
243243
$timeout.flush();
244-
244+
245245
expect(args.y.percentage).toBeGreaterThan(0.5);
246246
expect(args.x).toBe(null);
247247
});
@@ -251,7 +251,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
251251
grid.scrollTo( grid.options.data[5], null);
252252
});
253253
$timeout.flush();
254-
254+
255255
expect(Math.round(args.y.percentage * 10)/10).toEqual( 0.5);
256256
expect(args.x).toBe(null);
257257
});
@@ -281,7 +281,7 @@ describe('ui.grid.edit uiGridCellNavService', function () {
281281
grid.scrollTo( null, grid.columns[8].colDef);
282282
});
283283
$timeout.flush();
284-
284+
285285
expect(isNaN(args.x.percentage)).toEqual( true );
286286
});
287287

@@ -290,8 +290,8 @@ describe('ui.grid.edit uiGridCellNavService', function () {
290290
grid.scrollTo( null, null );
291291
});
292292
$timeout.flush();
293-
293+
294294
expect(args).toEqual( null );
295295
});
296296
});
297-
});
297+
});

src/js/core/directives/ui-grid-menu-button.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ angular.module('ui.grid')
190190
}
191191
}
192192

193+
var clearFilters = [{
194+
title: i18nService.getSafeText('gridMenu.clearAllFilters'),
195+
action: function ($event) {
196+
$scope.grid.clearAllFilters(undefined, true, undefined);
197+
},
198+
shown: function() {
199+
return $scope.grid.options.enableFiltering;
200+
},
201+
order: 100
202+
}];
203+
menuItems = menuItems.concat( clearFilters );
204+
193205
menuItems = menuItems.concat( $scope.registeredMenuItems );
194206

195207
if ( $scope.grid.options.gridMenuShowHideColumns !== false ){

src/js/i18n/cs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
exporterSelectedAsCsv: 'Exportovat vybranné data do csv',
5454
exporterAllAsPdf: 'Exportovat všechny data do pdf',
5555
exporterVisibleAsPdf: 'Exportovat viditelné data do pdf',
56-
exporterSelectedAsPdf: 'Exportovat vybranné data do pdf'
56+
exporterSelectedAsPdf: 'Exportovat vybranné data do pdf',
57+
clearAllFilters: 'Vyčistěte všechny filtry'
5758
},
5859
importer: {
5960
noHeaders: 'Názvy sloupců se nepodařilo získat, obsahuje soubor záhlaví?',

src/js/i18n/da.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
exporterSelectedAsCsv: 'Export selected data as csv',
4141
exporterAllAsPdf: 'Export all data as pdf',
4242
exporterVisibleAsPdf: 'Export visible data as pdf',
43-
exporterSelectedAsPdf: 'Export selected data as pdf'
43+
exporterSelectedAsPdf: 'Export selected data as pdf',
44+
clearAllFilters: 'Clear all filters'
4445
},
4546
importer: {
4647
noHeaders: 'Column names were unable to be derived, does the file have a header?',
@@ -53,4 +54,4 @@
5354
return $delegate;
5455
}]);
5556
}]);
56-
})();
57+
})();

src/js/i18n/de.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
exporterSelectedAsCsv: 'markierte Daten als CSV exportieren',
5454
exporterAllAsPdf: 'Alle Daten als PDF exportieren',
5555
exporterVisibleAsPdf: 'sichtbare Daten als PDF exportieren',
56-
exporterSelectedAsPdf: 'markierte Daten als CSV exportieren'
56+
exporterSelectedAsPdf: 'markierte Daten als CSV exportieren',
57+
clearAllFilters: 'Alle filter reinigen'
5758
},
5859
importer: {
5960
noHeaders: 'Es konnten keine Spaltennamen ermittelt werden. Sind in der Datei Spaltendefinitionen enthalten?',

src/js/i18n/en.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
exporterSelectedAsCsv: 'Export selected data as csv',
7070
exporterAllAsPdf: 'Export all data as pdf',
7171
exporterVisibleAsPdf: 'Export visible data as pdf',
72-
exporterSelectedAsPdf: 'Export selected data as pdf'
72+
exporterSelectedAsPdf: 'Export selected data as pdf',
73+
clearAllFilters: 'Clear all filters'
7374
},
7475
importer: {
7576
noHeaders: 'Column names were unable to be derived, does the file have a header?',

src/js/i18n/es.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
exporterSelectedAsCsv: 'Exportar selección como csv',
5151
exporterAllAsPdf: 'Exportar todo como pdf',
5252
exporterVisibleAsPdf: 'Exportar vista como pdf',
53-
exporterSelectedAsPdf: 'Exportar selección como pdf'
53+
exporterSelectedAsPdf: 'Exportar selección como pdf',
54+
clearAllFilters: 'Limpiar todos los filtros'
5455
},
5556
importer: {
5657
noHeaders: 'No fue posible derivar los nombres de las columnas, ¿tiene encabezados el archivo?',

src/js/i18n/fa.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
exporterSelectedAsCsv: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل csv',
5757
exporterAllAsPdf: 'خروجی تمام داده\u200cها در فایل pdf',
5858
exporterVisibleAsPdf: 'خروجی داده\u200cهای قابل مشاهده در فایل pdf',
59-
exporterSelectedAsPdf: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل pdf'
59+
exporterSelectedAsPdf: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل pdf',
60+
clearAllFilters: 'پاک کردن تمام فیلتر'
6061
},
6162
importer: {
6263
noHeaders: 'نام ستون قابل استخراج نیست. آیا فایل عنوان دارد؟',

src/js/i18n/fi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
exporterSelectedAsCsv: 'Vie valittu tieto csv-muodossa',
5454
exporterAllAsPdf: 'Vie tiedot pdf-muodossa',
5555
exporterVisibleAsPdf: 'Vie näkyvä tieto pdf-muodossa',
56-
exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa'
56+
exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa',
57+
clearAllFilters: 'Puhdista kaikki suodattimet'
5758
},
5859
importer: {
5960
noHeaders: 'Sarakkeen nimiä ei voitu päätellä, onko tiedostossa otsikkoriviä?',

src/js/i18n/fr.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
exporterSelectedAsCsv: 'Exporter les données sélectionnées en CSV',
5151
exporterAllAsPdf: 'Exporter toutes les données en PDF',
5252
exporterVisibleAsPdf: 'Exporter les données visibles en PDF',
53-
exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF'
53+
exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF',
54+
clearAllFilters: 'Nettoyez tous les filtres'
5455
},
5556
importer: {
5657
noHeaders: 'Impossible de déterminer le nom des colonnes, le fichier possède-t-il une en-tête ?',
@@ -78,4 +79,4 @@
7879
return $delegate;
7980
}]);
8081
}]);
81-
})();
82+
})();

0 commit comments

Comments
 (0)