Skip to content

Commit

Permalink
Merge pull request #467 from marmelab/fix_firefox_export_csv
Browse files Browse the repository at this point in the history
[RFR] Fix export CSV in firefox
  • Loading branch information
jeromemacias committed May 26, 2015
2 parents d4d7c65 + 5a70544 commit 0573022
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ define(function () {
notification.log(error.message, {addnCls: 'humane-flatty-error'});
})
.then(function (rawEntries) {
nonOptimizedReferencedData = ReadQueries.getFilteredReferenceData(exportView.getNonOptimizedReferences(), rawEntries);

return rawEntries;
return ReadQueries.getFilteredReferenceData(exportView.getNonOptimizedReferences(), rawEntries);
})
.then(function (rawEntries) {
optimizedReferencedData = ReadQueries.getOptimizedReferencedData(exportView.getOptimizedReferences(), rawEntries);
.then(function (nonOptimizedReference) {
nonOptimizedReferencedData = nonOptimizedReference;

return rawEntries;
return ReadQueries.getOptimizedReferencedData(exportView.getOptimizedReferences(), rawEntries);
})
.then(function (rawEntries) {
.then(function (optimizedReference) {
optimizedReferencedData = optimizedReference;

var references = exportView.getReferences(),
referencedData = angular.extend(nonOptimizedReferencedData, optimizedReferencedData),
referencedEntries;
Expand All @@ -72,10 +72,8 @@ define(function () {
referencedEntries
);
}

return rawEntries;
})
.then(function (rawEntries) {
.then(function () {
var entries = scope.datastore.mapEntries(
exportView.entity.name(),
exportView.identifier(),
Expand All @@ -92,14 +90,14 @@ define(function () {
}
var csv = Papa.unparse(results);
var fakeLink = document.createElement('a');
document.body.appendChild(fakeLink);

fakeLink.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(csv));
fakeLink.setAttribute('download', scope.entity.name() + '.csv');
fakeLink.click();
})
;
});
};
},
}
};
}

Expand Down

0 comments on commit 0573022

Please sign in to comment.