diff options
| author | cedricnjanga | 2018-03-12 06:17:02 -0700 |
|---|---|---|
| committer | cedricnjanga | 2018-03-12 06:17:02 -0700 |
| commit | e02ada352a0b204783fbc67d7c2a4266d2551082 (patch) | |
| tree | 92f446c0938f88f2ab7852cae1eb40f4e07a2f7d /app/controllers/lines_controller.rb | |
| parent | ba30cc2c8772dbd1934d032e2a3a6a66795df4e2 (diff) | |
| download | chouette-core-e02ada352a0b204783fbc67d7c2a4266d2551082.tar.bz2 | |
Refs #5146 Line state update
Diffstat (limited to 'app/controllers/lines_controller.rb')
| -rw-r--r-- | app/controllers/lines_controller.rb | 20 |
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 |
