Skip to content

Commit

Permalink
Fix add your location on /people/ page (publiclab#6895)
Browse files Browse the repository at this point in the history
* add parameter to pass url to addTag

* remove alerts and uncomment

* fix error - check if user is logged in
  • Loading branch information
nstjean authored and Vinit Shahdeo committed Feb 1, 2020
1 parent 8b1c9c3 commit c629ffb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/views/locations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@
var tags = 'lat:' + blurredLocation.getLat() + ',lon:' + blurredLocation.getLon();
if (blurredLocation.isBlurred()) tags = tags + ',' + 'location:blurred'
if ($('#placenameDisplay').val() != 'Location unavailable') tags = tags + ',' + 'place:' + parameterize($('#placenameDisplay').val());
addTag(tags);
<% if params[:url] %>
addTag(tags, '<%= params[:url] %>');
<% else %>
addTag(tags);
<% end %>
<% if params[:reload] %>setTimeout(function() { location.reload(); }, 3000);<% end %>
}
Expand Down
16 changes: 12 additions & 4 deletions app/views/tag/_location.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
jQuery(document).ready(function() {
$('.blurred-location-input').click(function createBlurredLocationInput() {
$(this).attr("disabled", "disabled");
<% if params[:action] == "profile" %>
$.ajax('/locations/modal?reload=true')
<% else %>
$.ajax('/locations/modal')
let modalUrl = '/locations/modal';
let firstVar = true;
<% if (params[:action] == "list") || (params[:action] == "profile") %>
modalUrl += firstVar ? '?' : '&';
modalUrl += 'reload=true';
firstVar = false;
<% end %>
if( $(this).attr("submit_to") ) {
modalUrl += firstVar ? '?' : '&';
modalUrl += 'url=' + encodeURIComponent($(this).attr("submit_to"));
firstVar = false;
}
$.ajax(modalUrl)
.done(function(response) {
$('.blurred-location-container').html(response);
$('#blurred-location-modal').on('shown.bs.modal', function () { blurredLocation.map.invalidateSize(); });
Expand Down
8 changes: 5 additions & 3 deletions app/views/users/list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
<h2><%= raw t('People') %></h2>
<h5><%= t('Recently active on Publiclab') =%></h5>
</div>
<div class ="col-md-4">
<a class="btn btn-outline-secondary blurred-location-input" style="color:#666;" onmouseover="this.style.background='white';"><i class="fa fa-map-marker"></i> Add your location</a>
</div>
<% if current_user && (@map_lat.blank? || @map_lon.blank?) %>
<div class="col-md-4">
<a class="btn btn-outline-secondary blurred-location-input" style="color:#666;" onmouseover="this.style.background='white';" submit_to="/profile/tags/create/<%= current_user.uid %>"><i class="fa fa-map-marker"></i> Add your location</a>
</div>
<% end %>
</div>
<div>
<br>
Expand Down

0 comments on commit c629ffb

Please sign in to comment.