aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Florisson2012-06-25 21:35:06 +0200
committerMarc Florisson2012-06-25 21:35:06 +0200
commit889d812612603b758c2e8aa0cd251826d36e364c (patch)
tree8afd22b2f403319c1c55bc051de1f3990695efd0
parente5ebc2c3e9fb14742562e2e7e278f13f7b2e01c7 (diff)
downloadchouette-core-889d812612603b758c2e8aa0cd251826d36e364c.tar.bz2
Refs #68, Refs #69, Refs 70, Refs 71
-rw-r--r--app/assets/stylesheets/vehicle_journeys.css.scss13
-rw-r--r--app/controllers/vehicle_journeys_controller.rb4
-rw-r--r--app/helpers/vehicle_journeys_helper.rb32
-rw-r--r--app/views/vehicle_journeys/_time_filter.html.erb11
-rw-r--r--app/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb6
-rw-r--r--app/views/vehicle_journeys/index.html.erb56
-rw-r--r--app/views/vehicle_journeys/show.html.erb4
-rw-r--r--config/locales/vehicle_journeys.yml6
-rw-r--r--spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb4
9 files changed, 103 insertions, 33 deletions
diff --git a/app/assets/stylesheets/vehicle_journeys.css.scss b/app/assets/stylesheets/vehicle_journeys.css.scss
index 0bfabc38b..868d4ecd7 100644
--- a/app/assets/stylesheets/vehicle_journeys.css.scss
+++ b/app/assets/stylesheets/vehicle_journeys.css.scss
@@ -3,7 +3,7 @@
// You can use Sass (SCSS) here: http://sass-lang.com/
@import "common";
-#workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.new
+#workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update, #workspace.vehicle_journeys.new
{
#route_color{ width: 100px;
color: white;
@@ -49,11 +49,15 @@
text-align: center;
}
- td.hours{
+ td.hours {
font-size: 12px;
color: #516a29;
}
+ td.missing {
+ background-color: orange;
+ }
+
td.stop_area{
text-align: left;
font-size: 12px;
@@ -63,7 +67,7 @@
}
-#workspace.vehicle_journeys.show, #workspace.vehicle_journeys.edit {
+#workspace.vehicle_journeys.show, #workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update {
.vehicle_journey_at_stops {
thead {
th { text-align: center; }
@@ -75,6 +79,9 @@
}
tbody {
td.hour { text-align: center; }
+ td.departure_time, td.arrival_time { padding-left: 15px; }
+ td.missing { background-color: orange; }
+ td.invalid_position { background-color: red; }
tr label { width: 100% }
tr.odd { }
tr.even { background-color: #DEFFA8; }
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 596a7f90c..d8dca65b5 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -18,6 +18,10 @@ class VehicleJourneysController < ChouetteController
end
end
+ def update
+ update!(:alert => "Hey pb")
+ end
+
protected
alias_method :vehicle_journey, :resource
diff --git a/app/helpers/vehicle_journeys_helper.rb b/app/helpers/vehicle_journeys_helper.rb
index 34b367424..e45978023 100644
--- a/app/helpers/vehicle_journeys_helper.rb
+++ b/app/helpers/vehicle_journeys_helper.rb
@@ -1,11 +1,39 @@
module VehicleJourneysHelper
+ def journey_name( journey_pattern)
+ if !journey_pattern.published_name.blank?
+ journey_pattern.published_name.first(8)
+ elsif !journey_pattern.name.blank?
+ journey_pattern.name.first(8)
+ else
+ journey_pattern.id
+ end
+ end
+ def vehicle_name( vehicle)
+ if !vehicle.published_journey_name.blank?
+ vehicle.published_journey_name.first(8)
+ elsif !vehicle.published_journey_identifier.blank?
+ vehicle.published_journey_identifier.first(8)
+ elsif !vehicle.number.blank?
+ vehicle.number
+ else
+ vehicle.id
+ end
+ end
+ def missing_time_check( is_present)
+ return "missing" if (is_present && is_present.departure_time.nil?)
+ end
+ def vehicle_departure(vehicle)
+ first_vjas = vehicle.vehicle_journey_at_stops.first
+ return "" unless first_vjas.departure_time
+ l(first_vjas.departure_time, :format => :hour).gsub( / /, ' ')
+ end
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( / /, ' ')
+ :time => vehicle_departure(vehicle))
end
def edit_vehicle_title( vehicle)
return t('vehicle_journeys.edit.title_stopless') if vehicle.vehicle_journey_at_stops.empty?
@@ -13,7 +41,7 @@ module VehicleJourneysHelper
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( / /, ' ')
+ :time => vehicle_departure(vehicle))
end
end
diff --git a/app/views/vehicle_journeys/_time_filter.html.erb b/app/views/vehicle_journeys/_time_filter.html.erb
new file mode 100644
index 000000000..0f1e8d439
--- /dev/null
+++ b/app/views/vehicle_journeys/_time_filter.html.erb
@@ -0,0 +1,11 @@
+ <%= 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.submit t('.time_range_filter') %>
+ <% end %>
+
diff --git a/app/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb b/app/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb
index f6feab945..218027dae 100644
--- a/app/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb
+++ b/app/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb
@@ -1,6 +1,6 @@
<% vjas = vehicle_journey_at_stop %>
-<tr class="time input optional <%= vjas._destroy ? "no_stop" : "" %> <%= (vehicle_journey_at_stop_counter%2==0) ? "odd" : "even" %>">
- <td>
+<tr class="time input optional <%= vjas._destroy ? "no_stop" : "" %> <%= (vehicle_journey_at_stop_counter%2==0) ? "odd" : "even" %>" >
+ <td class="arrival_time <%= vjas.arrival_time.nil? ? "missing" : "" %> <%= vjas.errors[:arrival_time].blank? ? "" : "invalid_position" %>">
<%= select_hour(vjas.arrival_time ? vjas.arrival_time.hour : 0, :prefix => "vehicle_journey", :field_name => "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][arrival_time(4i)]") %>
<%= select_minute(vjas.arrival_time ? vjas.arrival_time.min : 0, :prefix => "vehicle_journey", :field_name => "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][arrival_time(5i)]") %>
</td>
@@ -16,7 +16,7 @@
<input name=<%= "vehicle_journey[vehicle_journey_at_stops_attributes][#{vehicle_journey_at_stop_counter}][arrival_time(1i)]" %> type="hidden" value="2000">
<label for=<%= "vehicle_journey_vehicle_journey_at_stops_attributes_#{vehicle_journey_at_stop_counter}_departure_time_5i" %>><%= vjas.stop_point.stop_area.name %></label>
</td>
- <td>
+ <td class="departure_time <%= vjas.departure_time.nil? ? "missing" : "" %> <%= vjas.errors[:departure_time].blank? ? "" : "invalid_position" %>">
<%= select_hour(vjas.departure_time ? vjas.departure_time.hour : 0, :prefix => "vehicle_journey", :field_name => "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][departure_time(4i)]") %>
<%= select_minute(vjas.departure_time ? vjas.departure_time.min : 0, :prefix => "vehicle_journey", :field_name => "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][departure_time(5i)]") %>
</td>
diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb
index c71b82824..dc0900b9e 100644
--- a/app/views/vehicle_journeys/index.html.erb
+++ b/app/views/vehicle_journeys/index.html.erb
@@ -23,14 +23,13 @@
<table>
<thead>
<tr>
- <th class="title">Missions : </th>
- <% @vehicle_journeys.each do |vj| %>
- <th> <%= link_to vj.journey_pattern.published_name.blank? ? vj.journey_pattern.id: vj.journey_pattern.published_name.first(8),
- [@referential, @line, @route, vj.journey_pattern]%></th>
- <% end %>
+ <th class="title"><%= Chouette::JourneyPattern.model_name.human.pluralize %> :</th>
+ <% @vehicle_journeys.map(&:journey_pattern).each do |jp| %>
+ <th><%= link_to journey_name( jp), [@referential, @line, @route, jp] %></th>
+ <% end %>
</tr>
<tr>
- <th class="title">Calendriers : </th>
+ <th class="title"><%= Chouette::TimeTable.model_name.human.pluralize %> :</th>
<% @vehicle_journeys.each do |vj| %>
<th title="<%= time_tables_info( vj) %>" class="calendars">
<%= time_tables_shortest_info( vj) %>
@@ -38,9 +37,9 @@
<% end %>
</tr>
<tr>
- <th class="title">Courses : </th>
+ <th class="title"><%= Chouette::VehicleJourney.model_name.human.pluralize %> :</th>
<% @vehicle_journeys.each do |vj| %>
- <th> <%= link_to "c", [@referential, @line, @route, vj]%></th>
+ <th> <%= link_to vehicle_name(vj), [@referential, @line, @route, vj]%></th>
<% end %>
</tr>
</thead>
@@ -49,7 +48,9 @@
<tr class="<%= cycle('odd', 'even') %>">
<td class="stop_area"><%= sp.stop_area.name %></td>
<% @vehicle_journeys.each do |vj| %>
- <td class="hours"><%= @matrix["#{vj.id}-#{sp.id}"] ? l( @matrix["#{vj.id}-#{sp.id}"].departure_time, :format => :hour) : "" %></td>
+ <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) : "" %>
+ </td>
<% end %>
</tr>
<% end %>
@@ -57,20 +58,33 @@
</table>
</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>
-</ul>
-<h3><%= t(".selection") %></h3>
+ <ul class="actions">
+ <li>
+ <%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %>
+ </li>
+ </ul>
+ <h3><%= t(".selection") %></h3>
+
+ <h4><%= Chouette::JourneyPattern.model_name.human.pluralize %></h4>
-<h4><%= Chouette::JourneyPattern.model_name.human.pluralize %></h4>
+ <ul class="selection">
+ <% @route.journey_patterns.each do |journey_pattern| %>
+ <li><%= link_with_search journey_name(journey_pattern), "journey_pattern_id_eq" => journey_pattern.id %></li>
+ <% end %>
+ <li><%= link_with_search t(".selection_all"), {"journey_pattern_id_eq" => nil}, :class => "all" %></li>
+ </ul>
+
+ <h4><%= Chouette::TimeTable.model_name.human.pluralize %></h4>
+
+ <ul class="selection">
+ <% @route.time_tables.each do |time_table| %>
+ <li><%= link_with_search time_table.comment, "time_tables_comment_eq" => time_table.comment %></li>
+ <% end %>
+ <li><%= link_with_search t(".selection_all"), {"time_tables_comment_eq" => nil}, :class => "all" %></li>
+ </ul>
-<ul class="selection">
-<% @route.journey_patterns.each do |journey_pattern| %>
-<li><%= link_with_search journey_pattern.name, "journey_pattern_id_eq" => journey_pattern.id %></li>
+ <h4><%= t('.time_range') %></h4>
+ <%= render :partial => "time_filter", :locals => { :time_field => "departure_time"} %>
<% end %>
-<li><%= link_with_search t(".selection_all"), {"journey_pattern_id_eq" => nil}, :class => "all" %></li>
-</ul>
diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb
index 06f6f0c9f..8570261dd 100644
--- a/app/views/vehicle_journeys/show.html.erb
+++ b/app/views/vehicle_journeys/show.html.erb
@@ -65,9 +65,9 @@
<tbody>
<% @vehicle_journey.vehicle_journey_at_stops.each_with_index do |vjas, index| %>
<tr class="<%= index%2==0 ? "odd" : "even" %>">
- <td class="hour"><%= vjas.arrival_time ? l( vjas.arrival_time, :format => :hour) : "" %></td>
+ <td class="hour <%= vjas.arrival_time.nil? ? "missing" : "" %>"><%= vjas.arrival_time ? l( vjas.arrival_time, :format => :hour) : "" %></td>
<td><%= link_to vjas.stop_point.stop_area.name, [@referential, vjas.stop_point.stop_area] %></td>
- <td class="hour"><%= vjas.departure_time ? l( vjas.departure_time, :format => :hour) : "" %></td>
+ <td class="hour <%= vjas.departure_time.nil? ? "missing" : "" %>"><%= vjas.departure_time ? l( vjas.departure_time, :format => :hour) : "" %></td>
</tr>
<% end %>
</tbody>
diff --git a/config/locales/vehicle_journeys.yml b/config/locales/vehicle_journeys.yml
index 12f94a191..879d375a7 100644
--- a/config/locales/vehicle_journeys.yml
+++ b/config/locales/vehicle_journeys.yml
@@ -31,6 +31,9 @@ en:
vehicle_journeys: "Departure's times"
selection: Filter on
selection_all: All
+ time_range: Departure time threshold
+ time_filter:
+ time_range_filter: Filter
activerecord:
models:
vehicle_journey:
@@ -91,6 +94,9 @@ fr:
vehicle_journeys: "Horaires de départ aux arrêts"
selection: Filtrer sur
selection_all: Tous
+ time_range: Seuil horaire au départ
+ time_filter:
+ time_range_filter: Filtrer
activerecord:
models:
vehicle_journey:
diff --git a/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb b/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
index 70b0fc4ef..f99d27119 100644
--- a/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
+++ b/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
@@ -49,9 +49,9 @@ describe "/vehicle_journeys/_vehicle_journey_at_stop_fields" do
rendered.should have_selector("tr.no_stop")
end
end
- context "for a destroyed vehicle_journey_at_stop" do
+ context "for a not destroyed vehicle_journey_at_stop" do
before(:each) do
- vehicle_journey_at_stop.stub!(:_destroy => true)
+ vehicle_journey_at_stop.stub!(:_destroy => false)
end
it "should not render tr.no_stop" do
render_collection