aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Florisson2012-06-13 16:07:30 +0200
committerMarc Florisson2012-06-13 16:07:30 +0200
commitcbd9618b0a9d4ea7f2b0733c134d1c85010f0a2f (patch)
tree88413299c9fe5573ace27a25c3cb60a4d7b99892
parentbfcaec8ebed6cc7cfeb1ab64a48d9182a5c3e567 (diff)
downloadchouette-core-cbd9618b0a9d4ea7f2b0733c134d1c85010f0a2f.tar.bz2
add views for vehicle_journeys
-rw-r--r--Gemfile.lock5
-rw-r--r--app/assets/stylesheets/vehicle_journeys.css.scss43
-rw-r--r--app/controllers/time_tables_controller.rb16
-rw-r--r--app/controllers/vehicle_journeys_controller.rb7
-rw-r--r--app/helpers/time_tables_helper.rb30
-rw-r--r--app/helpers/vehicle_journeys_helper.rb19
-rw-r--r--app/views/vehicle_journeys/_form.html.erb17
-rw-r--r--app/views/vehicle_journeys/_time_table.html.erb9
-rw-r--r--app/views/vehicle_journeys/edit.html.erb4
-rw-r--r--app/views/vehicle_journeys/index.html.erb27
-rw-r--r--app/views/vehicle_journeys/new.html.erb4
-rw-r--r--app/views/vehicle_journeys/show.html.erb10
-rw-r--r--config/locales/time_tables.yml10
-rw-r--r--config/locales/vehicle_journeys.yml26
-rw-r--r--config/routes.rb3
15 files changed, 208 insertions, 22 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index 854660c94..d3cbae20d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://chouette.dryade.priv/ninoxe
- revision: 1b68352e83c2ef898fdab7cd4c4eeddba6a977d5
+ revision: b873a0f2de6ec4358148dc6c1400a34baf2343a3
specs:
ninoxe (0.0.8)
GeoRuby
@@ -190,6 +190,7 @@ GEM
jruby-rack (1.1.5)
jruby-rack-worker (0.3-java)
jruby-rack (>= 1.0.1)
+ json (1.7.3)
json (1.7.3-java)
json_pure (1.7.3)
launchy (2.1.0)
@@ -267,7 +268,7 @@ GEM
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
- rspec-core (2.10.0)
+ rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
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>
diff --git a/config/locales/time_tables.yml b/config/locales/time_tables.yml
index e10d8a5f8..421838586 100644
--- a/config/locales/time_tables.yml
+++ b/config/locales/time_tables.yml
@@ -1,6 +1,11 @@
en:
time_tables:
time_table:
+ empty: empty
+ bounding: from %{start} to %{end}
+ periods_count: "periods: %{count}"
+ dates_count: "dates: %{count}"
+ periods_dates_count: "dates: %{dates_count}, periods: %{periods_count}"
actions:
new: Add a new timetable
edit: Edit this timetable
@@ -62,6 +67,11 @@ en:
fr:
time_tables:
time_table:
+ empty: vide
+ bounding: du %{start} au %{end}
+ periods_count: "périodes: %{count}"
+ dates_count: "dates: %{count}"
+ periods_dates_count: "dates: %{dates_count}, périodes: %{periods_count}"
actions:
new: Ajouter un calendrier
edit: Modifier ce calendrier
diff --git a/config/locales/vehicle_journeys.yml b/config/locales/vehicle_journeys.yml
index 18882bad8..712f684d9 100644
--- a/config/locales/vehicle_journeys.yml
+++ b/config/locales/vehicle_journeys.yml
@@ -1,5 +1,8 @@
en:
vehicle_journeys:
+ vehicle_journey:
+ title_stopless: Vehicle journey %{name}
+ title: Vehicle journey %{name} leaving from %{stop} at %{time}
actions:
new: Add a new vehicle journey
edit: Edit this vehicle journey
@@ -8,11 +11,16 @@ en:
new:
title: Add a new vehicle journey
edit:
- title: Update vehicle journey %{vehicle journey}
+ title_stopless: Update vehicle journey %{name}
+ title: Update vehicle journey %{name} leaving from %{stop} at %{time}
+ form:
+ time_tables: Associated calendars to vehicle journey
show:
title: Vehicle Journey %{vehicle journey}
+ time_tables: Calendars list
+ bounding: From %{start} to %{end}
index:
- title: Vehicle journeys on route {%route}
+ title: Vehicle journeys on route %{route}
activerecord:
models:
vehicle_journey:
@@ -33,6 +41,8 @@ en:
published_journey_identifier: Published Identifier
facility: Facility
vehicletypeidentifier: Vehicle Type Identifier
+ time_table_ids: Calendar list
+ vehicle_journey_at_stop_ids: Time list
objectid: Neptune identifier
object_version: Version
creation_time: Created on
@@ -40,6 +50,9 @@ en:
fr:
vehicle_journeys:
+ vehicle_journey:
+ title_stopless: Course %{name}
+ title: Course %{name} partant de %{stop} à %{time}
actions:
new: "Ajouter une course"
edit: "Modifier cette course"
@@ -48,9 +61,14 @@ fr:
new:
title: "Ajouter une course"
edit:
- title: "Modifier la course au départ de %{stop} à %{time} sur la séquence %{route}"
+ title_stopless: "Modifier la course %{name}"
+ title: "Modifier la course partant de %{stop} à %{time}"
+ form:
+ time_tables: Calendriers associés à la course
show:
title: "Course au départ de %{stop} à %{time} sur la séquence %{route}"
+ time_tables: Liste des calendriers
+ bounding: De %{start} à %{end}
index:
title: "Courses de la séquence d'arrêts %{route}"
activerecord:
@@ -73,6 +91,8 @@ fr:
published_journey_identifier: Identifiant public
facility: Equipement
vehicle_type_identifier: "Type d'identifiant du véhicule"
+ time_table_ids: "Liste des calendriers"
+ vehicle_journey_at_stop_ids: Liste des horaires
objectid: Identifiant Neptune
object_version: Version
creation_time: Créé le
diff --git a/config/routes.rb b/config/routes.rb
index 573b7ab7c..82d1e9bee 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -50,6 +50,9 @@ ChouetteIhm::Application.routes.draw do
resources :companies, :stop_areas
resources :time_tables do
+ collection do
+ get :comment_filter
+ end
resources :time_table_dates
resources :time_table_periods
end