Skip to content

Commit

Permalink
Added read more link to popups. Fix/improvements of earlier steps (refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ut committed Jan 7, 2025
1 parent e6de835 commit d3400fa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/helpers/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function PopupFullContent(place) {
}
content += '<div class="leaflet-popup-content-text">';

content += "<p class='label' style='background-color: "+place.color+"; color: #444;'>" + place.layer_title + "</p>";
content += "<p class='label' style='background-color: "+place.layer_color+"; color: #444;'>" + place.layer_title + "</p>";
if (place.date_with_qualifier) {
content += "<p>" + place.date_with_qualifier;
if (place.address) {
Expand Down Expand Up @@ -73,6 +73,9 @@ function PopupFullContent(place) {
}
content += "<p>" + teaser + "</p>";
}
if (place.url) {
content += "<p><a href='" + place.url + "'>Read more</a></p>";
}
if (place.edit_link) {
content += "<p class='text-right'>" + place.edit_link + "</p>";
}
Expand Down
6 changes: 4 additions & 2 deletions app/assets/stylesheets/4_map.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@
#map.leaflet-container a {
color: darken(#c6c600,10%);
}

/* this is not design guide conform, needs adapation for all UI links and buttons */
/*
#map.leaflet-container h4 a {
text-decoration: underline;
}

*/
#map.leaflet-container a:hover {
text-decoration: underline;
color: darken(#c6c600,20%);
}
.leaflet-bar a, .leaflet-bar a:hover {
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/places_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def qualifier_for_select
[['Exact date', 'exact'], ['Approx. date', 'circa']]
end

def url(map_id, layer_id, id)
map = Map.friendly.find(map_id)
layer = Layer.friendly.find(layer_id)
"#{Rails.application.config_for(:settings).app_host_protocol}://#{Rails.application.config_for(:settings).app_host}/maps/#{map.slug}/layers/#{layer.slug}/places/#{id}"
end

def show_link(title, map_id, layer_id, id)
" <a href=\"/maps/#{map_id}/layers/#{layer_id}/places/#{id}\">#{title}</a>"
end
Expand Down
12 changes: 8 additions & 4 deletions app/models/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def color
layer.color
end

def layer_color
layer.color
end

def date
ApplicationController.helpers.smart_date_display(startdate, enddate)
end
Expand All @@ -136,6 +140,10 @@ def date_with_qualifier
end
end

def url
ApplicationController.helpers.url(layer.map.id, layer.id, id)
end

def show_link
ApplicationController.helpers.show_link(title, layer.map.id, layer.id, id)
end
Expand All @@ -144,10 +152,6 @@ def edit_link
ApplicationController.helpers.edit_link(layer.map.id, layer.id, id)
end

def layer_color
layer.color
end

def icon_name
icon ? ApplicationController.helpers.icon_name(icon.title) : ''
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/layers/_layer.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ json.extract! layer, :id, :title, :subtitle, :text, :credits, :image_link, :publ
json.url map_layer_url(layer, format: :json)
json.iconset layer.map.iconset, :title, :icon_anchor, :icon_size, :popup_anchor, :class_name if layer.map.iconset
json.places layer.places do |place|
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :layer_type, :layer_title, :color, :created_at, :updated_at, :date, :date_with_qualifier, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :layer_type, :layer_title, :layer_color, :color, :created_at, :updated_at, :date, :date_with_qualifier, :url, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.lat place.public_lat
json.lon place.public_lon
json.annotations place.annotations do |annotation|
Expand Down
2 changes: 1 addition & 1 deletion app/views/maps/_map.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ json.layers map.layers do |layer|
json.extract! layer, :id, :title, :subtitle, :text, :credits, :image_link, :published, :map_id, :color, :relations_bending, :relations_coloring, :image_alt, :image_licence, :image_source, :image_creator, :image_caption, :created_at, :updated_at, :ltype
json.iconset layer.map.iconset, :title, :icon_anchor, :icon_size, :popup_anchor, :class_name if layer.map.iconset
json.places layer.places do |place|
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :shy, :layer_id, :layer_title, :layer_color, :layer_type, :created_at, :updated_at, :date, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :shy, :layer_id, :layer_title, :layer_color, :layer_type, :created_at, :updated_at, :date, :url, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.lat place.public_lat
json.lon place.public_lon
json.annotations place.annotations do |annotation|
Expand Down

0 comments on commit d3400fa

Please sign in to comment.