diff --git a/app/assets/stylesheets/debates.scss b/app/assets/stylesheets/debates.scss index c74ef5057..ca722db3d 100644 --- a/app/assets/stylesheets/debates.scss +++ b/app/assets/stylesheets/debates.scss @@ -15,6 +15,7 @@ // 08.2. Sign Up // 09. Forms // 10. Alerts +// 11. User account // // 01. Variables @@ -846,3 +847,62 @@ form { color: $alert-color; } } + + +// 11. User account +// - - - - - - - - - - - - - - - - - - - - - - - - - + +.account { + background: white; + min-height: $line-height*23; + padding-top: $line-height; + + + input[type="checkbox"], .checkbox { + margin-top: -(rem-calc(12)); + } + + .back, .icon-angle-left { + @include back; + } + + h1 { + clear: both; + font-size: rem-calc(36); + font-weight: bold; + line-height: $line-height*2; + margin-bottom: $line-height; + } + + .icon-comment-quotes { + color: $debates; + font-size: rem-calc(60); + line-height: $line-height; + opacity: .5; + } + + h2 { + clear: both; + font-size: rem-calc(20); + font-weight: bold; + line-height: $line-height; + margin: 0; + } + + .recommendations { + list-style-type: none; + margin-left: 0; + margin-top: $line-height; + + li { + font-size: rem-calc(12); + margin: rem-calc(12) 0; + + &:before { + color: $debates; + content: "l "; + font-family: "icons" !important; + } + } + } +} diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 37123d553..60f588d2a 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -26,7 +26,7 @@ $comments-info: #A5B2B9; $comments-text: #3F4549; $header-color: #292B33; -$link: #2895F1; +$link: #2895F1;//#0077B9; $link-hover: #2178BF; $tags-bg: #FAFAFA; @@ -59,7 +59,7 @@ $success-bg: #DFF0D8; $success-border: #D6E9C6; $success-color: #3C763D; -$info-bg: #D9EDF7; +$info-bg: #D9EDF7; $info-border: #BCE8F1; $info-color: #31708F; diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index e9b5b6c99..9c11691e2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -7,8 +7,11 @@ class AccountController < ApplicationController end def update - flash[:notice] = t("flash.actions.save_changes.notice") if @account.update(account_params) - redirect_to account_path + if @account.update(account_params) + redirect_to account_path, notice: t("flash.actions.save_changes.notice") + else + render :show + end end private diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index d130121f3..185af445b 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -1,32 +1,62 @@ -

<%= t("account.show.title") %>

+
+
+

<%= t("account.show.title") %>

-<%= form_for @account, as: :account, url: account_path do |f| %> + <%= form_for @account, as: :account, url: account_path do |f| %> - <%= f.label :first_name, t("account.show.first_name_label") %> - <%= f.text_field :first_name %> - <%= f.label :last_name, t("account.show.last_name_label") %> - <%= f.text_field :last_name %> + <% if @account.errors.any? %> +
+

<%= pluralize(@account.errors.count, t("debates.form.error"), t("debates.form.errors")) %> <%= t("debates.form.not_saved") %>

+
    + <% @account.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> -
- <%= f.check_box :use_nickname %> - <%= t("account.show.use_nickname_label") %> +
+
+ <%= f.label :first_name, t("account.show.first_name_label") %> + <%= f.text_field :first_name, placeholder: t("account.show.first_name_label") %> +
+ +
+ <%= f.label :last_name, t("account.show.last_name_label") %> + <%= f.text_field :last_name, placeholder: t("account.show.last_name_label") %> +
+ +
+ <%= f.label :nickname, t("account.show.nickname_label") %> + <%= f.text_field :nickname, placeholder: t("account.show.nickname_label") %> + <%= f.label :use_nickname do %> + <%= f.check_box :use_nickname %> + <%= t("account.show.use_nickname_label") %> + <% end %> +
+ +
+ <%= f.label :email_on_debate_comment do %> + <%= f.check_box :email_on_debate_comment %> + <%= t("account.show.email_on_debate_comment_label") %> + <% end %> +
+ +
+ <%= f.label :email_on_comment_reply do %> + <%= f.check_box :email_on_comment_reply %> + <%= t("account.show.email_on_comment_reply_label") %> + <% end %> +
+ +
+ <%= f.submit t("account.show.save_changes_submit"), class: "button radius" %> +
+
+ <% end %>
- <%= f.label :nickname, t("account.show.nickname_label") %> - <%= f.text_field :nickname %> - -
- <%= f.check_box :email_on_debate_comment %> - <%= f.label :email_on_debate_comment, t("account.show.email_on_debate_comment_label") %> +
+ <%= link_to t("account.show.change_credentials_link"), edit_user_registration_path, class: 'button radius small secondary' %>
- -
- <%= f.check_box :email_on_comment_reply %> - <%= f.label :email_on_comment_reply, t("account.show.email_on_comment_reply_label") %> -
- - <%= f.submit t("account.show.save_changes_submit"), class: "button radius" %> -<% end %> - -<%= link_to t("account.show.change_credentials_link"), edit_user_registration_path %> - +
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index d359cf5cd..b670b6776 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,39 +1,45 @@ -

<%= t("devise_views.registrations.edit.edit") %> <%= resource_name.to_s.humanize %>

+
+ \ No newline at end of file diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml index 7675a204e..ae778d00f 100644 --- a/config/locales/devise_views.en.yml +++ b/config/locales/devise_views.en.yml @@ -41,16 +41,12 @@ en: edit: "Edit" email_label: "Email" waiting_for: "Currently waiting confirmation for:" - leave_blank: "(leave blank if you don't want to change it)" + leave_blank: "Leave blank if you don't want to change it" password_label: "New password" password_confirmation_label: "Confirm new password" current_password_label: "Current password" - need_current: "(we need your current password to confirm your changes)" + need_current: "We need your current password to confirm your changes" update_submit: "Update" - cancel_title: "Cancel my account" - cancel_text: "Unhappy?" - cancel_link: "Cancel my account" - cancel_confirm: "Are you sure?" back_link: "Back" new: title: "Sign up" diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml index 63e3159e0..647dd3237 100644 --- a/config/locales/devise_views.es.yml +++ b/config/locales/devise_views.es.yml @@ -41,16 +41,12 @@ es: edit: "Editar" email_label: "Email" waiting_for: "Esperando confirmación de:" - leave_blank: "(dejar en blanco si no deseas cambiarla)" + leave_blank: "Dejar en blanco si no deseas cambiarla" password_label: "Contraseña nueva" password_confirmation_label: "Confirmar contraseña nueva" current_password_label: "Contraseña actual" - need_current: "(necesitamos tu contraseña actual para confirmar los cambios)" + need_current: "Necesitamos tu contraseña actual para confirmar los cambios" update_submit: "Actualizar" - cancel_title: "Cancelar cuenta" - cancel_text: "¿Deseas borrar tu cuenta?" - cancel_link: "Cancelar mi cuenta" - cancel_confirm: "¿Seguro?" back_link: "Atrás" new: title: "Registrarse" diff --git a/config/locales/es.yml b/config/locales/es.yml index 6d877770d..2e2473a1a 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -63,9 +63,9 @@ es: show: title: "Mi cuenta" save_changes_submit: "Guardar cambios" + change_credentials_link: "Cambiar mis credenciales" email_on_debate_comment_label: "Recibir un email cuando alguien commenta en mis debates" email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios" - change_credentials_link: "Cambiar mi contraseña" first_name_label: "Nombre" last_name_label: "Apellidos" use_nickname_label: "Usar pseudónimo" diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index e622c83c1..174145a7f 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -15,6 +15,20 @@ feature 'Account' do expect(page).to have_selector("input[value='Colau']") end + scenario "Failed Edit" do + login_as(@user) + visit account_path + + fill_in 'account_first_name', with: '' + fill_in 'account_last_name', with: '' + fill_in 'account_nickname', with: '' + click_button 'Save changes' + + expect(page).to have_content "2 errors prohibited this debate from being saved" + expect(page).to have_content "First name can't be blank" + expect(page).to have_content "First name can't be blank" + end + scenario 'Edit' do login_as(@user) visit account_path