summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/tabs/_nav.html.haml2
-rw-r--r--app/views/tabs/_tab.html.haml2
-rw-r--r--app/views/tabs/_tabs.html.haml4
-rw-r--r--users/app/controllers/users_controller.rb10
-rw-r--r--users/app/helpers/users_helper.rb4
-rw-r--r--users/app/views/users/edit.html.haml24
6 files changed, 27 insertions, 19 deletions
diff --git a/app/views/tabs/_nav.html.haml b/app/views/tabs/_nav.html.haml
new file mode 100644
index 0000000..6974c06
--- /dev/null
+++ b/app/views/tabs/_nav.html.haml
@@ -0,0 +1,2 @@
+%li{:class => (:active if nav == @anchor)}
+ %a{:href => "##{nav}", 'data-toggle' => 'tab'}= t("tabs.#{nav}")
diff --git a/app/views/tabs/_tab.html.haml b/app/views/tabs/_tab.html.haml
new file mode 100644
index 0000000..adab666
--- /dev/null
+++ b/app/views/tabs/_tab.html.haml
@@ -0,0 +1,2 @@
+.tab-pane{:id => tab, :class => (:active if tab == @anchor)}
+ = content_for tab
diff --git a/app/views/tabs/_tabs.html.haml b/app/views/tabs/_tabs.html.haml
new file mode 100644
index 0000000..8b01dbd
--- /dev/null
+++ b/app/views/tabs/_tabs.html.haml
@@ -0,0 +1,4 @@
+%ul.nav.nav-tabs
+ = render :partial => '/tabs/nav', :collection => tabs
+.tab-content
+ = render :partial => '/tabs/tab', :collection => tabs
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 5c6767c..3d71c1a 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -3,6 +3,7 @@ class UsersController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create]
before_filter :fetch_user, :only => [:edit, :update, :destroy]
+ before_filter :set_anchor, :only => [:edit, :update]
before_filter :authorize_admin, :only => [:index]
respond_to :json, :html
@@ -50,4 +51,13 @@ class UsersController < ApplicationController
@user = User.find_by_param(params[:id])
access_denied unless admin? or (@user == current_user)
end
+
+ def set_anchor
+ @anchor = email_settings? ? :email : :account
+ end
+
+ def email_settings?
+ params[:user] &&
+ params[:user].keys.detect{|key| key.index('email')}
+ end
end
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index 6d76d6f..45ca0e9 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -30,8 +30,4 @@ module UsersHelper
classes.compact
end
- def email_settings?
- params[:user] &&
- params[:user].keys.detect{|key| key.index('email')}
- end
end
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 8fc2cab..820b80e 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -1,17 +1,11 @@
.span8.offset2
%h2=t :settings
- %ul.nav.nav-tabs
- %li{:class => email_settings? ? :inactive : :active}
- %a{:href => '#account', 'data-toggle' => 'tab'}Account
- %li{:class => email_settings? ? :active : :inactive}
- %a{:href => '#email', 'data-toggle' => 'tab'}Email
-
- .tab-content
- .tab-pane#account{:class => email_settings? ? :inactive : :active}
- = 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{:class => email_settings? ? :active : :inactive}
- = user_form_with 'email_field', :legend => :set_email_address
- = user_form_with 'email_forward_field', :legend => :forward_email
- = user_form_with 'email_aliases', :legend => :add_email_alias
+ - content_for :account do
+ = user_form_with 'login_field', :legend => :change_login
+ = user_form_with 'password_fields', :legend => :change_password
+ = render 'cancel_account' if @user == current_user
+ - content_for :email do
+ = user_form_with 'email_field', :legend => :set_email_address
+ = user_form_with 'email_forward_field', :legend => :forward_email
+ = user_form_with 'email_aliases', :legend => :add_email_alias
+ = render 'tabs/tabs', :tabs => [:account, :email]