From 821fc4b03479a193b055c91b8a655d226bc46c17 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 5 Jun 2015 14:00:21 -0400 Subject: Add Profiles::PreferencesController --- app/controllers/profiles/preferences_controller.rb | 29 ++++++++++++++++++++++ app/views/layouts/nav/_profile.html.haml | 7 +++--- app/views/profiles/preferences/show.html.haml | 1 + app/views/profiles/preferences/update.js.erb | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 app/controllers/profiles/preferences_controller.rb create mode 100644 app/views/profiles/preferences/show.html.haml create mode 100644 app/views/profiles/preferences/update.js.erb (limited to 'app') diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb new file mode 100644 index 00000000000..897e6fe074d --- /dev/null +++ b/app/controllers/profiles/preferences_controller.rb @@ -0,0 +1,29 @@ +class Profiles::PreferencesController < Profiles::ApplicationController + before_action :user + + def show + end + + def update + if @user.update_attributes(preferences_params) + flash[:notice] = 'Preferences saved.' + else + # TODO (rspeicher): There's no validation on these values, so can it fail? + end + + respond_to do |format| + format.html { redirect_to profile_preferences_path } + format.js + end + end + + private + + def user + @user = current_user + end + + def preferences_params + params.require(:user).permit(:color_scheme_id, :theme_id) + end +end diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index ac37fd4c1c1..121665bd536 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -38,11 +38,12 @@ %span SSH Keys %span.count= current_user.keys.count - = nav_link(path: 'profiles#design') do - = link_to design_profile_path, title: 'Design', data: {placement: 'right'} do + = nav_link(controller: :preferences) do + = link_to profile_preferences_path, title: 'Preferences', data: {placement: 'right'} do + -# TODO (rspeicher): Better icon? = icon('image fw') %span - Design + Preferences = nav_link(path: 'profiles#history') do = link_to history_profile_path, title: 'History', data: {placement: 'right'} do = icon('history fw') diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml new file mode 100644 index 00000000000..1333ed77b7e --- /dev/null +++ b/app/views/profiles/preferences/show.html.haml @@ -0,0 +1 @@ +TODO diff --git a/app/views/profiles/preferences/update.js.erb b/app/views/profiles/preferences/update.js.erb new file mode 100644 index 00000000000..70b786d12ed --- /dev/null +++ b/app/views/profiles/preferences/update.js.erb @@ -0,0 +1 @@ +// TODO -- cgit v1.2.1