diff --git a/app/assets/stylesheets/all.sass b/app/assets/stylesheets/all.sass index dd369b42..18f9f671 100644 --- a/app/assets/stylesheets/all.sass +++ b/app/assets/stylesheets/all.sass @@ -25,7 +25,7 @@ html padding: 0 background-color: transparent & > header, & > footer, - h2, nav, .region_selector, .orga_search, .formats, #banner + h2, nav, .region_filter, .orga_search, .formats, #banner display: none ul margin: 0 diff --git a/app/assets/stylesheets/region.sass b/app/assets/stylesheets/region.sass index fd5ce818..4566216f 100644 --- a/app/assets/stylesheets/region.sass +++ b/app/assets/stylesheets/region.sass @@ -1,4 +1,4 @@ -.region_selector +.region_filter float: right font-size: smaller & > ul > li @@ -40,7 +40,7 @@ input:checked + label display: inline padding: 0.5em - &:hover .radios + .region:hover .radios z-index: 1000 position: absolute box-shadow: 0 4px 4px gray diff --git a/app/views/regions/_filter.haml b/app/views/regions/_filter.haml index bcf8d216..a4a10ce2 100644 --- a/app/views/regions/_filter.haml +++ b/app/views/regions/_filter.haml @@ -1,4 +1,4 @@ -# Choose a region to filter events with -%nav.region_selector +%nav.region_filter %ul= render partial: '/regions/filter_region', collection: Region.where(region: nil) diff --git a/app/views/regions/_filter_region.haml b/app/views/regions/_filter_region.haml index 5d7a3fbd..568a9bf1 100644 --- a/app/views/regions/_filter_region.haml +++ b/app/views/regions/_filter_region.haml @@ -14,7 +14,10 @@ start_date: params[:start_date], year: params[:year], tag: params[:tag] do - %em.fa.fa-shield + - if filter_region.region.nil? + = flag_icon filter_region.code.try :downcase + - else + %em.fa.fa-shield = filter_region.name %ul = render partial: '/regions/filter_region', diff --git a/app/views/regions/_selector_region.haml b/app/views/regions/_selector_region.haml index c37a2325..4bb717c8 100644 --- a/app/views/regions/_selector_region.haml +++ b/app/views/regions/_selector_region.haml @@ -1,6 +1,11 @@ -- if selector_region.regions.present? || selector_region.url.nil? - = flag_icon selector_region.code.try :downcase - = selector_region - %em.fa.fa-chevron-right - .radios= f.collection_radio_buttons :region_id, - Region.where(region: selector_region), :id, :name +- if selector_region.regions.present? || selector_region.url.blank? + %span.region + = f.radio_button :region_id, selector_region.id + = f.label "region_id_#{selector_region.id}" do + = flag_icon selector_region.code.try :downcase + = selector_region + - if selector_region.regions.present? + %em.fa.fa-chevron-right + .radios + = f.collection_radio_buttons :region_id, + Region.where(region: selector_region), :id, :name diff --git a/db/migrate/20170701161358_add_lu_and_tn.rb b/db/migrate/20170701161358_add_lu_and_tn.rb new file mode 100644 index 00000000..06a14879 --- /dev/null +++ b/db/migrate/20170701161358_add_lu_and_tn.rb @@ -0,0 +1,11 @@ +# Add the new countries Luxembourg and Tunisia +class AddLuAndTn < ActiveRecord::Migration + def self.up + say 'Creates LU and TN regions' + return if Region.exists? name: 'Luxembourg' + [ + { name: 'Luxembourg', code: :LU, url: '//www.agendadulibre.org' }, + { name: 'Tunisie', code: :TN, url: '//www.agendadulibre.org' } + ].each { |country| Region.create country } + end +end diff --git a/db/schema.rb b/db/schema.rb index 50361a46..bb34cd50 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170508142601) do +ActiveRecord::Schema.define(version: 20170701161358) do create_table "active_admin_comments", force: :cascade do |t| t.string "namespace"