blob: bb71260ab96e1fd7abfae2629c647f7fca8b3c3f (
plain)
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
|
#
# These "auto" forms of the normal ticket path route helpers allow us to do two things automatically:
#
# (1) include the user in the path if appropriate.
# (2) retain the sort params, if appropriate.
#
# Tickets views with a user_id are limited to that user. For admins, they don't need a user_id for any ticket action.
#
# This is available both to the views and the tickets_controller.
#
module AutoTicketsPathHelper
protected
def auto_tickets_path(options={})
options = ticket_view_options.merge options
if @user
user_tickets_path(@user, options)
else
tickets_path(options)
end
end
def auto_ticket_path(ticket, options={})
options = ticket_view_options.merge options
if @user
user_ticket_path(@user, ticket, options)
else
ticket_path(ticket, options)
end
end
def auto_new_ticket_path(options={})
options = ticket_view_options.merge options
if @user
new_user_ticket_path(@user, options)
else
new_ticket_path(options)
end
end
private
def ticket_view_options
hsh = {}
hsh[:open_status] = params[:open_status] if params[:open_status] && !params[:open_status].empty?
hsh[:sort_order] = params[:sort_order] if params[:sort_order] && !params[:sort_order].empty?
hsh
end
end
|