From 50f429784c6f746a302db8221cb049630f19c98b Mon Sep 17 00:00:00 2001 From: echarp Date: Sun, 17 Apr 2016 14:07:39 +0200 Subject: [PATCH] Some advances to maps, and translations. Refs #71 --- app/assets/javascripts/maps.js.coffee | 2 +- app/controllers/maps_controller.rb | 8 +++++--- app/views/maps/index.html.haml | 2 +- app/views/maps/show.html.haml | 15 +++++++++++++++ config/locales/models/en.yml | 2 +- config/locales/models/fr.yml | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 app/views/maps/show.html.haml diff --git a/app/assets/javascripts/maps.js.coffee b/app/assets/javascripts/maps.js.coffee index 0b66d69f..e27dfa9c 100644 --- a/app/assets/javascripts/maps.js.coffee +++ b/app/assets/javascripts/maps.js.coffee @@ -30,7 +30,7 @@ $(document).ready -> map.addLayer layer controls.addOverlay layer, text + ' - ' + count - if (url.contains('maps.json') && layer.getBounds()._northEast && layer.getBounds()._southWest) + if (location.href.contains('maps/') || url.contains('maps.json')) && layer.getBounds()._northEast && layer.getBounds()._southWest # Automatic focus to all displayed events map.fitBounds layer.getBounds() diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 8fcf86be..3547eabb 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -15,10 +15,12 @@ class MapsController < ApplicationController end def show - kind = Kind.find_by_name params[:id] - orgas = apply_scopes(Orga.moderated.geo).joins(:kind).where(kind: kind) + @kind = Kind.find_by_name params[:id] respond_to do |format| - format.json { render json: orgas } + format.html { render layout: 'iframe' if params[:iframe] } + format.json do + render json: apply_scopes(Orga.moderated.geo).where(kind: @kind) + end end end end diff --git a/app/views/maps/index.html.haml b/app/views/maps/index.html.haml index 4347837c..4afa6484 100644 --- a/app/views/maps/index.html.haml +++ b/app/views/maps/index.html.haml @@ -10,7 +10,7 @@ %li = link_to maps_path format: :json do %em.fa.fa-calendar - = Event.model_name.human.pluralize + = Event.model_name.human - Kind.all.each do |kind| %li = link_to map_path kind.name, format: :json do diff --git a/app/views/maps/show.html.haml b/app/views/maps/show.html.haml new file mode 100644 index 00000000..56fa2a3d --- /dev/null +++ b/app/views/maps/show.html.haml @@ -0,0 +1,15 @@ +%h2 + %em.fa.fa-map-marker + = t 'layouts.application.map' + %em.fa{ class: "fa-#{@kind.icon}" } + = Kind.human_attribute_name("name_#{@kind.name}") + - if params[:tag] + « + %em= params[:tag] + » + +%ul#map.list + %li + = link_to map_path @kind.name, format: :json do + %em.fa{ class: "fa-#{@kind.icon}" } + = Kind.human_attribute_name("name_#{@kind.name}") diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index 82469a0b..5d1d8590 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -55,7 +55,7 @@ en: kind: name_association: Association name_enterprise: Enterprise - name_lug: LUG + name_lug: GLUG name_provider: ISP name_institution: Institution name_lab: Lab diff --git a/config/locales/models/fr.yml b/config/locales/models/fr.yml index 9db0e359..b152ca4a 100644 --- a/config/locales/models/fr.yml +++ b/config/locales/models/fr.yml @@ -55,7 +55,7 @@ fr: kind: name_association: Association name_enterprise: Entreprise - name_lug: GUL + name_lug: GULL name_provider: FAI name_institution: Institution name_lab: Lab