Skip to content

Commit 81191a0

Browse files
committed
Fix(exporter): fix #3403 rename exporterAllDataPromise to exporterAllDataFn
1 parent a9d81f7 commit 81191a0

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

misc/tutorial/405_exporting_all_data_complex.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This shows combined external pagination and sorting.
3232
{ name: 'gender', enableSorting: false },
3333
{ name: 'company', enableSorting: false }
3434
],
35-
exporterAllDataPromise: function() {
35+
exporterAllDataFn: function() {
3636
return getPage(1, $scope.gridOptions.totalItems, paginationOptions.sort)
3737
.then(function() {
3838
$scope.gridOptions.useExternalPagination = false;

src/features/exporter/js/exporter.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,41 @@
464464

465465
/**
466466
* @ngdoc function
467-
* @name exporterAllDataPromise
467+
* @name exporterAllDataFn
468468
* @propertyOf ui.grid.exporter.api:GridOptions
469469
* @description This promise is needed when exporting all rows,
470470
* and the data need to be provided by server side. Default is null.
471471
* @returns {Promise} a promise to load all data from server
472472
*
473473
* @example
474474
* <pre>
475-
* gridOptions.exporterAllDataPromise = function () {
475+
* gridOptions.exporterAllDataFn = function () {
476476
* return $http.get('/data/100.json')
477477
* }
478478
* </pre>
479479
*/
480-
gridOptions.exporterAllDataPromise = gridOptions.exporterAllDataPromise ? gridOptions.exporterAllDataPromise : null;
480+
gridOptions.exporterAllDataFn = gridOptions.exporterAllDataFn ? gridOptions.exporterAllDataFn : null;
481+
482+
/**
483+
* @ngdoc function
484+
* @name exporterAllDataPromise
485+
* @propertyOf ui.grid.exporter.api:GridOptions
486+
* @description DEPRECATED - exporterAllDataFn used to be
487+
* called this, but it wasn't a promise, it was a function that returned
488+
* a promise. Deprecated, but supported for backward compatibility, use
489+
* exporterAllDataFn instead.
490+
* @returns {Promise} a promise to load all data from server
491+
*
492+
* @example
493+
* <pre>
494+
* gridOptions.exporterAllDataFn = function () {
495+
* return $http.get('/data/100.json')
496+
* }
497+
* </pre>
498+
*/
499+
if ( gridOptions.exporterAllDataFn == null && gridOptions.exporterAllDataPromise ) {
500+
gridOptions.exporterAllDataFn = gridOptions.exporterAllDataPromise;
501+
}
481502
},
482503

483504

@@ -586,7 +607,7 @@
586607
* @ngdoc function
587608
* @name loadAllDataIfNeeded
588609
* @methodOf ui.grid.exporter.service:uiGridExporterService
589-
* @description When using server side pagination, use exportAllDataPromise to
610+
* @description When using server side pagination, use exporterAllDataFn to
590611
* load all data before continuing processing.
591612
* When using client side pagination, return a resolved promise so processing
592613
* continues immediately
@@ -599,8 +620,8 @@
599620
* uiGridExporterConstants.SELECTED
600621
*/
601622
loadAllDataIfNeeded: function (grid, rowTypes, colTypes) {
602-
if ( rowTypes === uiGridExporterConstants.ALL && grid.rows.length !== grid.options.totalItems && grid.options.exporterAllDataPromise) {
603-
return grid.options.exporterAllDataPromise()
623+
if ( rowTypes === uiGridExporterConstants.ALL && grid.rows.length !== grid.options.totalItems && grid.options.exporterAllDataFn) {
624+
return grid.options.exporterAllDataFn()
604625
.then(function() {
605626
grid.modifyRows(grid.options.data);
606627
});

src/features/exporter/test/exporter.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ describe('ui.grid.exporter uiGridExporterService', function () {
8484
exporterMenuCsv: true,
8585
exporterMenuPdf: true,
8686
exporterFieldCallback: jasmine.any(Function),
87-
exporterAllDataPromise: null,
87+
exporterAllDataFn: null,
8888
exporterSuppressColumns: []
8989
});
9090
});
9191

92-
it('set all options to non-default', function() {
92+
iit('set all options to non-default, including using deprecated exporterAllDataPromise', function() {
9393
var callback = function() {};
9494
options = {
9595
exporterSuppressMenu: true,
@@ -135,6 +135,7 @@ describe('ui.grid.exporter uiGridExporterService', function () {
135135
exporterMenuCsv: false,
136136
exporterMenuPdf: false,
137137
exporterFieldCallback: callback,
138+
exporterAllDataFn: callback,
138139
exporterAllDataPromise: callback,
139140
exporterSuppressColumns: [ 'buttons' ]
140141
});

0 commit comments

Comments
 (0)