blob: ea55820d07a23eea2167cd6bb4f740710fb3a9e9 (
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
|
class WorkbenchesController < BreadcrumbController
defaults :resource_class => Workbench
respond_to :html, :only => [:show]
def show
scope = Workbench.find(params[:id])
if params[:q] and params[:q][:organisation_name_eq_any].include? current_organisation.name
scope = scope.referentials.ready
else
scope = scope.all_referentials
end
@q = scope.ransack(params[:q])
@collection = @q.result(distinct: true)
@wbench_refs = @collection.order(sort_column + ' ' + sort_direction).paginate(page: params[:page], per_page: 30)
show! do
build_breadcrumb :show
end
end
private
def sort_column
Workbench.find(params[:id]).referentials.include?(params[:sort]) ? params[:sort] : 'name'
end
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc'
end
end
|