summaryrefslogtreecommitdiff
path: root/users/app
diff options
context:
space:
mode:
Diffstat (limited to 'users/app')
-rw-r--r--users/app/assets/javascripts/users.js.coffee5
-rw-r--r--users/app/controllers/users_controller.rb2
-rw-r--r--users/app/helpers/users_helper.rb30
-rw-r--r--users/app/views/users/edit.html.haml8
-rw-r--r--users/app/views/users/new.html.haml2
5 files changed, 28 insertions, 19 deletions
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index 76a6d79..9a2af7a 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -29,7 +29,6 @@ $(document).ready ->
$('#new_user').submit srp.signup
$('#new_session').submit preventDefault
$('#new_session').submit srp.login
- $('.user.form.edit').submit srp.update
- $('.user.form.edit').submit preventDefault
+ $('.user.form.change_password').submit srp.update
+ $('.user.form.change_password').submit preventDefault
$('.user.typeahead').typeahead({source: pollUsers});
-
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index cffc8c6..320ed96 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -31,7 +31,7 @@ class UsersController < ApplicationController
def update
@user.update_attributes(params[:user])
- respond_with @user
+ respond_with @user, :location => edit_user_path(@user)
end
def destroy
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index dec8904..5d9eff7 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -1,22 +1,32 @@
module UsersHelper
- def user_form_with(partial, legend, locals)
- user_form do |f|
- locals.reverse_merge! :legend => legend, :f => f
+ def user_form_with(partial, options = {})
+ user_form(options) do |f|
+ options[:f] = f
render :partial => partial,
:layout => 'legend_and_submit',
- :locals => locals
+ :locals => options
end
end
- def user_form
- html_class = 'form-horizontal user form '
- html_class += (@user.new_record? ? 'new' : 'edit')
+ def user_form(options)
simple_form_for @user,
- :validate => true,
- :format => :json,
- :html => {:class => html_class} do |f|
+ :html => user_form_html_options(options),
+ :validate => true do |f|
yield f
end
end
+
+ def user_form_html_options(options)
+ { :class => user_form_html_classes(options).join(" "),
+ :id => dom_id(@user, options[:legend])
+ }
+ end
+
+ def user_form_html_classes(options)
+ classes = %W/form-horizontal user form/
+ classes << options[:legend]
+ classes << (@user.new_record? ? 'new' : 'edit')
+ classes.compact
+ end
end
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 4192959..b33c19b 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -8,9 +8,9 @@
.tab-content
.tab-pane.active#account
- = user_form_with 'login_field', :change_login
- = user_form_with 'password_fields', :change_password
+ = user_form_with 'login_field', :legend => :change_login
+ = user_form_with 'password_fields', :legend => :change_password
= render 'cancel_account' if @user == current_user
.tab-pane#email
- = user_form_with 'email_field', :set_email_address
- = user_form_with 'email_forward_field', :forward_email
+ = user_form_with 'email_field', :legend => :set_email_address
+ = user_form_with 'email_forward_field', :legend => :forward_email
diff --git a/users/app/views/users/new.html.haml b/users/app/views/users/new.html.haml
index 81588b1..1814847 100644
--- a/users/app/views/users/new.html.haml
+++ b/users/app/views/users/new.html.haml
@@ -1,3 +1,3 @@
.span8.offset2
%h2=t :signup
- = user_form_with 'signup', :signup_message, :with_cancel => true
+ = user_form_with 'signup', :legend => :signup_message, :with_cancel => true