Merge branch 'develop' into feature/convo.algo

This commit is contained in:
Connor Turland 2017-02-05 06:28:49 +00:00
commit 3a4fa90c49
3 changed files with 32 additions and 1 deletions

View file

@ -102,6 +102,16 @@ class UsersController < ApplicationController
end
end
# PUT /user/update_metacode_focus
def update_metacode_focus
@user = current_user
@user.settings.metacode_focus = params[:value]
@user.save
respond_to do |format|
format.json { render json: { success: "success" }}
end
end
private
def user_params

View file

@ -22,7 +22,24 @@ module ApplicationHelper
else
Metacode.where(id: @m).to_a
end
@metacodes.sort! { |m1, m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1)
focus_code = user_metacode()
if focus_code != nil && @metacodes.index{|m| m.id == focus_code.id} == nil
@metacodes.push(focus_code)
end
@metacodes
.sort! { |m1, m2| m2.name.downcase <=> m1.name.downcase }
if focus_code != nil
@metacodes.rotate!(@metacodes.index{|m| m.id == focus_code.id})
else
@metacodes.rotate!(-1)
end
end
def user_metacode
current_user.settings.metacode_focus ? Metacode.find(current_user.settings.metacode_focus.to_i) : nil
end
def user_metacode

View file

@ -28,6 +28,10 @@ class UserPolicy < ApplicationPolicy
update?
end
def update_metacode_focus?
update?
end
# API action
def current?
user == record