Skip to content

Commit

Permalink
update exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewoestreich committed Jan 22, 2021
1 parent fddb850 commit 8be5cc8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 40 deletions.
1 change: 0 additions & 1 deletion __tests__/MTableFilterRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('MTableFilterRow Tests', () => {
);
const els = Array.from(wrapper.find('#m--table--filter--row')) || [];
const el = els[0];
console.log(el.find('#m--table--filter--row'));
expect(TABLE_REF.current.dataManager.filtered).toBe(true);
});
});
24 changes: 12 additions & 12 deletions exporters/csv.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { CsvBuilder } from 'filefy';

export default function ExportCsv(
columns,
data,
filename = 'data',
delimiter = ','
) {
import('filefy')
.then(({ CsvBuilder }) => {
const builder = new CsvBuilder(filename + '.csv');
builder
.setDelimeter(delimiter)
.setColumns(columns.map((col) => col.title))
.addRows(Array.from(data))
.exportFile();
})
.catch((err) => {
console.error(`exporting csv : unable to import 'filefy' : ${err}`);
});
try {
const builder = new CsvBuilder(filename + '.csv');
builder
.setDelimeter(delimiter)
.setColumns(columns.map((col) => col.title))
.addRows(Array.from(data))
.exportFile();
} catch (err) {
console.err(`err in ExportCsv : ${err}`);
}
}
49 changes: 24 additions & 25 deletions exporters/pdf.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import 'jspdf-autotable';

export default function ExportPdf(columns, data, filename = 'data') {
import('jspdf-autotable')
.then(() => {
const JSpdf =
typeof window !== 'undefined' ? require('jspdf').jsPDF : null;
if (JSpdf !== null) {
const content = {
startY: 50,
head: [columns.map((col) => col.title)],
body: data
};
const unit = 'pt';
const size = 'A4';
const orientation = 'landscape';
const doc = new JSpdf(orientation, unit, size);
doc.setFontSize(15);
doc.text(filename, 40, 40);
doc.autoTable(content);
doc.save(filename + '.pdf');
}
})
.catch((err) => {
console.error(
`exporting pdf : unable to import 'jspdf-autotable' : ${err}`
);
});
try {
const JSpdf = typeof window !== 'undefined' ? require('jspdf').jsPDF : null;
if (JSpdf !== null) {
const content = {
startY: 50,
head: [columns.map((col) => col.title)],
body: data
};
const unit = 'pt';
const size = 'A4';
const orientation = 'landscape';
const doc = new JSpdf(orientation, unit, size);
doc.setFontSize(15);
doc.text(filename, 40, 40);
doc.autoTable(content);
doc.save(filename + '.pdf');
}
} catch (err) {
console.error(
`exporting pdf : unable to import 'jspdf-autotable' : ${err}`
);
}
}
1 change: 0 additions & 1 deletion src/components/MTableToolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function MTableToolbar(props) {
}

function renderDefaultActions() {
console.log('renderDefaultActions', { props });
const localization = {
...MTableToolbar.defaultProps.localization,
...props.localization
Expand Down
1 change: 0 additions & 1 deletion src/components/m-table-body-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default class MTableBodyRow extends React.Component {
}

const key = `cell-${this.props.data.tableData.id}-${columnDef.tableData.id}`;
console.log(`rendering cell ${key}`, { props: this.props });

return (
<this.props.components.Cell
Expand Down

0 comments on commit 8be5cc8

Please sign in to comment.