Add sign_in button to profile view

This commit is contained in:
Erik Michaels-Ober 2011-04-03 21:18:59 -07:00
parent e3fc106db1
commit 8c359b97f9
9 changed files with 68 additions and 35 deletions

View File

@ -11,7 +11,7 @@ class HydrantsController < ApplicationController
if user_signed_in? if user_signed_in?
render("adopt", :layout => "info_window") render("adopt", :layout => "info_window")
else else
render("users/new", :layout => "info_window") render("sessions/new", :layout => "info_window")
end end
end end
end end

View File

@ -1,4 +1,8 @@
class SessionsController < Devise::SessionsController class SessionsController < Devise::SessionsController
def new
render("new", :layout => "info_window")
end
def create def create
resource = warden.authenticate(:scope => resource_name) resource = warden.authenticate(:scope => resource_name)
if resource if resource

View File

@ -8,4 +8,4 @@
<p>By adopting this hydrant, you agree to the <%= link_to "Terms of Service", "#", :tabindex => 3 %>.</p> <p>By adopting this hydrant, you agree to the <%= link_to "Terms of Service", "#", :tabindex => 3 %>.</p>
<% end %> <% end %>
<%= render(:partial => 'users/edit_profile') %> <%= render(:partial => 'users/edit_profile') %>
<%= render(:partial => 'users/sign_out') %> <%= render(:partial => 'sessions/sign_out') %>

View File

@ -0,0 +1,3 @@
<%= form_for(:sign_in, :html => {:id => "sign_in_form"}) do |f| %>
<%= f.submit "Sign in", :id => "sign_in_form_submit" %>
<% end %>

View File

@ -3,5 +3,7 @@
<% if user_signed_in? %> <% if user_signed_in? %>
<%= render(:partial => 'users/edit_profile') %> <%= render(:partial => 'users/edit_profile') %>
<%= render(:partial => 'hydrants/steal') %> <%= render(:partial => 'hydrants/steal') %>
<%= render(:partial => 'users/sign_out') %> <%= render(:partial => 'sessions/sign_out') %>
<% else %>
<%= render(:partial => 'sessions/sign_in') %>
<% end %> <% end %>

View File

@ -1,4 +1,4 @@
<h2>Thank you for adopting this hydrant!</h2> <h2>Thank you for adopting this hydrant!</h2>
<%= render(:partial => 'users/edit_profile') %> <%= render(:partial => 'users/edit_profile') %>
<%= render(:partial => 'hydrants/abandon') %> <%= render(:partial => 'hydrants/abandon') %>
<%= render(:partial => 'users/sign_out') %> <%= render(:partial => 'sessions/sign_out') %>

View File

@ -378,36 +378,6 @@ $(function() {
} }
return false; return false;
}); });
$('#sign_out_form').live('submit', function() {
var submitButton = $("#sign_out_form input[type='submit']");
$(submitButton).attr("disabled", true);
$.ajax({
type: 'GET',
url: '/users/sign_out.json',
data: {
'commit': $('#sign_out_form_submit').val(),
'utf8': '✓',
'authenticity_token': $('#sign_out_form input[name="authenticity_token"]').val()
},
beforeSend: function() {
$('#info_window').hide();
$('#loader').show();
},
success: function(data) {
$.ajax({
type: 'GET',
url: '/hydrant',
data: {
'hydrant_id': activeHydrantId
},
success: function(data) {
activeInfoWindow.setContent(data);
}
});
}
});
return false;
});
$('#adoption_form').live('submit', function() { $('#adoption_form').live('submit', function() {
var submitButton = $("#adoption_form input[type='submit']"); var submitButton = $("#adoption_form input[type='submit']");
$(submitButton).attr("disabled", true); $(submitButton).attr("disabled", true);
@ -677,13 +647,67 @@ $(function() {
} }
return false; return false;
}); });
$('#sign_out_form').live('submit', function() {
var submitButton = $("#sign_out_form input[type='submit']");
$(submitButton).attr("disabled", true);
$.ajax({
type: 'GET',
url: '/users/sign_out.json',
data: {
'commit': $('#sign_out_form_submit').val(),
'utf8': '✓',
'authenticity_token': $('#sign_out_form input[name="authenticity_token"]').val()
},
beforeSend: function() {
$('#info_window').hide();
$('#loader').show();
},
success: function(data) {
$.ajax({
type: 'GET',
url: '/hydrant',
data: {
'hydrant_id': activeHydrantId
},
success: function(data) {
activeInfoWindow.setContent(data);
}
});
}
});
return false;
});
$('#sign_in_form').live('submit', function() {
var submitButton = $("#sign_in_form input[type='submit']");
$(submitButton).attr("disabled", true);
$.ajax({
type: 'GET',
url: '/users/sign_in',
data: {
'commit': $('#sign_in_form_submit').val(),
'utf8': '✓',
'authenticity_token': $('#sign_in_form input[name="authenticity_token"]').val(),
},
beforeSend: function() {
$('#info_window').hide();
$('#loader').show();
},
success: function(data) {
activeInfoWindow.setContent(data);
}
});
return false;
});
$('#back_form').live('submit', function() { $('#back_form').live('submit', function() {
var submitButton = $("#edit_form input[type='submit']"); var submitButton = $("#back_form input[type='submit']");
$(submitButton).attr("disabled", true); $(submitButton).attr("disabled", true);
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '/hydrant', url: '/hydrant',
data: { data: {
'commit': $('#back_form_submit').val(),
'utf8': '✓',
'authenticity_token': $('#back_form input[name="authenticity_token"]').val(),
'hydrant_id': activeHydrantId 'hydrant_id': activeHydrantId
}, },
beforeSend: function() { beforeSend: function() {