diff options
| -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 | ||||
| -rw-r--r-- | config/locales/lines.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/lines.fr.yml | 2 | ||||
| -rw-r--r-- | db/schema.rb | 16 | ||||
| -rw-r--r-- | spec/models/line_referential_spec.rb | 2 | 
8 files changed, 27 insertions, 44 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}") }) diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml index 84285bbcb..1ed57d79f 100644 --- a/config/locales/lines.en.yml +++ b/config/locales/lines.en.yml @@ -27,9 +27,11 @@ en:        no_networks: "No networks"        no_companies: "No companies"        no_group_of_lines: "No group of lines" +      no_transport_mode: No transport mode        all_networks: "All networks"        all_companies: "All companies"        all_group_of_lines: "All group of lines" +      all_transport_modes: All transport modes        multi_selection: "Multiple selection"        multi_selection_enable: "Enable multiple selection"        multi_selection_disable: "Disable multiple selection" diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml index b5a13c34a..abd6696b4 100644 --- a/config/locales/lines.fr.yml +++ b/config/locales/lines.fr.yml @@ -27,9 +27,11 @@ fr:        no_networks: "Aucun réseaux"        no_companies: "Aucun transporteurs"        no_group_of_lines: "Aucun groupes de ligne" +      no_transport_modes: Aucun mode de transport        all_networks: "Tous les réseaux"        all_companies: "Tous les transporteurs"        all_group_of_lines: "Tous les groupes de ligne" +      all_transport_modes: Tous les modes de transport        multi_selection: "Sélection multiple"        multi_selection_enable: "Activer la sélection multiple"        multi_selection_disable: "Désactiver la sélection multiple" diff --git a/db/schema.rb b/db/schema.rb index 4a3fd73c7..12b08ac5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -147,22 +147,6 @@ ActiveRecord::Schema.define(version: 20161117104301) do    add_index "connection_links", ["objectid"], :name => "connection_links_objectid_key", :unique => true -  create_table "delayed_jobs", force: true do |t| -    t.integer  "priority",   default: 0 -    t.integer  "attempts",   default: 0 -    t.text     "handler" -    t.text     "last_error" -    t.datetime "run_at" -    t.datetime "locked_at" -    t.datetime "failed_at" -    t.string   "locked_by" -    t.string   "queue" -    t.datetime "created_at" -    t.datetime "updated_at" -  end - -  add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" -    create_table "exports", force: true do |t|      t.integer  "referential_id",  limit: 8      t.string   "status" diff --git a/spec/models/line_referential_spec.rb b/spec/models/line_referential_spec.rb index 942795076..e1e75e4d6 100644 --- a/spec/models/line_referential_spec.rb +++ b/spec/models/line_referential_spec.rb @@ -12,7 +12,7 @@ RSpec.describe LineReferential, :type => :model do    describe "#transport_modes" do      it 'returns a list of all transport modes' do -      expect(FactoryGirl.create(:line_referential).transport_modes).to eq( Chouette::TransportMode.all.select { |tm| tm.positive? } ) +      expect(FactoryGirl.create(:line_referential).transport_modes).to eq( Chouette::TransportMode.all.select { |tm| tm.to_i.positive? } )      end    end  end | 
