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

Community program search #38

Open
5 of 9 tasks
peregrinator opened this issue Jan 22, 2018 · 0 comments
Open
5 of 9 tasks

Community program search #38

peregrinator opened this issue Jan 22, 2018 · 0 comments
Assignees

Comments

@peregrinator
Copy link
Collaborator

peregrinator commented Jan 22, 2018

We want to add basic search and export functionality to the application. We'll start by allowing admin users to search for an community program by name, organization, or school.

We'll use Ransack to power the search and allow users to export the results as a CSV.

CommunityProgramSearch

  • create app/searches/application_search.rb
  • create app/searches/community_program_search.rb that inherits from ApplicationSearch
  • #new takes a set of parameters and creates an internal ransack search @query for them
  • #results calls query.results and adds any needed includes, etc (eager loading)
  • #csv calls #results.each and returns a CSV

Admin::SearchController

  • #index action that only renders the form if no parameters are present, otherwise uses CommunityProgramSearch and passes the results to the view (and renders form)
  • #export action that uses the CommunityProgramSearch #as_csv method that returns the results as a CSV.

app/views/admin/search_controller/index.html.erb

  • view as outlined in image
    image
  • "Export as CSV" button sends along the search parameters to search_controller#export
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

No branches or pull requests

2 participants