diff options
| author | Marc Florisson | 2014-09-19 18:29:06 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2014-09-19 18:29:06 +0200 | 
| commit | c1fe600970a810d6116077c2b77370567cf92eaa (patch) | |
| tree | a899a81f6b7422fb744804fd80697767452201ad /app | |
| parent | 9bec29bc032934c60e23a01a6cfd4b1664aabc22 (diff) | |
| download | chouette-core-c1fe600970a810d6116077c2b77370567cf92eaa.tar.bz2 | |
remove comment_filter path on time table resource
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 14 | ||||
| -rw-r--r-- | app/inputs/search_time_table_input.rb | 13 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_combine_form.html.erb | 10 | ||||
| -rw-r--r-- | app/views/time_tables/comment_filter.json.rabl | 5 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 2 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.html.erb | 24 | 
6 files changed, 31 insertions, 37 deletions
| diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 4f7261311..2b3b556c8 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -20,21 +20,17 @@ class TimeTablesController < ChouetteController    def new      @autocomplete_items = ActsAsTaggableOn::Tag.all      new! do -      build_breadcrumb :show       +      build_breadcrumb :show      end    end    def edit      edit! do -      build_breadcrumb :edit       +      build_breadcrumb :edit        @autocomplete_items = ActsAsTaggableOn::Tag.all      end    end -  def comment_filter -    @time_tables = filtered_time_tables     -  end -    def index      request.format.kml? ? @per_page = nil : @per_page = 12 @@ -43,7 +39,7 @@ class TimeTablesController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end -        build_breadcrumb :index       +        build_breadcrumb :index        }      end    end @@ -65,10 +61,6 @@ class TimeTablesController < ChouetteController    protected -  def filtered_time_tables -    referential.time_tables.select{ |t| t.comment =~ /#{params[:q]}/i  } -  end -    def collection      ransack_params = params[:q]      # Hack to delete params can't be used by ransack diff --git a/app/inputs/search_time_table_input.rb b/app/inputs/search_time_table_input.rb index 49f266d7a..c7009b850 100644 --- a/app/inputs/search_time_table_input.rb +++ b/app/inputs/search_time_table_input.rb @@ -2,7 +2,7 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput    def search      if options[:json] -      tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"  +      tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"        template.content_tag( :script,         ("$(document).ready(function() {             $('##{dom_id}').tokenInput('#{options[:json]}', { @@ -10,6 +10,7 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput               tokenLimit: #{tokenLimit},               minChars: 2,               preventDuplicates: true, +             queryParam: 'q[comment_cont]',               hintText: '#{options[:hint_text]}',               noResultsText: '#{options[:no_result_text]}',               searchingText: '#{options[:searching_text]}', @@ -19,15 +20,15 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput          });").html_safe)      end    end -   +    def to_html -    input_wrapping do       +    input_wrapping do        label_html <<          builder.search_field(method, input_html_options) <<            search      end    end -   +    def input_html_options      super.merge({                    :required          => nil, @@ -35,6 +36,6 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput                    :class             => 'token-input',                    'data-model-name' => object.class.model_name.human                  }) -  end  -   +  end +  end diff --git a/app/views/time_table_combinations/_combine_form.html.erb b/app/views/time_table_combinations/_combine_form.html.erb index 8a651277e..a2124d9dc 100644 --- a/app/views/time_table_combinations/_combine_form.html.erb +++ b/app/views/time_table_combinations/_combine_form.html.erb @@ -20,7 +20,7 @@          queryTokenizer: Bloodhound.tokenizers.whitespace,          limit: 12,          remote: { -          url: '<%= comment_filter_referential_time_tables_path(@referential, :format => :json) %>', +          url: '<%= referential_time_tables_path(@referential, :format => :json) %>?q[comment_cont]=%QUERY',            },          }); @@ -38,12 +38,12 @@            source: timeTableSuggestion.ttAdapter()          }        ); -       -  $('#time_table_combination_combined_name').on('typeahead:selected', function($e, datum)  + +  $('#time_table_combination_combined_name').on('typeahead:selected', function($e, datum)    {      $('input[name="time_table_combination[combined_id]"]').val(datum.id); -  })       -       +  }) +  	});  </script>  <% end %> diff --git a/app/views/time_tables/comment_filter.json.rabl b/app/views/time_tables/comment_filter.json.rabl deleted file mode 100644 index dec29cb69..000000000 --- a/app/views/time_tables/comment_filter.json.rabl +++ /dev/null @@ -1,5 +0,0 @@ -collection @time_tables, :object_root => false - -node do |time_table| -  { :id => time_table.id, :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } -end                      diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 7d530a66e..459e8ea07 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -12,7 +12,7 @@      <%= form.input :facility %>      <%= form.input :vehicle_type_identifier%>      <%= form.input :objectid, :required => !@vehicle_journey.new_record?, :input_html => { :title => t("formtastic.titles.vehicle_journey.objectid")} %> -    <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => comment_filter_referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'),  :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map{ |time_table| { :id => time_table.id, :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } } ).to_json }  %> +    <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'),  :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map{ |time_table| { :id => time_table.id, :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } } ).to_json }  %>      <li class="input">  	    <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>      </li> diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index d045d4239..4b3dcd27a 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -33,14 +33,14 @@        <%= f.check_box :vehicle_journey_at_stops_departure_time_not_eq %>        <span class="vehicle_journey_at_stops_departure_time_gt"> -      <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(3i)]" %> type="hidden" value="1"> -      <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(2i)]" %> type="hidden" value="1"> -      <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(1i)]" %> type="hidden" value="2000"> -      <%= f.label :vehicle_journey_at_stops_departure_time_gt, t('.time_range') %> -      <%= select_hour(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").hour : 0, -                       :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(4i)") %> -      <%= select_minute(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").min : 0, -                         :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(5i)") %> +        <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(3i)]" %> type="hidden" value="1"> +        <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(2i)]" %> type="hidden" value="1"> +        <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(1i)]" %> type="hidden" value="2000"> +        <%= f.label :vehicle_journey_at_stops_departure_time_gt, t('.time_range') %> +        <%= select_hour(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").hour : 0, +                         :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(4i)") %> +        <%= select_minute(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").min : 0, +                           :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(5i)") %>        </span>        </div>      </div> @@ -57,6 +57,11 @@          var time_tables_url = function(){            return '<%= referential_time_tables_path(@referential, :format => :json) %>?route_id=<%= @route.id %>';          }; +        var time_table_to_html = function( item ){ +          return '<li><div class=\"comment\">' + item.comment + +              '</div><div class=\"info\">' + item.time_table_bounding + +              '</div><div class=\"info\">' +  item.composition_info + '</div></li>'; +        };  		$( "#q_time_tables_id_eq" ).tokenInput( time_tables_url, {            crossDomain: false,            prePopulate: $('#q_time_tables_id_eq').data('pre'), @@ -66,7 +71,8 @@            hintText: '<%= t('search_hint') %>',            noResultsText: '<%= t('no_result_text') %>',            searchingText: '<%= t('searching_term') %>', -          resultsFormatter: function(item){ return '<li><div class=\"name\">' + item.comment + '</div><div class=\"info\">' + item.start_date + ' ' + item.end_date + '</div></li>' }, +          resultsFormatter: time_table_to_html, +          tokenFormatter: time_table_to_html,          });  		$( "#q_journey_pattern_id_eq" ).tokenInput( '<%= referential_line_route_journey_patterns_path(@referential, @line, @route, :format => :json) %>', {            crossDomain: false, | 
