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

Filter by Grades (first pass) #30

Merged
merged 1 commit into from
Jan 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
//= require jquery/jquery.shorten
//= require map

$('.ui.dropdown').dropdown();
$(function(){
$('.ui.dropdown').dropdown({
onChange: function(e) {
e = e.toLowerCase();
window.location = e === 'all' ? "/" : "/grade/" + e;
}
});
});
4 changes: 4 additions & 0 deletions app/controllers/daycare_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ def index
def show
@daycare = Daycare.find_by(permalink: params[:id])
end

def grade
@daycares = Daycare.where(grade: params[:grade]).page(params[:page])
end
end
2 changes: 1 addition & 1 deletion app/views/daycare/_daycare.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.image
.grade class="grade-#{daycare.grade}"= daycare.grade
.content
.header=link_to(daycare.center_name, "daycare/#{daycare.permalink}")
.header=link_to(daycare.center_name, "/daycare/#{daycare.permalink}")
.street_address
small= daycare.address
.city_state_info
Expand Down
15 changes: 15 additions & 0 deletions app/views/daycare/grade.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
= javascript_include_tag "daycares"

.ui.stackable.grid#results
.two.column.row
.column
.ui.basic.segment
.ui.large.divided.list.results-list
- @daycares.each do |daycare|
= render "daycare", daycare: daycare, details: false

.ui.basic.segment
= paginate @daycares
.column
.map-wrapper
#map
7 changes: 5 additions & 2 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ html lang="en"
.ui.green.empty.circular.label
| B
.item(data-value="C")
.ui.orange.empty.circular.label
.ui.yellow.empty.circular.label
| C
.item(data-value="D")
.ui.red.empty.circular.label
.ui.orange.empty.circular.label
| D
.item(data-value="E")
.ui.red.empty.circular.label
| E
.ui.stackable.secondary.menu
.header.item
.item.violations
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Rails.application.routes.draw do
get "/" => "daycare#index"
get "/daycare/:id" => "daycare#show"
get "/grade/:grade" => "daycare#grade"

# get "/auth/auth0/callback" => "auth0#callback"
# get "/auth/failure" => "auth0#failure"
Expand Down