fixes issue #1999 - Use Object name as default export filename (#2001)

* fixes issue #1999
add dynamic name(object name) to exportAsCSV filename

* make requested changes
This commit is contained in:
Deep Tailor 2018-05-16 13:20:58 -07:00 committed by Pete Richards
parent 28311fd4dd
commit fab1def790
3 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,7 @@
enableSort="true" enableSort="true"
auto-scroll="autoScroll" auto-scroll="autoScroll"
default-sort="defaultSort" default-sort="defaultSort"
export-as="{{ exportAs }}"
class="tabular-holder has-control-bar"> class="tabular-holder has-control-bar">
</mct-table> </mct-table>
</div> </div>

View File

@ -88,13 +88,18 @@ define(
setDefaults($scope); setDefaults($scope);
$scope.exportAsCSV = function () { $scope.exportAsCSV = function () {
var headers = $scope.displayHeaders; var headers = $scope.displayHeaders,
filename = $(element[0]).attr('export-as');
exportService.exportCSV($scope.displayRows.map(function (row) { exportService.exportCSV($scope.displayRows.map(function (row) {
return headers.reduce(function (r, header) { return headers.reduce(function (r, header) {
r[header] = row[header].text; r[header] = row[header].text;
return r; return r;
}, {}); }, {});
}), { headers: headers }); }), {
headers: headers,
filename: filename
});
}; };
$scope.toggleSort = function (key) { $scope.toggleSort = function (key) {

View File

@ -78,6 +78,8 @@ define(
this.domainObject = objectUtils.toNewFormat($scope.domainObject.getModel(), this.domainObject = objectUtils.toNewFormat($scope.domainObject.getModel(),
$scope.domainObject.getId()); $scope.domainObject.getId());
this.$scope.exportAs = this.$scope.domainObject.getModel().name;
_.bindAll(this, [ _.bindAll(this, [
'destroy', 'destroy',
'sortByTimeSystem', 'sortByTimeSystem',