diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 18 | ||||
| -rw-r--r-- | app/models/line_referential.rb | 2 | ||||
| -rw-r--r-- | app/views/referential_lines/show.html.slim | 16 | ||||
| -rw-r--r-- | app/views/shared/_lines_search_form.html.slim | 13 |
4 files changed, 22 insertions, 27 deletions
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 6a07e5093..165b4c262 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -67,19 +67,11 @@ class ReferentialLinesController < ChouetteController end def collection - if params[:q] && params[:q]["network_id_eq"] == "-1" - params[:q]["network_id_eq"] = "" - params[:q]["network_id_blank"] = "1" - end - - if params[:q] && params[:q]["company_id_eq"] == "-1" - params[:q]["company_id_eq"] = "" - params[:q]["company_id_blank"] = "1" - end - - if params[:q] && params[:q]["group_of_lines_id_eq"] == "-1" - params[:q]["group_of_lines_id_eq"] = "" - params[:q]["group_of_lines_id_blank"] = "1" + %w(network_id company_id group_of_lines_id comment_id transport_mode_name).each do |filter| + if params[:q] && params[:q]["#{filter}_eq"] == '-1' + params[:q]["#{filter}_eq"] = '' + params[:q]["#{filter}_blank"] = '1' + end end @q = referential.lines.search(params[:q]) diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb index 7096fd6ff..add9ae5b6 100644 --- a/app/models/line_referential.rb +++ b/app/models/line_referential.rb @@ -28,6 +28,6 @@ class LineReferential < ActiveRecord::Base end def transport_modes - Chouette::TransportMode.all.select { |tm| tm.positive? } + Chouette::TransportMode.all.select { |tm| tm.to_i.positive? } end end diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 4c439d08a..309331efc 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -56,14 +56,14 @@ / p / label = "#{@line.human_attribute_name('mobility_restricted_suitability')} : " - / + / / - if @line.mobility_restricted_suitability.nil? / = @line.human_attribute_name("unspecified_mrs") / - elsif @line.mobility_restricted_suitability? / = @line.human_attribute_name("accessible") / - else / = @line.human_attribute_name("not_accessible") - / + / / br / = "#{@line.human_attribute_name('number_of_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', true).count}" / br @@ -71,29 +71,29 @@ / br / = "#{@line.human_attribute_name('number_of_null_mrs_vj')} : " / = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("mobility_restricted_suitability = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count) - / + / / p / label = "#{@line.human_attribute_name('flexible_service')} : " - / + / / - if @line.flexible_service.nil? / = @line.human_attribute_name("unspecified_fs") / - elsif @line.flexible_service? / = @line.human_attribute_name("on_demaond_fs") / - else / = @line.human_attribute_name("regular_fs") - / + / / br / = "#{@line.human_attribute_name('number_of_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', true).count}" / br / = "#{@line.human_attribute_name('number_of_non_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', false).count}" / br / = @line.human_attribute_name("number_of_null_fs_vj") - / + / / - if @line.flexible_service.nil? / = "(#{@line.human_attribute_name('default_fs_msg')})" - / + / / = ": #{@line.vehicle_journeys.count - (@line.vehicle_journeys.where('flexible_service = ?', true).count + @line.vehicle_journeys.where('flexible_service = ?', false).count)}" - / + / / p / label = "#{@line.human_attribute_name('footnotes')} : " / ul diff --git a/app/views/shared/_lines_search_form.html.slim b/app/views/shared/_lines_search_form.html.slim index ba25370a8..065b365b2 100644 --- a/app/views/shared/_lines_search_form.html.slim +++ b/app/views/shared/_lines_search_form.html.slim @@ -2,7 +2,7 @@ = search_form_for @q, url: eval("#{referential_type}_lines_path(referential)"), remote: true, html: { method: :get, class: 'form-inline', id: 'search', role: 'form' } do |f| .panel.panel-default .panel-heading - .input-group.col-lg-9.col-md-9 + .input-group.col-md-9 = f.search_field :name_or_number_or_objectid_or_comment_cont, placeholder: t('lines.index.name_or_number_or_objectid_or_comment'), class: 'form-control' .input-group-btn button.btn.btn-primary type='submit' @@ -15,7 +15,10 @@ #advanced_search.panel-collapse.collapse .panel-body .row - - %w(networks companies group_of_lines).each do |filter| - - if referential.send(filter).any? - .col-lg-4.col-md-4.col-sm-4.col-xs-4 - = f.select(:"#{filter.singularize unless filter == 'group_of_lines'}_id_eq", referential.send(filter).collect { |f| [f.name, f.id] }.unshift([t("lines.index.no_#{filter}"), -1]), { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t("lines.index.all_#{filter}") }) + - %w(networks companies group_of_lines transport_modes).each do |filter| + - options_container = (referential_type == 'referential' && filter == 'transport_modes') ? referential.line_referential : referential + - if options_container&.send(filter).any? + - options = options_container.send(filter).collect { |f| [f.name, filter == 'transport_modes' ? f.name : f.id] }.unshift([t("lines.index.no_#{filter}"), -1]) + - matcher = filter == 'transport_modes' ? :transport_mode_name_eq : :"#{filter == 'group_of_lines' ? filter : filter.singularize}_id_eq" + .col-xs-3 + = f.select(matcher, options, { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t("lines.index.all_#{filter}") }) |
