Add ability to steal an adopted hydrant
This commit is contained in:
parent
1885126bb9
commit
77c8df874d
|
@ -0,0 +1,6 @@
|
|||
<%= form_for @hydrant, :html => {:id => "steal_form"} do |f| %>
|
||||
<%= f.hidden_field "id" %>
|
||||
<%= f.hidden_field "user_id", :value => "" %>
|
||||
<%= f.hidden_field "name", :value => "" %>
|
||||
<%= f.submit "Steal this hydrant", :id => "steal_form_submit" %>
|
||||
<% end %>
|
|
@ -1,2 +1,6 @@
|
|||
<h2><%= @hydrant.name ? @hydrant.name.titleize : "This hydrant" %> has been adopted by <%= @hydrant.user.name %></h2>
|
||||
<%= @hydrant.user.organization.blank? ? nil : "<h3>of #{@hydrant.user.organization}</h3>".html_safe %>
|
||||
<% if user_signed_in? %>
|
||||
<%= render :partial => 'steal_form' %>
|
||||
<%= render :partial => 'sign_out_form' %>
|
||||
<% end %>
|
||||
|
|
|
@ -318,7 +318,7 @@ $(function() {
|
|||
'id': $('#hydrant_id').val(),
|
||||
'commit': $('#adoption_form_submit').val(),
|
||||
'utf8': '✓',
|
||||
'authenticity_token': $('input[name="authenticity_token"]').val(),
|
||||
'authenticity_token': $('#adoption_form input[name="authenticity_token"]').val(),
|
||||
'_method': 'put',
|
||||
'hydrant': {
|
||||
'user_id': $('#hydrant_user_id').val(),
|
||||
|
@ -340,4 +340,34 @@ $(function() {
|
|||
});
|
||||
return false;
|
||||
});
|
||||
$('#steal_form').live('submit', function() {
|
||||
var answer = window.confirm("Are you sure you want to steal this hydrant?")
|
||||
if(answer) {
|
||||
$.post('<%= hydrant_path :format => "json" %>', {
|
||||
'id': $('#hydrant_id').val(),
|
||||
'commit': $('#steal_form_submit').val(),
|
||||
'utf8': '✓',
|
||||
'authenticity_token': $('#steal_form input[name="authenticity_token"]').val(),
|
||||
'_method': 'put',
|
||||
'hydrant': {
|
||||
'user_id': $('#hydrant_user_id').val(),
|
||||
'name': $('#hydrant_name').val()
|
||||
}
|
||||
}, function(data) {
|
||||
$.get('<%= contents_path %>', {
|
||||
'hydrant_id': activeHydrantId
|
||||
}, function(data) {
|
||||
activeInfoWindow.setContent(data);
|
||||
image = new google.maps.MarkerImage('/images/markers/red.png',
|
||||
new google.maps.Size(27.0, 37.0),
|
||||
new google.maps.Point(0, 0),
|
||||
new google.maps.Point(13.0, 18.0)
|
||||
);
|
||||
activeMarker.setIcon(image);
|
||||
activeMarker.setAnimation(null);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue