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

Changing tables #248

Merged
merged 4 commits into from
Oct 26, 2015
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
15 changes: 10 additions & 5 deletions app/assets/javascripts/views/restrooms/restrooms.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
# You can use CoffeeScript in this file: http://coffeescript.org/

$ ->
$('#ada_filter').click ->
$('#ada_filter').click ->
if $(this).hasClass("active")
$('.listItem.not_accessible').show()
else
else
$('.listItem.not_accessible').hide()
$('#unisex_filter').click ->

$('#unisex_filter').click ->
if $(this).hasClass("active")
$('.listItem.not_unisex').show()
else
else
$('.listItem.not_unisex').hide()

$('#changing_table_filter').click ->
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that we'll want to start pulling out all these boolean icons to enums rather than listing all of them here. Doesn't need to be part of this though, just a follow up. By no means is three icons unwieldy :P

Copy link
Member

Choose a reason for hiding this comment

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

Also, there may be a more 'rails' way to do it. Enums is just the first thing that pops into my head. @tkwidmer or @cllns might know

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really think there is a rails convention that would help here. These technically are three different filters. There may be a gem that will help with this, but since we are doing this filtering in javascript -- I don't know if it would really help without a refactor here. I'm fine with this for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I too don't think it's necessary at this point but I think we'd want to use a bitfield, not an enum. Here's a popular one that's named after a silly looking dog https://github.com/pboling/flag_shih_tzu :)

if $(this).hasClass("active")
$('.listItem.no_changing_table').show()
else
$('.listItem.no_changing_table').hide()
1 change: 1 addition & 0 deletions app/views/restrooms/_formsubmit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
= f.hidden_field :longitude
= f.input :accessible, :collection => [[t('restroom.accessible'), true], [t('restroom.not_accessible'), false]], :include_blank => false
= f.input :unisex, :collection => [[t('restroom.type.unisex'), true], [t('restroom.type.single_stall'), false]], :include_blank => false
= f.input :changing_table, :collection => [[t('restroom.changing_table'), true], [t('restroom.no_changing_table'), false]], :include_blank => false
= f.input :directions, :placeholder => t('restroom.directions_hint'), :as => :text, :required => false, :input_html => { :class => "span6" }
= f.input :comment, :placeholder => t('restroom.comments_hint'), :as => :text, :required => false, :input_html => { :class => "span6" }
= f.button :submit, t('restroom.restsubmit'), :class => "linkbutton"
10 changes: 9 additions & 1 deletion app/views/restrooms/_restroom.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
%div{:class => "listItem #{restroom.unisex? ? '' : 'not_unisex'} #{restroom.accessible? ? '' : 'not_accessible'}", "data-id" => restroom.id}
- unisex_class = restroom.unisex? ? '' : 'not_unisex'
- accessible_class = restroom.accessible? ? '' : 'not_accessible'
- changing_table_class = restroom.accessible? ? '' : 'no_changing_table'

%div{ class: "listItem #{unisex_class} #{accessible_class} #{changing_table_class}",
data: { id: restroom.id} }
.listItemImage
/ image tag goes here
.itemInfo
Expand Down Expand Up @@ -26,3 +31,6 @@
- if restroom.accessible?
.ADARestroom
%i.fa.fa-wheelchair.fa-3x
- if restroom.changing_table?
.changingTable
%i.fa.fa-child.fa-3x
3 changes: 3 additions & 0 deletions app/views/restrooms/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
%label#unisex_filter.filter.btn-light-purple.btn.linkbutton
%input{:type => "checkbox"}
%i.fa.fa-transgender-alt
%label#changing_table_filter.filter.btn-light-purple.btn.linkbutton
%input{:type => "checkbox"}
%i.fa.fa-child

.map-toggle-btn.mapToggle.filter.linkbutton.btn-light-purple
Map View
Expand Down
2 changes: 2 additions & 0 deletions config/locales/restroom.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ en:
comments: 'Comments'
accessible: 'Accessible'
not_accessible: 'Not accessible'
changing_table: 'Changing table'
no_changing_table: 'No changing table'
type:
unisex: 'Unisex / Gender neutral'
single_stall: 'Gendered single stall or safe place'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddChangingTableFlagToRestrooms < ActiveRecord::Migration
def change
add_column :restrooms, :changing_table, :boolean, default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140423031801) do
ActiveRecord::Schema.define(version: 20151018191859) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -66,6 +66,7 @@
t.integer "downvote", default: 0
t.integer "upvote", default: 0
t.string "country"
t.boolean "changing_table", default: false
end

end
5 changes: 5 additions & 0 deletions spec/models/restroom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
it { expect(Restroom.new(accessible: true).accessible?).to be true }
end

describe '#changing_table?' do
it { expect(Restroom.new.changing_table?).to be false }
it { expect(Restroom.new(changing_table: true).changing_table?).to be true }
end

describe '#topcities' do
it 'should return the top five cities with the most restroom data' do
city_with_more_data = "City1"
Expand Down