Skip to content

Commit

Permalink
Create separate partial for sidebar map and add it in questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlazypanda committed Mar 9, 2020
1 parent 783fbe2 commit ae15db7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
20 changes: 20 additions & 0 deletions app/views/sidebar/_map.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<% if @node && @node.lat && @node.lon %>
<% if @node.has_tag("place") %>
<%= render_top_map(@node.lat, @node.lon, @node.zoom) %>
<% else %>
<%= render_map(@node.lat, @node.lon, @node.zoom) %>
<% end %>
<%# Link to map %>
<% zoom = @node.zoom ? @node.zoom : "" %>
<% url = "/map#" + zoom.to_s + "/" + @node.lat.to_s + "/" + @node.lon.to_s %>
<% if @node.type == "page" %>
<% url = "/map/" + @node.slug_from_path %>
<% end %>
<a href="<%= url %>" class="btn btn-outline-secondary btn-location mt-2"><i class="fa fa-map" aria-hidden="true"></i> View on a map</a>
<% elsif !@node.lat && !@node.lon %>
<div id="map_template" style="position: relative; display: inline-block;">
<a class="blurred-location-input btn btn-outline-secondary btn-lg btn-location my-2"><i class="fa fa-map-marker" style="color:#c40;" ></i> <strong>Add a location</strong></a>
</div>
<br>
<span>Learn about location <a href="https://publiclab.org/location-privacy">privacy</a></span>
<% end %>
8 changes: 4 additions & 4 deletions app/views/sidebar/_question.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<div class="col-lg-3">

<%= render :partial => "like/like", :locals => {:node => @node, :tagnames => @tagnames } %>

<a style="margin-top:-16px;margin-bottom:0;" class="btn btn-sm btn-block btn-link d-lg-none" href="javascript:void()" onClick="toggle_sidebar()"><i class="fa fa-chevron-down"></i></a>

<div id="sidebar" class="d-lg-inline">

<a rel="tooltip" title="Ask question<% if @tagnames %> about <%= (@tagnames.uniq.collect {|x| x.gsub(/[\w-]+:/, '') }).join(',') %><% end %>" data-placement="bottom" href="/post<%= '?tags=' + @tagnames.uniq.join(',') if @tagnames %>&template=question&redirect=question" class="btn btn-primary btn-lg btn-block requireLogin"><i class="fa fa-question-circle fa-white"></i> Ask related question &raquo;</a>

<br />

<% if @node %>
<%= render :partial => "sidebar/list" %>
<% end %>
Expand All @@ -24,13 +24,13 @@
<% end %>
<% end %>

<%= render partial: "sidebar/map" %>
<%= render partial: 'sidebar/notes', locals: { notes: @notes, title: "Related Questions", node: @node } %>

</div>

<div id=sidebar-tags>
<%= render partial: 'tag/tagging' %>
</div>

</div>
<%= javascript_include_tag 'sidebar' %>
21 changes: 1 addition & 20 deletions app/views/sidebar/_related.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,7 @@
<%= render partial: 'sidebar/notes', locals: { notes: @node.responses, title: I18n.t('sidebar._related.responses_to_note'), node: @node } %>
<% end %>

<% if @node && @node.lat && @node.lon %>
<% if @node.has_tag("place") %>
<%= render_top_map(@node.lat, @node.lon, @node.zoom) %>
<% else %>
<%= render_map(@node.lat, @node.lon, @node.zoom) %>
<% end %>
<%# Link to map %>
<% zoom = @node.zoom ? @node.zoom : "" %>
<% url = "/map#" + zoom.to_s + "/" + @node.lat.to_s + "/" + @node.lon.to_s %>
<% if @node.type == "page" %>
<% url = "/map/" + @node.slug_from_path %>
<% end %>
<a href="<%= url %>" class="btn btn-outline-secondary btn-location mt-2"><i class="fa fa-map" aria-hidden="true"></i> View on a map</a>
<% elsif !@node.lat && !@node.lon %>
<div id="map_template" style="position: relative; display: inline-block;">
<a class="blurred-location-input btn btn-outline-secondary btn-lg btn-location my-2"><i class="fa fa-map-marker" style="color:#c40;" ></i> <strong>Add a location</strong></a>
</div>
<br>
<span>Learn about location <a href="https://publiclab.org/location-privacy">privacy</a></span>
<% end %>
<%= render partial: "sidebar/map" %>

<br style="clear:both;" />

Expand Down

0 comments on commit ae15db7

Please sign in to comment.