diff options
| -rw-r--r-- | app/controllers/autocomplete_time_tables_controller.rb | 33 | ||||
| -rw-r--r-- | app/helpers/time_tables_helper.rb | 54 | ||||
| -rw-r--r-- | app/inputs/search_time_table_input.rb | 5 | ||||
| -rw-r--r-- | app/views/autocomplete_time_tables/index.rabl | 10 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_combine_form.html.erb | 2 | ||||
| -rw-r--r-- | app/views/time_tables/_properties_show.html.erb | 127 | ||||
| -rw-r--r-- | app/views/time_tables/_show_time_table.html.erb | 14 | ||||
| -rw-r--r-- | app/views/time_tables/_time_table.html.erb | 14 | ||||
| -rw-r--r-- | app/views/time_tables/index.html.erb | 12 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 8 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_show_popover.html.erb | 12 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_time_filter.html.erb | 13 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_time_table.html.erb | 7 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb | 15 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.html.erb | 27 | ||||
| -rw-r--r-- | config/routes.rb | 1 | 
16 files changed, 221 insertions, 133 deletions
| diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb new file mode 100644 index 000000000..c556bb71c --- /dev/null +++ b/app/controllers/autocomplete_time_tables_controller.rb @@ -0,0 +1,33 @@ +class AutocompleteTimeTablesController < InheritedResources::Base +  respond_to :json, :only => [:index] + +  before_filter :switch_referential + +  def switch_referential +    Apartment::Database.switch(referential.slug) +  end + +  def referential +    @referential ||= current_organisation.referentials.find params[:referential_id] +  end + +  protected + +  def select_time_tables +    if params[:route_id] +      referential.time_tables.joins( vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})") +   else +      referential.time_tables +   end +  end + +  def referential_time_tables +    @referential_time_tables ||= select_time_tables +  end + +  def collection +    comment_selection = referential_time_tables.select{ |p| p.comment =~ /#{params[:q]}/i  } +    tag_selection = referential_time_tables.tagged_with( params[:q], :wild => true) +    @time_tables = (comment_selection + tag_selection).uniq +  end +end diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb index e0c1fc2db..9fdb791b1 100644 --- a/app/helpers/time_tables_helper.rb +++ b/app/helpers/time_tables_helper.rb @@ -1,57 +1,3 @@  module TimeTablesHelper -  def time_table_state_code(time_table) -    if time_table.validity_out_from_on?(Date.today) -      "validity_out" -    elsif time_table.validity_out_between?(Date.today,Date.today+7.day) -      "validity_out_soon" -    else -      "validity_regular" -    end -  end -  def tag_list_shortened(time_table) -    time_table.tags.join(', ').truncate(30, separator: ',') -  end -  def bounding_info(time_table) -    return t('time_tables.time_table.empty') if time_table.bounding_dates.empty? -    t('time_tables.time_table.bounding', -        :start => l(time_table.bounding_dates.min), -        :end => l(time_table.bounding_dates.max)) -  end -  def bounding_short_info(dates) -    return t('time_tables.time_table.empty') if dates.empty? -    "#{l(dates.min)} #{l(dates.max)}" -  end -  def time_table_bounding( time_table) -    bounding_short_info( time_table.bounding_dates) -  end -  def time_tables_shortest_info( vehicle) -    bounding_short_info( vehicle.bounding_dates) -  end -  def time_tables_info( vehicle) -    vehicle.time_tables.map do |time_table| -      "#{time_table_bounding( time_table)} - #{composition_info(time_table)}" -    end.join( "\n") -  end - -  def composition_info(time_table) -    return if time_table.bounding_dates.empty? -    if time_table.dates.empty? -      t('time_tables.time_table.periods_count', :count => time_table.periods.count) -    elsif time_table.periods.empty? -      t('time_tables.time_table.dates_count', :count => time_table.dates.count) -    else -      t('time_tables.time_table.periods_dates_count', -        :dates_count => time_table.dates.count, -        :periods_count => time_table.periods.count) -    end -  end - -  def time_table_description(time_table) -    if time_table.bounding_dates.empty? -      "#{time_table.comment} (vide)" -    else -      "#{time_table.comment} : #{time_table_bounding( time_table)} - #{composition_info(time_table)}" -    end -  end  end diff --git a/app/inputs/search_time_table_input.rb b/app/inputs/search_time_table_input.rb index 877333592..c64280e6d 100644 --- a/app/inputs/search_time_table_input.rb +++ b/app/inputs/search_time_table_input.rb @@ -25,12 +25,11 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput               minChars: 2,               propertyToSearch: 'comment',               preventDuplicates: true, -             queryParam: 'q[comment_cont]',               hintText: '#{options[:hint_text]}',               noResultsText: '#{options[:no_result_text]}',               searchingText: '#{options[:searching_text]}',               resultsFormatter: time_table_formatter, -             tokenFormatter: time_table_formatter,              +             tokenFormatter: time_table_formatter,             });          });").html_safe)      end @@ -49,7 +48,7 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput                    :required          => nil,                    :autofocus         => nil,                    :class             => 'token-input', -                  'data-model-name' => object.class.model_name.human                   +                  'data-model-name' => object.class.model_name.human                  })    end diff --git a/app/views/autocomplete_time_tables/index.rabl b/app/views/autocomplete_time_tables/index.rabl new file mode 100644 index 000000000..0389c26b0 --- /dev/null +++ b/app/views/autocomplete_time_tables/index.rabl @@ -0,0 +1,10 @@ +collection @time_tables, :object_root => false + +node do |time_table| +  { :id => time_table.id, :comment => time_table.comment, +    :time_table_bounding => time_table.presenter.time_table_bounding, +    :composition_info => time_table.presenter.composition_info, +    :tags => time_table.tags.join(','), +    :day_types => %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| time_table.send(d) }.map{ |d| time_table.human_attribute_name(d).first(2)}.join('')} +end + diff --git a/app/views/time_table_combinations/_combine_form.html.erb b/app/views/time_table_combinations/_combine_form.html.erb index aad31a218..dd9cd9b92 100644 --- a/app/views/time_table_combinations/_combine_form.html.erb +++ b/app/views/time_table_combinations/_combine_form.html.erb @@ -3,7 +3,7 @@    <%= 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 :combined_id, :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'), :tokenLimit => 1 %> +    <%= form.input :combined_id, :label => t('.time_tables'), :as => :search_time_table, :json => referential_autocomplete_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'), :searching_text => t('searching_term'), :tokenLimit => 1 %>    <% end %>    </div>    <div class="modal-footer"> diff --git a/app/views/time_tables/_properties_show.html.erb b/app/views/time_tables/_properties_show.html.erb new file mode 100644 index 000000000..bc2f88ddf --- /dev/null +++ b/app/views/time_tables/_properties_show.html.erb @@ -0,0 +1,127 @@ +<div class="time_table_show"> + +  <div class="resume"> +    <div class="validity <%= time_table_state_code(@time_table) %>"></div> +    <label> +      <% if @time_table.bounding_dates.empty? %> +        <%= t(".resume_empty") %> +      <% else %> +        <%= t(".resume", :start_date => l(@time_table.bounding_dates.min), +                   :end_date => l(@time_table.bounding_dates.max)) %> +      <% end %> +    </label> +  </div> +  <div class="summary"> +    <p> +      <label><%= @time_table.human_attribute_name("version") %>: </label> +      <%= @time_table.version %> +    </p> +    <p> +      <label><%= @time_table.human_attribute_name("tag_list") %>: </label> +      <%= @time_table.tag_list %> +    </p> +    <p> +      <label><%= @time_table.human_attribute_name("day_types") %>:  </label> +      <% if @time_table.int_day_types & 508 == 0 %> +        <label><%= @time_table.human_attribute_name("none") %></label> +      <% else %> +	      <% if @time_table.monday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("monday") %> </span> +	      <% end %> + +	      <% if @time_table.tuesday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("tuesday") %> </span> +	      <% end %> + +	      <% if @time_table.wednesday %> +	        <span class='day_type'> <%= @time_table.human_attribute_name("wednesday") %> </span> +	      <% end %> + +	      <% if @time_table.thursday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("thursday") %> </span> +	      <% end %> + +	      <% if @time_table.friday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("friday") %> </span> +	      <% end %> + +	      <% if @time_table.saturday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("saturday") %> </span> +	      <% end %> + +	      <% if @time_table.sunday %> +	      	<span class='day_type'> <%= @time_table.human_attribute_name("sunday") %> </span> +	      <% end %> +      <% end %> +    </p> + +  <h3 class="time_table_calendars"> +	<a class="calendars"><%= @time_table.human_attribute_name("calendars") %> +      <%= image_tag("icons/plus.png"  , :class => "switcher", :style => "display: none;") %> +      <%= image_tag("icons/minus.png"  , :class => "switcher" ) %> +    </a> + +  </h3> +  <div class="calendars content"> +    <div class="year_choice"> +      <span class="previous"> <%= link_to("<", referential_time_table_path(@referential, @time_table, :year => (@year - 1)) ) %> </span> +      <span class="year"> <%= "#{@year}" %> </span> +      <span class="next"> <%= link_to(">", referential_time_table_path(@referential, @time_table, :year => (@year + 1)) ) %> </span> +    </div> +    <div class="calendar_helper"> +    <%= cal = "" +      (1..12).each do |month| +        cal << calendar(:year => @year, :month => month, :first_day_of_week => 1) do |d| +                 if @time_table.excluded_date?(d) +                   [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "excluded_date"}] +                 elsif @time_table.include_in_overlap_dates?(d) +                   [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "overlap_date"}] +                 elsif @time_table.include_in_dates?(d) +                   [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "selected_date"}] +                 elsif @time_table.include_in_periods?(d) +                   [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "selected_period"}] +                 end +               end +      end +      cal.html_safe +    %> +    </div> +  </div> + + +  </div> +  <h3 class="time_table_periods"> +	<a class="periods"><%= @time_table.human_attribute_name("periods") %> +      <%= image_tag("icons/plus.png"  , :class => "switcher", :style => "display: none;") %> +      <%= image_tag("icons/minus.png"  , :class => "switcher" ) %> +    </a> + +  </h3> +  <div class="periods content"> +  	<%= render "time_tables/periods" %> +  </div> + +  <h3 class="time_table_dates"> +	<a class="dates"><%= @time_table.human_attribute_name("dates") %> +      <%= image_tag("icons/plus.png"  , :class => "switcher", :style => "display: none;") %> +      <%= image_tag("icons/minus.png"  , :class => "switcher" ) %> +    </a> +  </h3> + +  <div class="dates content"> +  	<%= render "time_tables/dates" %> +  </div> + +  <h3 class="time_table_dates"> +	<a class="excluded_dates"><%= @time_table.human_attribute_name("excluded_dates") %> +      <%= image_tag("icons/plus.png"  , :class => "switcher", :style => "display: none;") %> +      <%= image_tag("icons/minus.png"  , :class => "switcher" ) %> +    </a> +  </h3> + +  <div class="excluded_dates content"> +  	<%= render "time_tables/excluded_dates" %> +  </div> + +</div> + diff --git a/app/views/time_tables/_show_time_table.html.erb b/app/views/time_tables/_show_time_table.html.erb index a439aed1b..c48b93470 100644 --- a/app/views/time_tables/_show_time_table.html.erb +++ b/app/views/time_tables/_show_time_table.html.erb @@ -1,6 +1,6 @@  <div class="time_table_show" id="time_table_show">    <p> -    <span class="state-code <%= time_table_state_code(@time_table) %>"><i class="fa fa-certificate"></i></span> +    <span class="state-code <%= @time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span>      <label>        <% if @time_table.bounding_dates.empty? %>          <%= t(".resume_empty") %> @@ -53,7 +53,7 @@        </div>      </div>      <div class="tab-pane" id="time_tables_datas"> -      <div class="summary">         +      <div class="summary">          <p>            <label><%= @time_table.human_attribute_name("version") %>: </label>            <%= @time_table.version %> @@ -62,15 +62,15 @@            <label><%= @time_table.human_attribute_name("day_types") %>:  </label>            <% if @time_table.int_day_types & 508 == 0 %>            <label><%= @time_table.human_attribute_name("none") %></label> -          <% else %>   +          <% else %>  	          <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>                <span class="<%= @time_table.send( day_type) ? "included_day_type" : "excluded_day_type" %>">                  <%= @time_table.human_attribute_name(day_type) %>                </span>              <% end %> -          <% end %>	 -        </p>        -         +          <% end %> +        </p> +        </div>        <% if @time_table.periods.present? %> @@ -93,7 +93,7 @@    	    <%= render "time_tables/excluded_dates" %>        </div>        <% end %> -       +      </div>    </div> diff --git a/app/views/time_tables/_time_table.html.erb b/app/views/time_tables/_time_table.html.erb index 0642f5a6c..7f48a9365 100644 --- a/app/views/time_tables/_time_table.html.erb +++ b/app/views/time_tables/_time_table.html.erb @@ -1,24 +1,24 @@  <div id="index_item" class="panel panel-default time_table">    <div class="panel-heading">      <div class="panel-title clearfix"> -      <span class="pull-right">                 +      <span class="pull-right">          <%= link_to edit_referential_time_table_path(@referential, time_table), :class => "btn btn-default btn-sm" do %>            <span class="fa fa-pencil"></span>          <% end %> -        <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, referential_time_table_path(@referential, time_table), :method => :delete, :data => {:confirm =>  t('time_tables.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %>       +        <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, referential_time_table_path(@referential, time_table), :method => :delete, :data => {:confirm =>  t('time_tables.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %>        </span>        <h5>          <%= link_to([@referential, time_table], :class => "preview", :title => "#{Chouette::TimeTable.model_name.human.capitalize} #{time_table.comment}") do %> -        <span class="state-code <%= time_table_state_code(time_table) %>"><i class="fa fa-certificate"></i></span> +        <span class="state-code <%= time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span>          <span class="name"> -          <%= truncate(time_table.comment, :length => 20) %>           +          <%= truncate(time_table.comment, :length => 20) %>          </span>          <% end %>        </h5> -    </div>                           +    </div>    </div>    <div class="panel-body"> -    <%= time_tables_shortest_info(time_table) %> +    <%= time_table.presenter.time_tables_shortest_info %>      <% unless time_table.periods.empty? %>        <div>        <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %> @@ -29,7 +29,7 @@        </div>      <% end %>      <% unless time_table.tags.empty? %> -      <div><%= tag_list_shortened(time_table) %></div> +      <div><%= time_table.presenter.tag_list_shortened %></div>      <% end %>    </div>  </div> diff --git a/app/views/time_tables/index.html.erb b/app/views/time_tables/index.html.erb index e9802b4bc..2163dfa94 100644 --- a/app/views/time_tables/index.html.erb +++ b/app/views/time_tables/index.html.erb @@ -1,11 +1,11 @@ -<%= title_tag t('time_tables.index.title') %>  +<%= title_tag t('time_tables.index.title') %>  <%= search_form_for @q, :url => referential_time_tables_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %>  <div class="panel panel-default"> -  <div class="panel-heading">    -    <div class="input-group col-md-9">    +  <div class="panel-heading"> +    <div class="input-group col-md-9">        <%= f.text_field :comment_cont, :placeholder => "#{t('.comment')}", :class => 'form-control' %> -       +        <div class="input-group-btn">          <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>        </div> @@ -14,8 +14,8 @@        <i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %>      </a>    </div> -   -  <div id="advanced_search" class="panel-collapse collapse">           + +  <div id="advanced_search" class="panel-collapse collapse">      <div class="panel-body">        <div>          <label><%= "#{t('.from')}" %></label> diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 1c3945164..5322f3eb4 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 => 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, :tags => time_table.tags.join(','), :day_types => %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| time_table.send(d) }.map{ |d| time_table.human_attribute_name(d).first(2)}.join(''), :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_autocomplete_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" => Rabl::Renderer.new( 'autocomplete_time_tables/index', @vehicle_journey.time_tables, :view_path => 'app/views', :format => :json, :scope => :self ).render }  %>      <li class="input">  	    <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>      </li> @@ -48,12 +48,12 @@  	    <tbody class="journey_pattern_dependent_list">  	      <%= render :partial => "vehicle_journeys/vehicle_journey_at_stop_fields",  	      :collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop, :locals => { :vehicle_journey_at_stops_size => @vehicle_journey.vehicle_journey_at_stops.size } %> -         +        </tbody>      </table> -     +    <% end %> -   +    <%= form.actions do %>      <%= form.action :submit, :as => :button %>      <%= form.action :cancel, :as => :link %> diff --git a/app/views/vehicle_journeys/_show_popover.html.erb b/app/views/vehicle_journeys/_show_popover.html.erb index 5f6fe51ea..40a44e805 100644 --- a/app/views/vehicle_journeys/_show_popover.html.erb +++ b/app/views/vehicle_journeys/_show_popover.html.erb @@ -2,25 +2,25 @@    <%= Chouette::JourneyPattern.model_name.human %> : <%= link_to journey_name( vehicle_journey.journey_pattern ), [@referential, @line, @route, vehicle_journey.journey_pattern] %>  </p>  <p> -  <%= vehicle_journey.time_tables.size %> <%= Chouette::TimeTable.model_name.human.pluralize %> <small><%= time_tables_shortest_info( vehicle_journey ) %></small> : +  <%= vehicle_journey.time_tables.size %> <%= Chouette::TimeTable.model_name.human.pluralize %> <small><%= vehicle_journey.presenter.time_tables_shortest_info %></small> :    <ul>      <% vehicle_journey.time_tables.limit(4).each do |time_table| %>      <li>        <%= link_to [@referential, time_table]  do %> -      <span class="state-code <%= time_table_state_code(time_table) %>"><i class="fa fa-certificate"></i></span> <%= time_table.comment %> -      <% end %>       +      <span class="state-code <%= time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span> <%= time_table.comment %> +      <% end %>        <% if time_table.tag_list.present? %>        <br>        <span class="time_table_info"><%= truncate(time_table.tag_list.to_s, :length => 35) %></span>        <% end %>        <br> -      <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>       +      <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>          <span class="<%= time_table.send( day_type) ? "included_day_type" : "excluded_day_type"%> time_table_info">            <%= time_table.human_attribute_name(day_type).first(2) %>          </span>          <% end %> -        <span class="bounding"><%= time_table_bounding( time_table) %></span> +        <span class="bounding"><%= time_table.presenter.time_table_bounding %></span>      </li>      <% end %> -  </ul>   +  </ul>  </p> diff --git a/app/views/vehicle_journeys/_time_filter.html.erb b/app/views/vehicle_journeys/_time_filter.html.erb deleted file mode 100644 index 6767468ec..000000000 --- a/app/views/vehicle_journeys/_time_filter.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -  <%= search_form_for @q, :url => referential_line_route_vehicle_journeys_path(@referential, @line, @route) do |f| %> -   <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"> -   <%= 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.hidden_field :journey_pattern_id_eq %> -   <%= f.hidden_field :time_tables_comment_eq %> -   <%= f.submit t('.time_range_filter') %> -  <% end %> - diff --git a/app/views/vehicle_journeys/_time_table.html.erb b/app/views/vehicle_journeys/_time_table.html.erb deleted file mode 100644 index f9e51ac37..000000000 --- a/app/views/vehicle_journeys/_time_table.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<%= div_for(time_table, :class => "time_table") do %> -  <%= render "time_tables/cell_title", time_table: time_table  %> -  <div class="info"> -    <%= render "time_tables/cell_info", time_table: time_table  %> -  </div> -<% end %> - diff --git a/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb b/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb deleted file mode 100644 index ad691a2fe..000000000 --- a/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= div_for(vehicle_journey) do %> -  <%= link_to vehicle_name(vehicle_journey), [@referential, @line, @route, vehicle_journey] %> -  <div class="info"> -    <% unless vehicle_journey.time_tables.empty? %> -      <%= vehicle_journey.human_attribute_name('time_tables') %> <%= time_tables_info( vehicle_journey) %> - -    <% end %> -    <% if vehicle_journey.journey_pattern %> -      <%= vehicle_journey.human_attribute_name('journey_pattern') %> <%= link_to journey_name(vehicle_journey.journey_pattern), [@referential, @line, @route, vehicle_journey.journey_pattern] %> -    <% end %> -    <div class="actions">   -      <%= link_to t("actions.edit"), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, vehicle_journey), :class => "edit" %> | -      <%= link_to t("actions.destroy"), [@referential, @line, @route, vehicle_journey], :method => :delete, :confirm =>  t('vehicle_journeys.actions.destroy_confirm'), :class => "remove" %> -    </div> -  </div> -<% end %> diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index 990f028e9..13126b2e1 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -4,13 +4,13 @@  <div class="panel panel-default">    <div class="panel-heading">      <%= f.label :journey_pattern_id_eq, "Missions" %> -    <%= f.text_field(:journey_pattern_id_eq, :class => "form-control") %>       +    <%= f.text_field(:journey_pattern_id_eq, :class => "form-control") %>      <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>      <a data-toggle="collapse" data-parent="#search" href="#advanced_search" class="advanced_search">        <i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %>      </a>    </div> -   +    <div id="advanced_search" class="panel-collapse collapse">      <div class="panel-body">        <div> @@ -50,24 +50,31 @@  <script>  	$(function() {          var time_tables_url = function(){ -          return '<%= referential_time_tables_path(@referential, :format => :json) %>?route_id=<%= @route.id %>'; +          return '<%= referential_autocomplete_time_tables_path(@referential, :format => :json) %>?route_id=<%= @route.id %>';          }; -        var time_table_to_html = function( item ){ +        var time_table_formatter = function(item){ +          var day_types = ''; +          if ( item.day_types.length >0 ){ +            day_types = '<span class=\"day_types\">' +  item.day_types + '</span>' ; +          } +          var tags = ''; +          if ( item.tags.length >0 ){ +            tags = '<div class=\"info\">' +  item.tags + '</div>' ; +          }            return '<li><div class=\"comment\">' + item.comment + -              '</div><div class=\"info\">' + item.time_table_bounding + -              '</div><div class=\"info\">' +  item.composition_info + '</div></li>'; +                  '</div><div class=\"info\">' + item.time_table_bounding + '  ' + day_types + '</div>' + +                  tags + '</li>';          };  		$( "#q_time_tables_id_eq" ).tokenInput( time_tables_url, {            crossDomain: false,            prePopulate: $('#q_time_tables_id_eq').data('pre'), -          minChars: 3, -          queryParam: 'q[comment_cont]', +          minChars: 2,            propertyToSearch: 'comment',            hintText: '<%= t('search_hint') %>',            noResultsText: '<%= t('no_result_text') %>',            searchingText: '<%= t('searching_term') %>', -          resultsFormatter: time_table_to_html, -          tokenFormatter: time_table_to_html, +          resultsFormatter: time_table_formatter, +          tokenFormatter: time_table_formatter          });  		$( "#q_journey_pattern_id_eq" ).tokenInput( '<%= referential_line_route_journey_patterns_path(@referential, @line, @route, :format => :json) %>', {            crossDomain: false, diff --git a/config/routes.rb b/config/routes.rb index 67eb757ae..3e4e31250 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -62,6 +62,7 @@ ChouetteIhm::Application.routes.draw do      resources :api_keys      resources :rule_parameter_sets      resources :autocomplete_stop_areas +    resources :autocomplete_time_tables      match 'lines' => 'lines#destroy_all', :via => :delete      resources :group_of_lines do        collection do | 
