2015-06-05 18:00:21 +00:00
|
|
|
class Profiles::PreferencesController < Profiles::ApplicationController
|
|
|
|
before_action :user
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-06-10 22:19:06 +00:00
|
|
|
begin
|
2017-06-23 09:34:07 +00:00
|
|
|
result = Users::UpdateService.new(user, preferences_params).execute
|
2017-06-15 13:24:37 +00:00
|
|
|
|
|
|
|
if result[:status] == :success
|
2015-06-10 22:19:06 +00: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 18:00:21 +00: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 17:57:01 +00:00
|
|
|
params.require(:user).permit(
|
|
|
|
:color_scheme_id,
|
2015-10-05 15:22:47 +00:00
|
|
|
:layout,
|
2015-06-10 07:23:28 +00:00
|
|
|
:dashboard,
|
2017-05-03 11:27:17 +00:00
|
|
|
:project_view
|
2015-06-05 17:57:01 +00:00
|
|
|
)
|
2015-06-05 18:00:21 +00:00
|
|
|
end
|
|
|
|
end
|