2015-06-05 14:00:21 -04:00
|
|
|
class Profiles::PreferencesController < Profiles::ApplicationController
|
|
|
|
before_action :user
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-06-10 18:19:06 -04:00
|
|
|
begin
|
2017-09-27 05:48:33 -04:00
|
|
|
result = Users::UpdateService.new(current_user, preferences_params.merge(user: user)).execute
|
2017-06-15 09:24:37 -04:00
|
|
|
|
|
|
|
if result[:status] == :success
|
2015-06-10 18:19:06 -04:00
|
|
|
flash[:notice] = 'Preferences saved.'
|
|
|
|
else
|
|
|
|
flash[:alert] = 'Failed to save preferences.'
|
|
|
|
end
|
|
|
|
rescue ArgumentError => e
|
|
|
|
# Raised when `dashboard` is given an invalid value.
|
|
|
|
flash[:alert] = "Failed to save preferences (#{e.message})."
|
2015-06-05 14:00:21 -04:00
|
|
|
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
|
2015-06-05 13:57:01 -04:00
|
|
|
params.require(:user).permit(
|
|
|
|
:color_scheme_id,
|
2015-10-05 11:22:47 -04:00
|
|
|
:layout,
|
2015-06-10 03:23:28 -04:00
|
|
|
:dashboard,
|
2017-09-11 11:44:42 -04:00
|
|
|
:project_view,
|
|
|
|
:theme_id
|
2015-06-05 13:57:01 -04:00
|
|
|
)
|
2015-06-05 14:00:21 -04:00
|
|
|
end
|
|
|
|
end
|