2015-09-11 14:41:01 +05:30
|
|
|
class Profiles::PreferencesController < Profiles::ApplicationController
|
|
|
|
before_action :user
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
begin
|
2017-09-10 17:25:29 +05:30
|
|
|
result = Users::UpdateService.new(user, preferences_params).execute
|
|
|
|
|
|
|
|
if result[:status] == :success
|
2015-09-11 14:41:01 +05:30
|
|
|
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})."
|
|
|
|
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,
|
2015-10-24 18:46:33 +05:30
|
|
|
:layout,
|
2015-09-11 14:41:01 +05:30
|
|
|
:dashboard,
|
2017-09-10 17:25:29 +05:30
|
|
|
:project_view
|
2015-09-11 14:41:01 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|