Browse Source

Map added to the orgas page

remotes/origin/master
echarp 3 years ago
parent
commit
51cf38e8b4
  1. 11
      app/assets/javascripts/maps.js.coffee
  2. 1
      app/views/maps/_events.html.haml
  3. 12
      app/views/maps/_orgas.html.haml
  4. 23
      app/views/orgas/_orga.html.haml
  5. 46
      app/views/orgas/index.html.haml
  6. 4
      app/views/orgas/show.html.haml

11
app/assets/javascripts/maps.js.coffee

@ -1,7 +1,5 @@
# Setting up OpenStreeMap from a generic #map element
$(document).on 'turbolinks:load', ->
markerColors = ['blue', 'red', 'darkred', 'orange', 'green', 'darkgreen', 'purple', 'darkpuple', 'cadetblue']
idx = 0
$('#map.list').each ->
map = L.map 'map'
# Set some initial bounds, in case nothing else is displayed
@ -16,7 +14,8 @@ $(document).on 'turbolinks:load', ->
$('li a', this).each ->
url = $(this).attr 'href'
text = $(this).html()
markerColor = markerColors[idx++ %% markerColors.length]
markerColor = $('.awesome-marker', this).attr('class')
.substr 'awesome-marker awesome-marker-icon-'.length
if location.search && url.indexOf('?') >= 0
url += '&' + location.search.substr 1
else
@ -57,7 +56,6 @@ $(document).on 'turbolinks:load', ->
).addTo map
url = $(this).data 'url'
markerColor = markerColors[idx++ %% markerColors.length]
if location.search && url.indexOf('?') >= 0
url += '&' + location.search.substr 1
else
@ -66,7 +64,8 @@ $(document).on 'turbolinks:load', ->
# Marker with the proper icon
marker = L.AwesomeMarkers.icon
prefix: 'fa',
icon: 'calendar'
icon: $(this).data('icon') || 'calendar',
markerColor: 'darkred'
L.marker([coord[0], coord[1]], icon: marker).addTo map
$.getJSON url, (json) ->
@ -76,7 +75,7 @@ $(document).on 'turbolinks:load', ->
marker = L.AwesomeMarkers.icon
prefix: 'fa',
icon: feature.properties.icon || 'calendar',
markerColor: markerColor
markerColor: 'blue'
L.marker latlng, icon: marker
,
onEachFeature: (feature, layer) ->

1
app/views/maps/_events.html.haml

@ -9,6 +9,7 @@
= Event.model_name.human
- else
= t '.future'
- cs = %w[blue red darkred orange green darkgreen purple darkpuple cadetblue]
- idx = 1
- Kind.all.each do |kind|

12
app/views/maps/_orgas.html.haml

@ -0,0 +1,12 @@
= render '/regions/filter'
%ul.list.feeds#map
- cs = %w[red darkred orange green darkgreen purple darkpuple cadetblue]
- idx = 0
- Kind.all.each do |kind|
%li
= link_to map_path kind.name, format: :json do
.awesome-marker{ class: "awesome-marker-icon-#{cs[idx % cs.length]}" }
%i.icon-white.fa{ class: "fa-#{kind.icon}" }
= Kind.human_attribute_name "name_#{kind.name}"
- idx += 1

23
app/views/orgas/_orga.html.haml

@ -0,0 +1,23 @@
%tr{ class: orga.active ? 'active' : 'inactive' }
%td.flag= flag_icon orga.region.flag
%td.kind
- if orga.kind
%em.fa{ class: "fa-#{orga.kind.icon}",
title: Kind.human_attribute_name("name_#{orga.kind.name}") }
%td.name
= orga.name
= render partial: '/orgas/favicon', locals: { orga: orga }
%td.city= orga.city
%td.region= orga.region
%td.updated_at
- if orga.updated_at.present?
= l orga.updated_at.to_date
%td.tags{ title: orga.tag_list }
- if orga.tags.count > 1
%em.fa.fa-tags
- elsif orga.tags.count.positive?
%em.fa.fa-tag
%td.view{ title: t('.view') }
= link_to orga_path orga, q: params[:q].permit, page: params[:page] do
%em.fa.fa-arrow-circle-right

46
app/views/orgas/index.html.haml

@ -1,3 +1,5 @@
= render '/maps/orgas'
%h2
%em.fa.fa-users
= title t '.title'
@ -11,49 +13,9 @@
%th.city= sort_link @search, :city
%th.region= sort_link @search,
:region_name, Orga.human_attribute_name(:region)
%th.updated_at= sort_link @search,
:updated_at
%th.updated_at= sort_link @search, :updated_at
%tbody
- @orgas.each do |orga|
%tr{ class: orga.active ? 'active' : 'inactive' }
%td.flag= flag_icon orga.region.flag
%td.kind
- if orga.kind
%em.fa{ class: "fa-#{orga.kind.icon}",
title: Kind.human_attribute_name("name_#{orga.kind.name}") }
%td.name
= orga.name
= render partial: '/orgas/favicon', locals: { orga: orga }
%td.city= orga.city
%td.region= orga.region
%td.updated_at
- if orga.updated_at.present?
= l orga.updated_at.to_date
%td.tags{ title: orga.tag_list }
- if orga.tags.count > 1
%em.fa.fa-tags
- elsif orga.tags.count.positive?
%em.fa.fa-tag
%td.url{ title: Orga.human_attribute_name(:url) }
- if orga.url.present?
= link_to orga.url do
%em.fa.fa-external-link-alt
%td.diaspora{ title: Orga.human_attribute_name(:diaspora) + '*' }
- if orga.diaspora.present?
= link_to orga.diaspora do
%em.fa
%td.feed{ title: Orga.human_attribute_name(:feed) }
- if orga.feed.present?
= link_to orga.feed do
%em.fa.fa-rss
%td.view{ title: t('.view') }
= link_to orga_path orga, q: params[:q].permit, page: params[:page] do
%em.fa.fa-eye
%td.edit{ title: t('.edit') }
- if orga.secret.nil? || user_signed_in?
= link_to edit_orga_path orga do
%em.fa.fa-edit
%tbody= render @orgas
%tfoot
%tr

4
app/views/orgas/show.html.haml

@ -22,7 +22,9 @@
- if @orga.latitude && @orga.longitude
.orga#map{ data: { url: maps_path(format: :json).to_s,
latitude: @orga.latitude.to_s, longitude: @orga.longitude.to_s } }
latitude: @orga.latitude.to_s,
longitude: @orga.longitude.to_s,
icon: @orga.kind.icon } }
.description
= description sanitize @orga.description,

Loading…
Cancel
Save