diff options
| author | Michel Etienne | 2014-09-19 14:56:22 +0200 | 
|---|---|---|
| committer | Michel Etienne | 2014-09-19 14:56:22 +0200 | 
| commit | 9bec29bc032934c60e23a01a6cfd4b1664aabc22 (patch) | |
| tree | 528b7c105d0aeee7f437939d61cb0bf2a52aae66 /app | |
| parent | 4a278cad118f7110cc8304da6288e4e6b6047181 (diff) | |
| parent | e07b540b2f19e5d89ec481ca478f175bc20e0e44 (diff) | |
| download | chouette-core-9bec29bc032934c60e23a01a6cfd4b1664aabc22.tar.bz2 | |
Merge branch 'sismo' of github.com:afimb/chouette2 into sismo
Diffstat (limited to 'app')
23 files changed, 229 insertions, 97 deletions
| diff --git a/app/assets/stylesheets/main/time_table_combinations.css.scss b/app/assets/stylesheets/main/time_table_combinations.css.scss index 4cc0cfdc2..70dc2e535 100644 --- a/app/assets/stylesheets/main/time_table_combinations.css.scss +++ b/app/assets/stylesheets/main/time_table_combinations.css.scss @@ -1,6 +1,9 @@ -#combine_form{ - +#modal_combine{      .time_table_combination{ + +        .radio input[type="radio"]{ +            position: inherit !important; +        }          .inputs{ diff --git a/app/assets/stylesheets/main/vehicle_journeys.css.scss b/app/assets/stylesheets/main/vehicle_journeys.css.scss index c026923fb..f6e21ad68 100644 --- a/app/assets/stylesheets/main/vehicle_journeys.css.scss +++ b/app/assets/stylesheets/main/vehicle_journeys.css.scss @@ -38,6 +38,24 @@  #workspace.vehicle_journeys.index  { +    #search{ +        .panel-heading .btn{ +            margin-left: 20px; +        } +         +        ul.token-input-list{ +            display: inline-block; +            vertical-align: middle; +            margin-left: 20px; +            width: 250px; +        } + +        .advanced_search_link{ +            vertical-align: -webkit-baseline-middle; +        } +         +    } +          table{          margin: 20px 0 0 0; diff --git a/app/controllers/journey_patterns_controller.rb b/app/controllers/journey_patterns_controller.rb index 26c54e9c6..18e7ee28b 100644 --- a/app/controllers/journey_patterns_controller.rb +++ b/app/controllers/journey_patterns_controller.rb @@ -2,6 +2,7 @@ class JourneyPatternsController < ChouetteController    defaults :resource_class => Chouette::JourneyPattern    respond_to :html +  respond_to :json, :only => :index    respond_to :js, :only => [:new_vehicle_journey, :show]    respond_to :kml, :only => :show @@ -14,7 +15,7 @@ class JourneyPatternsController < ChouetteController    alias_method :route, :parent    alias_method :journey_pattern, :resource -  def index      +  def index      index! do |format|        format.html { redirect_to referential_line_route_path(@referential,@line,@route) }      end @@ -37,10 +38,16 @@ class JourneyPatternsController < ChouetteController      @vehicle_journey.update_journey_pattern(resource)      render "vehicle_journeys/select_journey_pattern"    end -  # overwrite inherited resources to use delete instead of destroy  +  # overwrite inherited resources to use delete instead of destroy    # foreign keys will propagate deletion)    def destroy_resource(object)          object.delete    end + +  def collection +    @q = route.journey_patterns.search( params[:q]) +    @journey_patterns ||= @q.result(:distinct => true).order(:name) +  end +  end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 957603b3b..4f7261311 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -32,10 +32,7 @@ class TimeTablesController < ChouetteController    end    def comment_filter -    respond_to do |format| -      format.json { render :json => filtered_time_tables_maps} -    end - +    @time_tables = filtered_time_tables        end    def index @@ -68,11 +65,6 @@ class TimeTablesController < ChouetteController    protected -  def filtered_time_tables_maps -    filtered_time_tables.collect do |time_table| -      { :id => time_table.id, :name => time_table_description(time_table) } -    end -  end    def filtered_time_tables      referential.time_tables.select{ |t| t.comment =~ /#{params[:q]}/i  }    end diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 8dc425ffc..9e809a719 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -9,10 +9,6 @@ class VehicleJourneysController < ChouetteController      end    end -  def timeless -    @vehicle_journeys = parent.vehicle_journeys.timeless -  end -    def select_journey_pattern      if params[:journey_pattern_id]        selected_journey_pattern = Chouette::JourneyPattern.find( params[:journey_pattern_id]) @@ -52,15 +48,18 @@ class VehicleJourneysController < ChouetteController    alias_method :vehicle_journey, :resource    def collection -    adapt_time_params -    @q = select_vehicles.search(params[:q]) -    @vehicle_journeys ||= @q.result.order( "vehicle_journey_at_stops.departure_time").paginate(:page => params[:page], :per_page => 8) +    @vehicle_filter = VehicleFilter.new( adapted_params) +    @q = @vehicle_filter.vehicle_journeys.search( @vehicle_filter.filtered_params) +    @vehicle_journeys ||= @q.result( :distinct => true ).order( "vehicle_journey_at_stops.departure_time").paginate(:page => params[:page], :per_page => 8)    end -  def adapt_time_params -    hour_entry = "vehicle_journey_at_stops_departure_time_gt(4i)".to_sym -    if params[:q] && params[:q][ hour_entry] -      params[:q].merge! hour_entry => (params[:q][ hour_entry].to_i - utc_offset) +  def adapted_params +    params.tap do |adapted_params| +      adapted_params.merge!( :route => parent) +      hour_entry = "vehicle_journey_at_stops_departure_time_gt(4i)".to_sym +      if params[:q] && params[:q][ hour_entry] +        adapted_params[:q].merge! hour_entry => (params[:q][ hour_entry].to_i - utc_offset) +      end      end    end    def utc_offset @@ -68,13 +67,6 @@ class VehicleJourneysController < ChouetteController      sample = [2001,1,1,10,0]      Time.zone.local(*sample).utc.hour - Time.utc(*sample).hour    end -  def select_vehicles -    if params[:q] && params[:q][ :time_tables_id_eq ] -      parent.sorted_vehicle_journeys.joins( :time_tables).where( "time_tables_vehicle_journeys.time_table_id" => params[:q][ :time_tables_id_eq ].split(',')) -    else -      parent.sorted_vehicle_journeys -    end -  end    def matrix      {}.tap do |hash| diff --git a/app/helpers/history_helper.rb b/app/helpers/history_helper.rb index 1b9d056ab..ccc6374a1 100644 --- a/app/helpers/history_helper.rb +++ b/app/helpers/history_helper.rb @@ -1,7 +1,7 @@  module HistoryHelper    def creation_tag(object) -    field_set_tag t("layouts.creation_tag.title"), :class => "history_tag" do +    field_set_tag t("layouts.history_tag.title"), :class => "history_tag" do        content_tag :ul do          [(content_tag :li do            if object.has_attribute?(:creation_time)   diff --git a/app/inputs/search_stop_area_input.rb b/app/inputs/search_stop_area_input.rb index 8003a513a..44f9cf82a 100644 --- a/app/inputs/search_stop_area_input.rb +++ b/app/inputs/search_stop_area_input.rb @@ -13,7 +13,7 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput               noResultsText: '#{options[:no_result_text]}',               searchingText: '#{options[:searching_text]}',               resultsFormatter: function(item){ return '<li><div class=\"name\">' + item.name + '</div><div class=\"info\">' + item.area_type + '</div><div class=\"info\">' +  item.zip_code + ' ' + item.city_name + '</div></li>' }, -             tokenFormatter: function(item) { return '<li><p>' + item.name + '</p></li>' } +             tokenFormatter: function(item){ return '<li><div class=\"name\">' + item.name + '</div><div class=\"info\">' + item.area_type + '</div><div class=\"info\">' +  item.zip_code + ' ' + item.city_name + '</div></li>' },             });          });").html_safe)      end diff --git a/app/inputs/search_time_table_input.rb b/app/inputs/search_time_table_input.rb new file mode 100644 index 000000000..49f266d7a --- /dev/null +++ b/app/inputs/search_time_table_input.rb @@ -0,0 +1,40 @@ +class SearchTimeTableInput < Formtastic::Inputs::SearchInput + +  def search +    if options[:json] +      tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"  +      template.content_tag( :script, +       ("$(document).ready(function() { +           $('##{dom_id}').tokenInput('#{options[:json]}', { +             crossDomain: false, +             tokenLimit: #{tokenLimit}, +             minChars: 2, +             preventDuplicates: true, +             hintText: '#{options[:hint_text]}', +             noResultsText: '#{options[:no_result_text]}', +             searchingText: '#{options[:searching_text]}', +             resultsFormatter: 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>' }, +             tokenFormatter: 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>' }, +           }); +        });").html_safe) +    end +  end +   +  def to_html +    input_wrapping do       +      label_html << +        builder.search_field(method, input_html_options) << +          search +    end +  end +   +  def input_html_options +    super.merge({ +                  :required          => nil, +                  :autofocus         => nil, +                  :class             => 'token-input', +                  'data-model-name' => object.class.model_name.human +                }) +  end  +   +end diff --git a/app/models/vehicle_filter.rb b/app/models/vehicle_filter.rb new file mode 100644 index 000000000..ba8cce867 --- /dev/null +++ b/app/models/vehicle_filter.rb @@ -0,0 +1,57 @@ +class VehicleFilter +  include ActiveModel::Validations +  include ActiveModel::Conversion +  extend ActiveModel::Naming + +  attr_accessor :route +  attr_accessor :q + +  def initialize(attributes = {}) +    attributes.each do |name, value| +      send("#{name}=", value) if self.respond_to? name.to_sym +    end +  end + +  def without_any_time_table? +    q && q[ "time_tables_id_not_eq" ] && q[ "time_tables_id_not_eq" ]=="1" +  end +  def without_any_passing_time? +    q && q[ "vehicle_journey_at_stops_departure_time_not_eq" ] && +      q[ "vehicle_journey_at_stops_departure_time_not_eq" ]=="1" +  end +  def vehicles_passing_time_filtered +    if without_any_passing_time? +      route.vehicle_journeys.includes( :vehicle_journey_at_stops).where( :vehicle_journey_at_stops => { :id => nil}) +    else +      route.sorted_vehicle_journeys +    end +  end +  def vehicle_journeys +    if without_any_time_table? +      vehicles_passing_time_filtered.includes( :time_tables).where( :time_tables => { :id => nil}) +    elsif time_table_ids.empty? +      vehicles_passing_time_filtered +    else +      vehicles_passing_time_filtered.joins( :time_tables).where( "time_tables_vehicle_journeys.time_table_id" => time_table_ids) +    end +  end +  def time_table_ids +    return [] unless q && q[ "time_tables_id_eq" ] +    q[ "time_tables_id_eq" ].split(',') +  end +  def filtered_params +    return {} unless q +    q.tap do |filtered_params| +      if without_any_passing_time? +        1.upto( 5 ) do |index| +          q.delete "vehicle_journey_at_stops_departure_time_gt(#{index}i)" +        end +      end +      q.delete "time_tables_id_eq" +      q.delete "time_tables_id_not_eq" +      q.delete "vehicle_journey_at_stops_departure_time_not_eq" +    end +  end + + +end diff --git a/app/views/connection_links/select_areas.html.erb b/app/views/connection_links/select_areas.html.erb index 17f6b193f..c98b4994e 100644 --- a/app/views/connection_links/select_areas.html.erb +++ b/app/views/connection_links/select_areas.html.erb @@ -3,8 +3,8 @@  <%= semantic_form_for [@referential, @connection_link] do |form| %>  <div>    <%= form.inputs do %> -    <%= form.input :departure_id, :as => :search_stop_area, :json => referential_connection_link_connection_link_areas_path(@referential, @connection_link, :format => :json), :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @departure.present? ? [ { :id => @departure.id.to_s, :name => "#{@departure.name}" } ]: [] ).to_json } %> -    <%= form.input :arrival_id, :as => :search_stop_area, :json => referential_connection_link_connection_link_areas_path(@referential, @connection_link, :format => :json), :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @arrival.present? ? [ { :id => @arrival.id.to_s, :name => "#{@arrival.name}" } ]: [] ).to_json }  %> +    <%= form.input :departure_id, :as => :search_stop_area, :json => referential_connection_link_connection_link_areas_path(@referential, @connection_link, :format => :json), :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('stop_areas/show', [@departure], :view_path => 'app/views', :format => :json).render  } %> +    <%= form.input :arrival_id, :as => :search_stop_area, :json => referential_connection_link_connection_link_areas_path(@referential, @connection_link, :format => :json), :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('stop_areas/show', [@arrival], :view_path => 'app/views', :format => :json).render }  %>    <% end %>     <%= form.actions do %> diff --git a/app/views/stop_areas/add_children.html.erb b/app/views/stop_areas/add_children.html.erb index 33cc81b27..732e28466 100644 --- a/app/views/stop_areas/add_children.html.erb +++ b/app/views/stop_areas/add_children.html.erb @@ -3,7 +3,7 @@  <%= semantic_form_for [@referential, @stop_area] do |form| %>  <div>    <%= form.inputs do %> -    <%= form.input :children_ids, :as => :search_stop_area, :json => referential_stop_area_stop_area_children_path(@referential, @stop_area, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @children.map { |child| { :id => child.id.to_s, :name => "#{child.name}" } } ).to_json }  %> +    <%= form.input :children_ids, :as => :search_stop_area, :json => referential_stop_area_stop_area_children_path(@referential, @stop_area, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('stop_areas/index', @children, :view_path => 'app/views', :format => :json).render }  %>    <% end %>     <%= form.actions do %> diff --git a/app/views/stop_areas/index.rabl b/app/views/stop_areas/index.rabl new file mode 100644 index 000000000..72b736858 --- /dev/null +++ b/app/views/stop_areas/index.rabl @@ -0,0 +1,9 @@ +collection @stop_areas + +node do |stop_area| +  { :id => stop_area.id, :name => stop_area.name || "", :zip_code => stop_area.zip_code || "", :city_name => stop_area.city_name || "" }   +end + +node :area_type do |area| +  I18n.t("area_types.label.#{area.area_type.underscore}") || "" +end
\ No newline at end of file diff --git a/app/views/stop_areas/select_parent.html.erb b/app/views/stop_areas/select_parent.html.erb index 9bd25f4dd..9909e49d0 100644 --- a/app/views/stop_areas/select_parent.html.erb +++ b/app/views/stop_areas/select_parent.html.erb @@ -2,8 +2,8 @@  <%= semantic_form_for [@referential, @stop_area] do |form| %>  <div> -  <%= form.inputs do %> -    <%= form.input :parent_id, :as => :search_stop_area, :json => referential_stop_area_stop_area_parents_path(@referential, @stop_area, :format => :json), :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @parent.present? ? [ { :id => @parent.id.to_s, :name => "#{@parent.name}" } ]: [] ).to_json }  %> +  <%= form.inputs do %>     +    <%= form.input :parent_id, :as => :search_stop_area, :json => referential_stop_area_stop_area_parents_path(@referential, @stop_area, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'), :searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('stop_areas/show', [@parent], :view_path => 'app/views', :format => :json).render }  %>    <% end %>     <%= form.actions do %> diff --git a/app/views/stop_areas/show.rabl b/app/views/stop_areas/show.rabl new file mode 100644 index 000000000..a03a3511d --- /dev/null +++ b/app/views/stop_areas/show.rabl @@ -0,0 +1,9 @@ +object @stop_area + +node do |stop_area| +  { :id => stop_area.id, :name => stop_area.name || "", :zip_code => stop_area.zip_code || "", :city_name => stop_area.city_name || "" }   +end + +node :area_type do |area| +  I18n.t("area_types.label.#{area.area_type.underscore}") || "" +end diff --git a/app/views/time_table_combinations/_combine_form.html.erb b/app/views/time_table_combinations/_combine_form.html.erb index e899ee1f8..8a651277e 100644 --- a/app/views/time_table_combinations/_combine_form.html.erb +++ b/app/views/time_table_combinations/_combine_form.html.erb @@ -2,7 +2,7 @@    <div class="modal-body">    <%= render "shared/flash_messages" %>    <%= form.inputs do %> -    <%= form.input :operation, :as => :radio, :collection => Hash[TimeTableCombination.operations.map {|b| [t( b, :scope => "time_table_combinations.operations"),b]}]  %> +    <%= form.input :operation, :as => :radio, :collection => Hash[TimeTableCombination.operations.map {|b| [t( b, :scope => "time_table_combinations.operations"),b]}] %>      <%= form.input :combined_name, :class =>  "typeahead", :input_html => { :class => "form-control" } %>      <%= form.input :combined_id, :as => :hidden  %>    <% end %> @@ -34,7 +34,7 @@          },          {            name: 'comment', -          displayKey: 'name', +          displayKey: 'comment',            source: timeTableSuggestion.ttAdapter()          }        ); diff --git a/app/views/time_tables/comment_filter.json.rabl b/app/views/time_tables/comment_filter.json.rabl new file mode 100644 index 000000000..dec29cb69 --- /dev/null +++ b/app/views/time_tables/comment_filter.json.rabl @@ -0,0 +1,5 @@ +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/time_tables/index.json.rabl b/app/views/time_tables/index.json.rabl new file mode 100644 index 000000000..dec29cb69 --- /dev/null +++ b/app/views/time_tables/index.json.rabl @@ -0,0 +1,5 @@ +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/time_tables/time_tables.json.rabl b/app/views/time_tables/time_tables.json.rabl new file mode 100644 index 000000000..dec29cb69 --- /dev/null +++ b/app/views/time_tables/time_tables.json.rabl @@ -0,0 +1,5 @@ +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 d5d4cffdd..7d530a66e 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 => :text,  :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map { |time_table| { :id => time_table.id, :name => time_table_description(time_table) } } ).to_json }  %> +    <%= 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 }  %>      <li class="input">  	    <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>      </li> @@ -65,17 +65,3 @@    <%= javascript_include_tag edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey, :format => :js) %>  <% end %> -<script> -	$(function() { -          $( "#vehicle_journey_time_table_tokens" ).tokenInput('<%= comment_filter_referential_time_tables_path(@referential, :format => :json) %>', { -       crossDomain: false, -       prePopulate: $('#time_table_tokens').data('pre'), -       minChars: 1, -       preventDuplicates: true, -       hintText: '<%= t('search_hint') %>', -       noResultsText: '<%= t('no_result_text') %>', -       searchingText: '<%= t('searching_term') %>' -    }); -	}); -</script> - diff --git a/app/views/vehicle_journeys/_sidebar.html.erb b/app/views/vehicle_journeys/_sidebar.html.erb index 355f90618..cb3236c18 100644 --- a/app/views/vehicle_journeys/_sidebar.html.erb +++ b/app/views/vehicle_journeys/_sidebar.html.erb @@ -1,6 +1,5 @@    <ul class="actions">      <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> -    <li><%= link_to t('.timeless'), timeless_referential_line_route_vehicle_journeys_path(@referential, @line, @route), :class => "link" %></li>  	<li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li>    </ul>    <div class="btn-group"> diff --git a/app/views/vehicle_journeys/_vehicle_journeys.html.erb b/app/views/vehicle_journeys/_vehicle_journeys.html.erb index ed9ad67ca..529b2683b 100644 --- a/app/views/vehicle_journeys/_vehicle_journeys.html.erb +++ b/app/views/vehicle_journeys/_vehicle_journeys.html.erb @@ -34,7 +34,7 @@      <td class="stop_area"><%= sp.stop_area.name %></td>      <% @vehicle_journeys.each do |vj| %>        <td class="hours <%= missing_time_check(@matrix["#{vj.id}-#{sp.id}"]) %>"> -        <%= (@matrix["#{vj.id}-#{sp.id}"] && @matrix["#{vj.id}-#{sp.id}"].departure_time) ? l( @matrix["#{vj.id}-#{sp.id}"].departure_time, :format => :hour) : "" %> +        <%= (@matrix["#{vj.id}-#{sp.id}"] && @matrix["#{vj.id}-#{sp.id}"].departure_time) ? l( @matrix["#{vj.id}-#{sp.id}"].departure_time, :format => :hour) : "--" %>        </td>      <% end %>    </tr> diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index 4ee1881b0..d045d4239 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -4,17 +4,9 @@  <div class="panel panel-default">    <div class="panel-heading">      <div class="input-group col-md-9"> -      <%= f.collection_select :journey_pattern_id_eq, @route.journey_patterns.map{|j| j.name = journey_name(j); j}, :id, :name, :include_blank => "All"  %> -      <%= f.label :time_tables_id_eq, "TM" %> -      <%= f.text_field :time_tables_id_eq, :input_html => { :"data-pre" => [].to_json} %> -      <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)") %> +      <%= f.label :journey_pattern_id_eq, "Missions" %> +      <%= f.text_field :journey_pattern_id_eq %> +        <div class="input-group-btn">          <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>        </div> @@ -26,7 +18,31 @@    <div id="advanced_search" class="panel-collapse collapse">      <div class="panel-body"> -      <p>other fields</p> +      <div> +      <%= f.label :time_tables_id_not_eq, "Sans calendrier" %> +      <%= f.check_box :time_tables_id_not_eq %> + +      <span class="time_tables_id_eq"> +        <%= f.label :time_tables_id_eq, "Sélectionner calendriers" %> +        <%= f.text_field :time_tables_id_eq, :input_html => { :"data-pre" => [].to_json} %> +      </span> +      </div> + +      <div> +      <%= f.label :vehicle_journey_at_stops_departure_time_not_eq, "Sans horaire" %> +      <%= 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)") %> +      </span> +      </div>      </div>    </div>  </div> @@ -52,5 +68,22 @@            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>' },          }); +		$( "#q_journey_pattern_id_eq" ).tokenInput( '<%= referential_line_route_journey_patterns_path(@referential, @line, @route, :format => :json) %>', { +          crossDomain: false, +          prePopulate: $('#q_journey_pattern_id_eq').data('pre'), +          minChars: 1, +          queryParam: 'q[name_cont]', +          propertyToSearch: 'name', +          hintText: '<%= t('search_hint') %>', +          noResultsText: '<%= t('no_result_text') %>', +          searchingText: '<%= t('searching_term') %>', +          resultsFormatter: function(item){ return '<li><div class=\"name\">' + item.name + ', (' + item.id + ') </div></li>' }, +        }); +        $( 'input[name="q[time_tables_id_not_eq]"]').change( function(){ +            $('span.time_tables_id_eq').toggle( $(this).filter(":checked").val()==undefined); +        }); +        $( 'input[name="q[vehicle_journey_at_stops_departure_time_not_eq]"]').change( function(){ +            $('span.vehicle_journey_at_stops_departure_time_gt').toggle( $(this).filter(":checked").val()==undefined); +        });  	});  </script> diff --git a/app/views/vehicle_journeys/timeless.html.erb b/app/views/vehicle_journeys/timeless.html.erb deleted file mode 100644 index af5ee93ea..000000000 --- a/app/views/vehicle_journeys/timeless.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%= title_tag t('.title', :route => @route.name ) %> - -<div class="timeless_vehicle_journey_index"> -  <div class="summary"> -    <p> -      <label><%= @route.human_attribute_name(:line) %>: </label> -      <%= link_to line_formatted_name( @line), [@referential, @line] %> -    </p> -    <p> -      <label><%= Chouette::Route.model_name.human %>: </label> -      <%= link_to @route.name, [@referential, @line, @route] %> -    </p> -  </div> -</div> - -<h3><%= t('.vehicles_list') %></h3> -<div class="timeless_vehicles"> -  <%= render :partial => "timeless_vehicle_journey", :collection => @vehicle_journeys, :as => :vehicle_journey %> -</div> - -<% content_for :sidebar do %> -<ul class="actions"> -  <li> -    <%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %> -  </li> -  <li><%= link_to t('.vehicle_journeys'), [@referential, @line, @route, :vehicle_journeys], :class => "link" %></li> -</ul> -<% end %> | 
