-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathhub_controller.rb
51 lines (43 loc) · 1.17 KB
/
hub_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class HubController < ApplicationController
before_action :require_sign_in_and_project_selection
before_action :set_links_to_render
# GET /hub
def index
handle_bad_tab_order
respond_to do |format|
format.html {}
# TODO not used?!
# format.js {
# render partial: 'navigation_index' # layout: nil
# }
format.json{
render json: helpers.hub_json
}
end
end
def tasks
@tasks = UserTasks.hub_tasks(params[:category])
end
def order_tabs
handle_bad_tab_order
end
def update_tab_order
# TODO: update_column likely
@sessions_current_user.update_attribute(:hub_tab_order, params[:order])
head :ok
end
protected
def handle_bad_tab_order
# This is preventative only, it should never happen in real data, and may only occur when
# we reset tab performance.
if @sessions_current_user.hub_tab_order.empty?
# TODO: update_column likely
@sessions_current_user.update_attribute(:hub_tab_order, DEFAULT_HUB_TAB_ORDER)
end
true
end
def set_links_to_render
@links_to_render = params[:list]
@links_to_render ||= @sessions_current_user.hub_tab_order.first
end
end