Don't include hidden columns when downloading a table as CSV (https://github.com/woocommerce/woocommerce-admin/pull/667)

This commit is contained in:
Albert Juhé Lluveras 2018-10-24 16:26:19 +02:00 committed by GitHub
parent 2cce4e90c5
commit 1a2b28fee8
4 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/** @format */
export default `Date,Orders,Gross Revenue,Refunds,Coupons,Taxes,Shipping,Net Revenue
2018-10-01 00:00:00,1,411,0,0,0,0,411
2018-10-02 00:00:00,0,0,0,0,0,0,0`;
export default `Date,Orders,Gross Revenue,Refunds,Taxes,Shipping,Net Revenue
2018-10-01 00:00:00,1,411,0,0,0,411
2018-10-02 00:00:00,0,0,0,0,0,0`;

View File

@ -19,8 +19,8 @@ export default [
value: 0,
},
{
display: '€0.00',
value: 0,
display: '€10.00',
value: 10,
},
{
display: '€0.00',

View File

@ -83,12 +83,15 @@ class TableCard extends Component {
onClickDownload() {
const { headers, query, onClickDownload, rows, title } = this.props;
const { showCols } = this.state;
const visibleHeaders = headers.filter( ( header, i ) => showCols[ i ] );
const visibleRows = rows.map( row => row.filter( ( cell, i ) => showCols[ i ] ) );
// @TODO The current implementation only downloads the contents displayed in the table.
// Another solution is required when the data set is larger (see #311).
downloadCSVFile(
generateCSVFileName( title, query ),
generateCSVDataFromTable( headers, rows )
generateCSVDataFromTable( visibleHeaders, visibleRows )
);
if ( onClickDownload ) {

View File

@ -40,6 +40,9 @@ describe( 'TableCard', () => {
downloadable
/>
);
tableCard.setState( {
showCols: [ true, true, true, true, false, true, true, true ],
} );
const downloadButton = tableCard.findWhere(
node => node.props().className === 'woocommerce-table__download-button'