Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Export #823

Merged
merged 54 commits into from Mar 15, 2016
Merged

CSV Export #823

merged 54 commits into from Mar 15, 2016

Conversation

tylerhcarter
Copy link
Contributor

Closes #813

Adds a CSV export download link. Allows user to download any view of Stream Records. Uses the currently selected filters.

Also adds stream_records_per_page filter.

@tylerhcarter
Copy link
Contributor Author

@lukecarbis The only thing I'm not quite happy with is the page item count seems to be pushed down. I've played around with it a bit, but haven't gotten very far. Suggestions?

@@ -687,6 +690,94 @@ public function render_list_table() {
<?php
}

public function maybe_render_csv_page() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest moving the maybe_render_csv_page, render_csv_disable_paginate, and render_csv_expand_columns into their own Export class, then instantiating it as a property of Admin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I agree that this spot is more suitable for it.

}

header( 'Content-type: text/csv' );
header( 'Content-Disposition: attachment; filename="output.csv"' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's brand it: stream.csv

@lukecarbis
Copy link
Contributor

Loving the progress on this. What I'd really like to see if Exporting modularised. I'm imagining an Export class, and an Export_CSV class.

The Export class would register all the export types (filterable), and include them in the Export options at the bottom of the list table.

The Export_CSV class would look after the pagination filter, columns, and outputting the CSV file.

Basically, what I'm getting at is that it should be very easy to create an Export_JSON class without touching or duplicating any existing code.

Make sense?

@tylerhcarter
Copy link
Contributor Author

Definitely. And we might as well add that while we’re at it.

I’m thinking about having Export build a data array that adds the base data (and could be filtered) that will then be passed to the specific exporter. That way anyone could add extra information without having to rely on individual exporter implementations.

On Feb 29, 2016, at 2:20 PM, Luke Carbis notifications@github.com wrote:

Loving the progress on this. What I'd really like to see if Exporting modularised. I'm imagining an Export class, and an Export_CSV class.

The Export class would register all the export types (filterable), and include them in the Export options at the bottom of the list table.

The Export_CSV class would look after the pagination filter, columns, and outputting the CSV file.

Basically, what I'm getting at is that it should be very easy to create an Export_JSON class without touching or duplicating any existing code.

Make sense?


Reply to this email directly or view it on GitHub #823 (comment).

@tylerhcarter
Copy link
Contributor Author

Something about the copy messed up all of the tabs/indents causing Travis to fail. I'm going to have to go through and individually fix it. Will do that a little later today.

@lukecarbis
Copy link
Contributor

Great thoughts. Let's do it.

Move CSV functionality to separate class
List exporters at bottom of table
}

public function render_download() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop blank line at top of method.

@tylerhcarter
Copy link
Contributor Author

@lukecarbis Everything we've talked about is finished. I think we're ready to merge. Let me know if something is missing.

header( 'Content-Disposition: attachment; filename="stream.json"' );
}

if ( function_exists( 'wp_json_encode' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@lukecarbis
Copy link
Contributor

@Chacha Could you please review my commits above, and give me your thoughts? a900133...49c1642

@tylerhcarter
Copy link
Contributor Author

@lukecarbis Reviewed all commits. I am all for bringing this inline with how connectors are registered. Consistency is important.

👍

*/
public function is_valid_exporter( $exporter ) {
if ( ! is_a( $exporter, 'WP_Stream\Exporter' ) ) {
trigger_error(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably trigger this error in register_exporters(). You should be able to call is_valid_exporter() on anything and simply get true or false. Otherwise it might be disjarring, akin to raising an exception with you call is_array( 'string' ).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

'user_id' => '',
'context' => '',
'action' => '',
'ip' => '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing needs to be fixed here.

lukecarbis pushed a commit that referenced this pull request Mar 15, 2016
@lukecarbis lukecarbis merged commit 4468d6d into develop Mar 15, 2016
@lukecarbis lukecarbis deleted the csv-export branch March 15, 2016 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants