diff options
| author | Marc Florisson | 2012-06-13 16:07:30 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-06-13 16:07:30 +0200 | 
| commit | cbd9618b0a9d4ea7f2b0733c134d1c85010f0a2f (patch) | |
| tree | 88413299c9fe5573ace27a25c3cb60a4d7b99892 /app | |
| parent | bfcaec8ebed6cc7cfeb1ab64a48d9182a5c3e567 (diff) | |
| download | chouette-core-cbd9618b0a9d4ea7f2b0733c134d1c85010f0a2f.tar.bz2 | |
add views for vehicle_journeys
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/vehicle_journeys.css.scss | 43 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 16 | ||||
| -rw-r--r-- | app/controllers/vehicle_journeys_controller.rb | 7 | ||||
| -rw-r--r-- | app/helpers/time_tables_helper.rb | 30 | ||||
| -rw-r--r-- | app/helpers/vehicle_journeys_helper.rb | 19 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 17 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_time_table.html.erb | 9 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/edit.html.erb | 4 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.html.erb | 27 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/new.html.erb | 4 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.html.erb | 10 | 
11 files changed, 169 insertions, 17 deletions
| diff --git a/app/assets/stylesheets/vehicle_journeys.css.scss b/app/assets/stylesheets/vehicle_journeys.css.scss index 8199a7541..c8f442322 100644 --- a/app/assets/stylesheets/vehicle_journeys.css.scss +++ b/app/assets/stylesheets/vehicle_journeys.css.scss @@ -13,6 +13,16 @@            display: none;          }      } +    .time_table_list { +        padding-left: 25%; +    } +} + +#workspace.vehicle_journeys.index +{ +    th.calendars { +        font-size: 11px; +    }  }  #workspace.vehicle_journeys.show @@ -20,6 +30,39 @@      .summary p label {          font-weight: bold;      } +     +    .time_table:after {  +        @include after_div_for_object;   +    } + +    .time_tables { +        margin-top: 20px; +    } + +    .time_tables:after { +        @include content_to_clear; +    } +     +    .vehicle_journey_time_tables { +        clear: both; +        margin: 0px; +        padding: 0px; +    } + +    .time_table { +        @include div_for_object; +        /* to create multi-column index */ +        width: 350px; +        float: left; +        padding-right: 10px; + +        span.included_day_type { +            font-weight: bolder; +            color: black; +        } +        span.excluded_day_type { +        } +    }  }         diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index dbecde0eb..b860d2948 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -6,8 +6,24 @@ class TimeTablesController < ChouetteController    belongs_to :referential +  def comment_filter +    respond_to do |format|   +      format.json { render :json => filtered_time_tables_maps}   +    end   +     +  end +    protected +  def filtered_time_tables_maps +    filtered_time_tables.collect do |time_table| +      { :id => time_table.id.to_s, :name => time_table.comment } +    end +  end +  def filtered_time_tables +    referential.time_tables.select{ |t| t.comment =~ /#{params[:q]}/i  } +  end +    def collection          @q = referential.time_tables.search(params[:q])      @time_tables ||= @q.result(:distinct => true).order(:comment).paginate(:page => params[:page], :per_page => 10) diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 215677382..596a7f90c 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -23,14 +23,15 @@ class VehicleJourneysController < ChouetteController    alias_method :vehicle_journey, :resource    def collection -    @q = parent.vehicle_journeys.search(params[:q]) -    @vehicle_journeys ||= @q.result(:distinct => true).paginate(:page => params[:page], :per_page => 10) +    @q = parent.sorted_vehicle_journeys.search(params[:q]) +    @vehicle_journeys ||= @q.result(:distinct => true).order( "vehicle_journey_at_stops.departure_time").paginate(:page => params[:page], :per_page => 10)      @matrix ||= matrix     end    def matrix      {}.tap do |hash| -      @vehicle_journeys.each do |vj| +      Chouette::VehicleJourney.find( @vehicle_journeys.map { |v| v.id } ). +        each do |vj|          vj.vehicle_journey_at_stops.each do |vjas|            hash[ "#{vj.id}-#{vjas.stop_point_id}"] = vjas           end diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb new file mode 100644 index 000000000..c5a6579d9 --- /dev/null +++ b/app/helpers/time_tables_helper.rb @@ -0,0 +1,30 @@ +module TimeTablesHelper +  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 time_tables_shortest_info( vehicle) +    "#{l(vehicle.bounding_dates.min)} #{l(vehicle.bounding_dates.max)}" +  end +  def time_tables_info( vehicle) +    vehicle.time_tables.map do |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 +      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 +end + diff --git a/app/helpers/vehicle_journeys_helper.rb b/app/helpers/vehicle_journeys_helper.rb new file mode 100644 index 000000000..34b367424 --- /dev/null +++ b/app/helpers/vehicle_journeys_helper.rb @@ -0,0 +1,19 @@ +module VehicleJourneysHelper +  def vehicle_title( vehicle) +    return t('vehicle_journeys.vehicle_journey.title_stopless') if vehicle.vehicle_journey_at_stops.empty? +    first_vjas = vehicle.vehicle_journey_at_stops.first +    t('vehicle_journeys.vehicle_journey.title',  +          :name => vehicle.published_journey_name, +          :stop => first_vjas.stop_point.stop_area.name, +          :time => l(first_vjas.departure_time, :format => :hour)).gsub( /  /, ' ') +  end +  def edit_vehicle_title( vehicle) +    return t('vehicle_journeys.edit.title_stopless') if vehicle.vehicle_journey_at_stops.empty? +    first_vjas = vehicle.vehicle_journey_at_stops.first +    t('vehicle_journeys.edit.title',  +          :name => vehicle.published_journey_name, +          :stop => first_vjas.stop_point.stop_area.name, +          :time => l(first_vjas.departure_time, :format => :hour)).gsub( /  /, ' ') +  end +end + diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 71714a28c..138e4ba99 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -17,7 +17,7 @@        </li>      <% end %> -    <%= form.inputs :class => "stop_times" do %> +    <%= form.inputs :class => "stop_times", :name => @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids) do %>        <div class="journey_pattern_dependent_list">          <!--          <= form.semantic_fields_for :vehicle_journey_at_stops do |vjas| > @@ -31,6 +31,11 @@            :collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop %>         </div>      <% end %> +    <%= form.inputs :class => "time_tables", :name=> @vehicle_journey.human_attribute_name(:time_table_ids) do %> +      <div class="time_table_list"> +      <%= form.input :time_table_ids, :label => t('.time_tables'), :as => :text, :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map { |time_table| { :id => time_table.id.to_s, :name => time_table.comment } } ).to_json }  %> +      </div> +    <% end %>    <% end %> @@ -45,3 +50,13 @@    <%= javascript_include_tag edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey, :format => :js) %>  <% end %> +<script> +	$(function() { +          $( "#vehicle_journey_time_table_ids" ).tokenInput('<%= comment_filter_referential_time_tables_path(@referential, :format => :json) %>', {  +       crossDomain: false,  +       prePopulate: $('#time_table_ids').data('pre'), +       minChars: 3, +    }); +	}); +</script> + diff --git a/app/views/vehicle_journeys/_time_table.html.erb b/app/views/vehicle_journeys/_time_table.html.erb index e5d36ed63..fccee5ff8 100644 --- a/app/views/vehicle_journeys/_time_table.html.erb +++ b/app/views/vehicle_journeys/_time_table.html.erb @@ -1,6 +1,15 @@  <%= div_for(time_table, :class => "time_table") do %>    <%= link_to time_table.comment, [@referential, time_table] %>    <div class="info"> +    <%= composition_info(time_table) %> - +    <% unless time_table.periods.empty? %> +      <% %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).first(2) %> +        </span> +      <% end %> +    <% end %> - +    <%= bounding_info(time_table) %>      <div class="actions">          <%= link_to t("actions.edit"), edit_referential_time_table_path(@referential, time_table), :class => "edit" %>      </div> diff --git a/app/views/vehicle_journeys/edit.html.erb b/app/views/vehicle_journeys/edit.html.erb index 164f654b6..fcb0c2bd9 100644 --- a/app/views/vehicle_journeys/edit.html.erb +++ b/app/views/vehicle_journeys/edit.html.erb @@ -1,4 +1,4 @@ -<%= title_tag t('vehicle_journeys.edit.title' ) %> +<%= title_tag edit_vehicle_title(@vehicle_journey) %>  <div class="vehicle_journey">    <div class="summary"> @@ -7,7 +7,7 @@        <%= link_to line_formatted_name( @line), [@referential, @line] %>      </p>      <p> -      <label><%= Chouette::Route.model_name.human %>: </label> +      <label><%= @vehicle_journey.human_attribute_name(:route) %>: </label>        <%= link_to @route.name, [@referential, @line, @route] %>      </p>    <div> diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index cbb43408c..025a99f2a 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -21,12 +21,27 @@  </div>  <div class="vehicle_journeys paginated_content">    <table border="1"> -  <tr> -  <th> "vide"</th> -  <% @vehicle_journeys.each do |vj| %> -    <th> <%= link_to "c", [@referential, @line, @route, vj]%></th> -  <% end %> -  </tr> +  <thead> +    <tr> +      <th>mission</th> +      <% @vehicle_journeys.each do |vj| %> +        <th> <%= link_to vj.journey_pattern.published_name.blank? ? vj.journey_pattern.id: vj.journey_pattern.published_name, +                  [@referential, @line, @route, vj.journey_pattern]%></th> +      <% end %> +    </tr> +    <tr> +      <th>calendriers</th> +      <% @vehicle_journeys.each do |vj| %> +        <th title="<%= time_tables_info( vj) %>" class="calendars"> <%= time_tables_shortest_info( vj) %></th> +      <% end %> +    </tr> +    <tr> +      <th>courses</th> +      <% @vehicle_journeys.each do |vj| %> +      <th> <%= link_to "c", [@referential, @line, @route, vj]%></th> +      <% end %> +    </tr> +  <thead>    <% @route.stop_points.each_with_index do |sp, index| %>    <tr>      <td><%= sp.stop_area.name %></td> diff --git a/app/views/vehicle_journeys/new.html.erb b/app/views/vehicle_journeys/new.html.erb index fd7bb34ac..db344438e 100644 --- a/app/views/vehicle_journeys/new.html.erb +++ b/app/views/vehicle_journeys/new.html.erb @@ -1,4 +1,4 @@ -<%= title_tag  t('vehicle_journeys.new.title') %> +<%= title_tag t('vehicle_journeys.new.title') %>  <div class="vehicle_journey">    <div class="summary"> @@ -7,7 +7,7 @@        <%= link_to line_formatted_name( @line), [@referential, @line] %>      </p>      <p> -      <label><%= Chouette::Route.model_name.human %>: </label> +      <label><%= @vehicle_journey.human_attribute_name(:route) %>: </label>        <%= link_to @route.name, [@referential, @line, @route] %>      </p>    <div> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index a89d2261b..997c92705 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -1,4 +1,4 @@ -<%= title_tag t('vehicle_journeys.edit.title' ) %> +<%= title_tag vehicle_title(@vehicle_journey) %>  <div class="vehicle_journey">    <div class="summary"> @@ -7,11 +7,11 @@        <%= link_to line_formatted_name( @line), [@referential, @line] %>      </p>      <p> -      <label><%= Chouette::Route.model_name.human %>: </label> +      <label><%= @vehicle_journey.human_attribute_name(:route) %>: </label>        <%= link_to @route.name, [@referential, @line, @route] %>      </p>      <p> -      <label><%= Chouette::JourneyPattern.model_name.human %>: </label> +      <label><%= @vehicle_journey.human_attribute_name(:journey_pattern) %>: </label>        <%= link_to journey_name(@vehicle_journey.journey_pattern), [@referential, @line, @route, @vehicle_journey.journey_pattern] %>      </p>      <p> @@ -52,6 +52,10 @@      </p>    </div>  </div> +<h3><%= t('.time_tables') %></h3> +<div class="vehicle_journey_time_tables"> +<%= render :partial => "vehicle_journeys/time_table", :collection => @vehicle_journey.time_tables %> +</div>  <% content_for :sidebar do %>  <ul class="actions">    <li><%= link_to t('vehicle_journeys.actions.edit'), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :class => "edit" %></li> | 
