Refactored profile to resource. Added missing flash notice on successfull updated. Update username via ajax

This commit is contained in:
Dmitriy Zaporozhets 2012-12-02 13:29:24 +02:00
parent 2be5e6d443
commit 46bf3a0949
14 changed files with 95 additions and 56 deletions

View file

@ -6,17 +6,17 @@
= render "layouts/head_panel", title: "Profile"
.container
%ul.main_menu
= nav_link(path: 'profile#show', html_options: {class: 'home'}) do
= nav_link(path: 'profiles#show', html_options: {class: 'home'}) do
= link_to "Profile", profile_path
= nav_link(path: 'profile#account') do
= link_to "Account", profile_account_path
= nav_link(path: 'profiles#account') do
= link_to "Account", account_profile_path
= nav_link(controller: :keys) do
= link_to keys_path do
SSH Keys
%span.count= current_user.keys.count
= nav_link(path: 'profile#design') do
= link_to "Design", profile_design_path
= nav_link(path: 'profile#history') do
= link_to "History", profile_history_path
= nav_link(path: 'profiles#design') do
= link_to "Design", design_profile_path
= nav_link(path: 'profiles#history') do
= link_to "History", history_profile_path
.content= yield

View file

@ -1 +0,0 @@
%h1 Profile

View file

@ -15,7 +15,7 @@
%span.cred.right
keep it secret!
.padded
= form_for @user, url: profile_reset_private_token_path, method: :put do |f|
= form_for @user, url: reset_private_token_profile_path, method: :put do |f|
.data
%p.slead
Private token used to access application resources without authentication.
@ -31,7 +31,7 @@
%fieldset
%legend Password
= form_for @user, url: profile_password_path, method: :put do |f|
= form_for @user, url: update_password_profile_path, method: :put do |f|
.padded
%p.slead After successful password update you will be redirected to login page where you should login with new password
-if @user.errors.any?
@ -53,16 +53,24 @@
%fieldset
%fieldset.update-username
%legend
Username
%small.right
%small.cred.right
Changing your username can have unintended side effects!
= form_for @user, url: profile_update_path, method: :put do |f|
= form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|
.padded
= f.label :username
.input
= f.text_field :username, required: true
 
%span.loading-gif.hide= image_tag "ajax_loader.gif"
%span.update-success.cgreen.hide
%i.icon-ok
Saved
%span.update-failed.cred.hide
%i.icon-ok
Failed
.input
= f.submit 'Save username', class: "btn save-btn"

View file

@ -1,4 +1,4 @@
= form_for @user, url: profile_update_path, remote: true, method: :put do |f|
= form_for @user, url: profile_path, remote: true, method: :put do |f|
%fieldset.application-theme
%legend
Application theme

View file

@ -8,7 +8,7 @@
%hr
= form_for @user, url: profile_update_path, method: :put, html: { class: "edit_user form-horizontal" } do |f|
= form_for @user, url: profile_path, method: :put, html: { class: "edit_user form-horizontal" } do |f|
-if @user.errors.any?
%div.alert-message.block-message.error
%ul
@ -39,9 +39,9 @@
- if Gitlab.config.omniauth_enabled? && @user.provider?
%li
%p.hint
%p
You can login through #{@user.provider.titleize}!
= link_to "click here to change", profile_account_path
= link_to "click here to change", account_profile_path
.row
.span7

View file

@ -0,0 +1,6 @@
- if @user.valid?
:plain
$('.update-username .update-success').show();
- else
:plain
$('.update-username .update-failed').show();