Skip to content

issue#2375 allow change of delimiter for csv download - #2403

Merged
xsrust merged 5 commits into
developmentfrom
csv_separator
Feb 28, 2020
Merged

issue#2375 allow change of delimiter for csv download#2403
xsrust merged 5 commits into
developmentfrom
csv_separator

Conversation

@raycarrick-ed

Copy link
Copy Markdown
Contributor

Fixes #2375 .

Changes proposed in this PR:

  • add a select menu to the usage page which gives a choice of three separators
  • this could be extended to allow for them to be specified in branding.yml but it'll do for starters
  • each download then also has a "sep" field which gets changed by a JS event listener attached to the select menu
  • the various CSV handling functions then get an extra sep parameter whch gets passed in from the download url

@briri briri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good @raycarrick-ed.

My comments were just informational about things I think we should consider post Rails5 upgrade.


// attach listener to separator select menu
// on change look for "stat" elements and chnage their query param
document.getElementById('csv-field-sep').addEventListener('click', (e) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should look into converting this over to a <form> submission instead of a <a> link, that way we wouldn't need to do any manual JS it would just come through in the submission params.

Something to do after the Rails 5 upgrade

Comment thread lib/csvable.rb Outdated
end

CSV.generate do |csv|
CSV.generate({:col_sep => sep}) do |csv|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

preferred style is { col_sep: sep } instead of { :col_sep => sep }.
No need to worry about it now though, when we run Rubocop on the entire codebase it will auto-change these for us.

@briri

briri commented Feb 21, 2020

Copy link
Copy Markdown
Contributor

looks like there are some JS linter issues in the checks. feel free to merge yourself once those are cleared up. You can run yarn run eslint --ext .js app/javascript/**/*.js to run the linter locally

@xsrust

xsrust commented Feb 27, 2020

Copy link
Copy Markdown
Contributor

I fixed up the eslint issues, and also tweaked the styling to make the new drop-down display inline with the button text.
Also noticed (because I'm working on a fresh roadmap DB from seeds) that the usage-dashboard breaks when there are no plans, so I added a default-case to the start_plan_date util in the usage_controller

@xsrust
xsrust merged commit be8afeb into development Feb 28, 2020
Comment on lines +191 to +192
StatCreatedPlan.all.order(:date).limit(1).pluck(:date).first \
|| Date.today.last_month.end_of_month

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixes a problem when there are no stats in the db (for example after a fresh seed)

@briri
briri deleted the csv_separator branch April 28, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants