diff options
| author | jpl | 2016-11-15 16:26:40 +0100 |
|---|---|---|
| committer | jpl | 2016-11-15 16:26:40 +0100 |
| commit | 78c2067553183cf83da2ba46f003628f1e96104a (patch) | |
| tree | 130e53823f39847db6096b2fc1324bdab71cb82f | |
| parent | 77c6b9b88c8b63c6d59c820cbb084fd99f48a011 (diff) | |
| download | chouette-core-78c2067553183cf83da2ba46f003628f1e96104a.tar.bz2 | |
Refs #1886: adding rails-select2 for lines searching autocomplete
| -rw-r--r-- | app/assets/javascripts/application.js | 2 | ||||
| -rw-r--r-- | app/assets/javascripts/select2.coffee | 6 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 25 | ||||
| -rw-r--r-- | app/views/lines/_lines.html.slim | 2 | ||||
| -rw-r--r-- | app/views/referential_lines/index.html.slim | 20 |
5 files changed, 41 insertions, 14 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 493c2a956..b0e100684 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,7 @@ //= require raphael //= require morrisjs //= require bootstrap-sass-official -//= require select2 +//= require select2-full //= require select2_locale_fr //= require typeahead.js //= require jquery-tokeninput diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee index 93f949a5a..27528961a 100644 --- a/app/assets/javascripts/select2.coffee +++ b/app/assets/javascripts/select2.coffee @@ -1,9 +1,9 @@ @select_2 = -> - $("[data-select2ed='true']").each(-> - $(this).select2 + $("[data-select2ed='true']").each -> + target = $(this) + target.select2 theme: 'bootstrap' language: 'fr' placeholder: target.data('select2ed-placeholder') - ) $(document).on 'ready page:load', select_2 diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index a566f440e..6a07e5093 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -89,7 +89,30 @@ class ReferentialLinesController < ChouetteController private def line_params - params.require(:line).permit( :transport_mode, :network_id, :company_id, :objectid, :object_version, :creation_time, :creator_id, :name, :number, :published_name, :transport_mode_name, :registration_number, :comment, :mobility_restricted_suitability, :int_user_needs, :flexible_service, :group_of_lines, :group_of_line_ids, :group_of_line_tokens, :url, :color, :text_color, :stable_id, { footnotes_attributes: [ :code, :label, :_destroy, :id ] } ) + params.require(:line).permit( + :transport_mode, + :network_id, + :company_id, + :objectid, + :object_version, + :creation_time, + :creator_id, + :name, :number, + :published_name, + :transport_mode_name, + :registration_number, + :comment, + :mobility_restricted_suitability, + :int_user_needs, + :flexible_service, + :group_of_lines, + :group_of_line_ids, + :group_of_line_tokens, + :url, + :color, + :text_color, + :stable_id, + { footnotes_attributes: [ :code, :label, :_destroy, :id ] } ) end end diff --git a/app/views/lines/_lines.html.slim b/app/views/lines/_lines.html.slim index 7de88c2c3..638fdfb6d 100644 --- a/app/views/lines/_lines.html.slim +++ b/app/views/lines/_lines.html.slim @@ -6,4 +6,4 @@ = paginated_content(@lines) .pagination - = will_paginate @lines, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer
\ No newline at end of file + = will_paginate @lines, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer diff --git a/app/views/referential_lines/index.html.slim b/app/views/referential_lines/index.html.slim index 5647bde0c..9f4094a98 100644 --- a/app/views/referential_lines/index.html.slim +++ b/app/views/referential_lines/index.html.slim @@ -1,23 +1,27 @@ = title_tag t('lines.index.title') -= search_form_for @q, :url => referential_lines_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| += search_form_for @q, url: referential_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-md-9 - = f.text_field :name_or_number_cont, :placeholder => "#{t('.name_or_number')}", :class => 'form-control' + = f.search_field :name_or_number_cont, placeholder: "#{t('.name_or_number')}", class: 'form-control' .input-group-btn - button.btn.btn-default type="submit" - i.fa.fa-search + button.btn.btn-primary type="submit" + i.fa.fa-search a data-toggle="collapse" data-parent="#search" href="#advanced_search" i.fa.fa-plus - = "#{t('.advanced_search')}" + = " #{t('.advanced_search')}" #advanced_search.panel-collapse.collapse .panel-body - = f.select(:network_id_eq, @referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), {include_blank: t('.all_networks')}, { :class => 'form-control' }) - = f.select(:company_id_eq, @referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), { include_blank: t('.all_companies')}, { :class => 'form-control' }) - = f.select(:group_of_lines_id_eq, @referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), {include_blank: t('.all_group_of_lines')}, { :class => 'form-control' }) + .row + .col-lg-4.col-md-4.col-sm-4.col-xs-4 + = f.select(:network_id_eq, @referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t('.all_networks') } ) + .col-lg-4.col-md-4.col-sm-4.col-xs-4 + = f.select(:company_id_eq, @referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t('.all_companies') }) + .col-lg-4.col-md-4.col-sm-4.col-xs-4 + = f.select(:group_of_lines_id_eq, @referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t('.all_group_of_lines') }) #lines = render 'lines' |
