diff options
| author | Marc Florisson | 2012-06-15 20:22:48 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-06-15 20:22:48 +0200 |
| commit | aa96bcc26c7c943c199cfe911343702937550452 (patch) | |
| tree | f022a5433d07c63061f93c46ea12ed73ab2b631b | |
| parent | aac47f41318b3ccd980f482e0a9fd21433ace69b (diff) | |
| download | chouette-core-aa96bcc26c7c943c199cfe911343702937550452.tar.bz2 | |
refactor vehicle_journey's views
| -rw-r--r-- | app/assets/stylesheets/common.css.scss | 3 | ||||
| -rw-r--r-- | app/assets/stylesheets/layout.css.scss | 6 | ||||
| -rw-r--r-- | app/assets/stylesheets/lines.css.scss | 7 | ||||
| -rw-r--r-- | app/assets/stylesheets/vehicle_journeys.css.scss | 21 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 2 | ||||
| -rw-r--r-- | app/helpers/time_tables_helper.rb | 14 | ||||
| -rw-r--r-- | app/views/routes/_route.html.erb | 19 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 3 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 6 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_vehicle_journey_at_stop.html.erb | 6 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.html.erb | 9 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.html.erb | 22 | ||||
| -rw-r--r-- | config/locales/routes.yml | 6 | ||||
| -rw-r--r-- | config/locales/vehicle_journeys.yml | 10 | ||||
| -rw-r--r-- | spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb | 1 |
15 files changed, 119 insertions, 16 deletions
diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index 9f9ce3346..b6d91a318 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -43,6 +43,9 @@ padding-left: 12px; } + a.link { + background: url(image-path('icons/link-small.png')) no-repeat 0% 50%; + } a.edit { background: url(image-path('user_interface/ui/edit-small.png')) no-repeat 0% 50%; } diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index e93ec699c..10ab70fb8 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -54,6 +54,10 @@ $text_color: #222; background: url(image-path('user_interface/ui/add.png')) no-repeat; } + a.link { + background: url(image-path('icons/link.png')) no-repeat; + } + a.select_parent { background: url(image-path('icons/select_parent.png')) no-repeat; } @@ -61,4 +65,4 @@ $text_color: #222; a.select_areas { background: url(image-path('icons/select_parent.png')) no-repeat; } -}
\ No newline at end of file +} diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 07ed34e5b..f66f8badd 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -61,6 +61,13 @@ padding: 0 5px 0 5px;} h3.routes { clear: both; } + .route { + margin-bottom: 0px; + .info { + margin-bottom: 30px; + } + } + .summary p label { font-weight: bold; } diff --git a/app/assets/stylesheets/vehicle_journeys.css.scss b/app/assets/stylesheets/vehicle_journeys.css.scss index c8f442322..6906aabb3 100644 --- a/app/assets/stylesheets/vehicle_journeys.css.scss +++ b/app/assets/stylesheets/vehicle_journeys.css.scss @@ -30,6 +30,26 @@ .summary p label { font-weight: bold; } + + .vehicle_journey_at_stops thead th { + text-align: center; + } + .vehicle_journey_at_stops thead th.hour { + width: 70px; + } + .vehicle_journey_at_stops tbody td.hour { + text-align: center; + } + .vehicle_journey_at_stops thead tr { + background-color: #75B80D; + color: white; + } + .vehicle_journey_at_stops tbody tr.odd { + background-color: #BDF366; + } + .vehicle_journey_at_stops tbody tr.even { + background-color: #85CF10; + } .time_table:after { @include after_div_for_object; @@ -53,6 +73,7 @@ @include div_for_object; /* to create multi-column index */ width: 350px; + height: 100px; float: left; padding-right: 10px; diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index b860d2948..a3e2c85c4 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -17,7 +17,7 @@ class TimeTablesController < ChouetteController def filtered_time_tables_maps filtered_time_tables.collect do |time_table| - { :id => time_table.id.to_s, :name => time_table.comment } + { :id => time_table.id, :name => time_table.comment } end end def filtered_time_tables diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb index db9c1109e..a7607f7a0 100644 --- a/app/helpers/time_tables_helper.rb +++ b/app/helpers/time_tables_helper.rb @@ -5,13 +5,19 @@ module TimeTablesHelper :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) - return vehicle.bounding_dates.inspect - #"#{l(vehicle.bounding_dates.min)} #{l(vehicle.bounding_dates.max)}" + bounding_short_info( vehicle.bounding_dates) end def time_tables_info( vehicle) vehicle.time_tables.map do |time_table| - composition_info(time_table) + "#{time_table_bounding( time_table)} - #{composition_info(time_table)}" end.join( "\n") end @@ -19,7 +25,7 @@ module TimeTablesHelper 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 + 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', diff --git a/app/views/routes/_route.html.erb b/app/views/routes/_route.html.erb index 7804ec068..4ec720e5d 100644 --- a/app/views/routes/_route.html.erb +++ b/app/views/routes/_route.html.erb @@ -1,9 +1,20 @@ <%= div_for(route) do %> - <div class="wayback"> - <%= link_to image_tag("icons/#{route.wayback}.png"), referential_line_route_path( @referential, @line, route) %> - </div> - <div class="route"> + <%= link_to image_tag("icons/#{route.wayback}.png"), referential_line_route_path( @referential, @line, route) %> + <div> <%= link_to route.name, referential_line_route_path( @referential, @line, route) %> </div> + <div class="info"> + <% if route.number.blank? %> + <%= route.human_attribute_name('number') %> <%= route.number %> - + <% end %> + <% if route.direction.blank? %> + <%= route.human_attribute_name('direction') %> <%= route.direction %> - + <% end %> + <%= route.human_attribute_name('wayback_code') %> <%= (route.wayback=="A") ? t('route.wayback.positive') : t('wayback.negative') %> + <div class="actions"> + <%= link_to t("routes.actions.edit"), edit_referential_line_route_path(@referential, @line, route), :class => "edit" %> | + <%= link_to t("vehicle_journeys.actions.index"), referential_line_route_vehicle_journeys_path(@referential, @line, route), :class => "link" %> + </div> + </div> <% end %> diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index 72524846b..0666fdcf5 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -93,6 +93,9 @@ <li> <%= link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), :class => "add" %> </li> + <li> + <%= link_to t('vehicle_journeys.actions.index'), referential_line_route_vehicle_journeys_path(@referential, @line, @route), :class => "link" %> + </li> </ul> <% end %> diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 138e4ba99..540168e69 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -33,7 +33,7 @@ <% 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 } %> + <%= 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.comment } } ).to_json } %> </div> <% end %> @@ -52,9 +52,9 @@ <script> $(function() { - $( "#vehicle_journey_time_table_ids" ).tokenInput('<%= comment_filter_referential_time_tables_path(@referential, :format => :json) %>', { + $( "#vehicle_journey_time_table_tokens" ).tokenInput('<%= comment_filter_referential_time_tables_path(@referential, :format => :json) %>', { crossDomain: false, - prePopulate: $('#time_table_ids').data('pre'), + prePopulate: $('#time_table_tokens').data('pre'), minChars: 3, }); }); diff --git a/app/views/vehicle_journeys/_vehicle_journey_at_stop.html.erb b/app/views/vehicle_journeys/_vehicle_journey_at_stop.html.erb new file mode 100644 index 000000000..5af8dfaf7 --- /dev/null +++ b/app/views/vehicle_journeys/_vehicle_journey_at_stop.html.erb @@ -0,0 +1,6 @@ +<%= div_for(vehicle_journey_at_stop, :class => "vehicle_journey_at_stop") do %> + <span class="stop_name"> + <%= link_to vehicle_journey_at_stop.stop_point.stop_area.name, [@referential, vehicle_journey_at_stop.stop_point.stop_area] %> + </span><%= l(vehicle_journey_at_stop.departure_time, :format => :hour) %> +<% end %> + diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index 025a99f2a..4362af8bb 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -25,14 +25,16 @@ <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, + <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 %> </tr> <tr> <th>calendriers</th> <% @vehicle_journeys.each do |vj| %> - <th title="<%= time_tables_info( vj) %>" class="calendars"> <%= time_tables_shortest_info( vj) %></th> + <th title="<%= time_tables_info( vj) %>" class="calendars"> + <%= time_tables_shortest_info( vj) %> + </th> <% end %> </tr> <tr> @@ -54,6 +56,9 @@ </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 => "link" %> + </li> </ul> <% end %> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index 997c92705..73c4cb6ae 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -52,6 +52,28 @@ </p> </div> </div> +<h3><%= @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids) %></h3> +<div class="vehicle_journey_at_stops"> + <table border="0" > + <thead> + <tr> + <th class="stop title" ><%= t('.stop_title') %></th> + <th class="hour title"><%= t('.departure') %></th> + <th class="hour title"><%= t('.arrival') %></th> + </tr> + <thead> + <tbody> + <% @vehicle_journey.vehicle_journey_at_stops.each_with_index do |vjas, index| %> + <tr class="<%= index%2==0 ? "odd" : "even" %>"> + <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.arrival_time ? l( vjas.arrival_time, :format => :hour) : "" %></td> + </tr> + <% end %> + </tbody> + </table> +</div> + <h3><%= t('.time_tables') %></h3> <div class="vehicle_journey_time_tables"> <%= render :partial => "vehicle_journeys/time_table", :collection => @vehicle_journey.time_tables %> diff --git a/config/locales/routes.yml b/config/locales/routes.yml index 4d0c7842d..7ab2ca623 100644 --- a/config/locales/routes.yml +++ b/config/locales/routes.yml @@ -27,6 +27,9 @@ en: other: routes attributes: route: + wayback: + positive: forward + negative: backward line: Line name: Name published_name: Published name @@ -69,6 +72,9 @@ fr: other: "Séquences d'arrêts" attributes: route: + wayback: + positive: Aller + negative: Retour line: Ligne name: Nom published_name: Nom public diff --git a/config/locales/vehicle_journeys.yml b/config/locales/vehicle_journeys.yml index 712f684d9..dd6d54921 100644 --- a/config/locales/vehicle_journeys.yml +++ b/config/locales/vehicle_journeys.yml @@ -4,6 +4,7 @@ en: title_stopless: Vehicle journey %{name} title: Vehicle journey %{name} leaving from %{stop} at %{time} actions: + index: "Vehicle time's board" new: Add a new vehicle journey edit: Edit this vehicle journey destroy: Remove this vehicle journey @@ -17,10 +18,14 @@ en: time_tables: Associated calendars to vehicle journey show: title: Vehicle Journey %{vehicle journey} + stop_title: Stop + departure: Departure + arrival: Arrival time_tables: Calendars list bounding: From %{start} to %{end} index: title: Vehicle journeys on route %{route} + vehicle_journeys: "Departure's times" activerecord: models: vehicle_journey: @@ -54,6 +59,7 @@ fr: title_stopless: Course %{name} title: Course %{name} partant de %{stop} à %{time} actions: + index: "Horaires des courses" new: "Ajouter une course" edit: "Modifier cette course" destroy: "Supprimer cette course" @@ -67,10 +73,14 @@ fr: time_tables: Calendriers associés à la course show: title: "Course au départ de %{stop} à %{time} sur la séquence %{route}" + stop_title: Arrêt + departure: Départ + arrival: Arrivée time_tables: Liste des calendriers bounding: De %{start} à %{end} index: title: "Courses de la séquence d'arrêts %{route}" + vehicle_journeys: "Horaires de départ aux arrêts" 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 77f98ffbb..d7c307c1d 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 @@ -55,7 +55,6 @@ describe "/vehicle_journeys/_vehicle_journey_at_stop_fields" do end it "should not render li.no_stop" do render_collection - puts rendered.inspect rendered.should_not have_selector("li.no_stop") end end |
