aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/lines_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/lines_controller.rb')
-rw-r--r--app/controllers/lines_controller.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index 27a9bf9be..6b002e4f6 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -89,7 +89,9 @@ class LinesController < ChouetteController
params[:q]["#{filter}_blank"] = '1'
end
end
- @q = line_referential.lines.search(params[:q])
+
+ scope = ransack_status line_referential.lines
+ @q = scope.search(params[:q])
if sort_column && sort_direction
@lines ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction).paginate(:page => params[:page]).includes([:network, :company])
@@ -145,4 +147,20 @@ class LinesController < ChouetteController
)
end
+ # Fake ransack filter
+ def ransack_status scope
+ return scope unless params[:q].try(:[], :status)
+ return scope if params[:q][:status].values.uniq.length == 1
+
+ @status = {
+ activated: params[:q][:status]['activated'] == 'true',
+ deactivated: params[:q][:status]['deactivated'] == 'true',
+ }
+
+ scope = Chouette::Line.where(deactivated: @status[@status.key(true)])
+
+ params[:q].delete :status
+ scope
+end
+
end