suggestions_helper.rb
2.07 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
module PairwisePlugin::Helpers::SuggestionsHelper
def pagination_for_choices(choices)
pagination_links choices,
:params => {
:controller => 'pairwise_plugin_suggestions',
:action => :index,
:profile => profile.identifier
}
end
def link_to_sort_choices(pairwise_content, label, sort_by)
sort_order = "asc"
if params[:order]
order = params[:order]
if order[:sort_by] == sort_by
case order[:sort_order]
when 'asc'
sort_order = 'desc'
when 'desc'
sort_order = 'asc'
else
sort_order = 'asc'
end
end
end
link_to label, :action => "index", :id => pairwise_content.id, :pending => params[:pending], :reproved => params[:reproved], :order => {:sort_by => sort_by, :sort_order => sort_order}
end
def class_to_order_column(title, order=nil)
if order
sort_by = title == order[:sort_by] ? "selected_column" : "not_selected_column"
#raise sort_by.inspect
case order[:sort_order]
when 'asc'
sort_order = "soDescending"
when 'desc'
sort_order = "soAscending"
else
sort_order = "soAscending"
end
if (title == order[:sort_by])
style = "#{sort_by} #{sort_order}"
else
style = "#{sort_by}"
end
else
style = "not_selected_column"
end
end
def link_to_edit_choice(pairwise_content, choice)
link_to _("Edit"), :action => "edit", :id => pairwise_content.id, :choice_id => choice.id
end
def link_to_approve_choice(pairwise_content, choice, params)
link_to _("Approve"), :action => "approve", :id => pairwise_content.id, :choice_id => choice.id,:page => params[:page], :pending => params[:pending]
end
def link_to_reprove_idea(pairwise_content, choice, reason, params)
link_to _("Reprove"), :action => "reprove", :reason => reason || 'reprove' , :id => pairwise_content.id, :choice_id => choice.id,:page => params[:page], :pending => params[:pending]
end
end