From 24148be964f69140ea46a830cd0d07e43aa61bfc Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Tue, 24 Apr 2012 13:28:41 +0200 Subject: add route's views --- app/assets/stylesheets/lines.css.scss | 1 + app/assets/stylesheets/routes.css.scss | 2 +- app/controllers/lines_controller.rb | 1 + app/controllers/routes_controller.rb | 27 +++++++++++++++++++++-- app/helpers/routes_helper.rb | 7 ++++++ app/views/lines/show.html.erb | 8 +++++++ app/views/routes/_form.html.erb | 4 ++-- app/views/routes/_list.html.erb | 21 ------------------ app/views/routes/index.html.erb | 20 ----------------- app/views/routes/show.html.erb | 39 ++++++++++++++++++++++++++++------ config/locales/directions.yml | 31 +++++++++++++++++++++++++++ config/locales/lines.yml | 2 ++ config/locales/routes.yml | 14 ++++++++---- 13 files changed, 120 insertions(+), 57 deletions(-) create mode 100644 app/helpers/routes_helper.rb delete mode 100644 app/views/routes/_list.html.erb delete mode 100644 app/views/routes/index.html.erb create mode 100644 config/locales/directions.yml diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 6c136af7c..c5370611c 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -58,6 +58,7 @@ .line_color{ color: white; font-weight: bold; padding: 0 5px 0 5px;} + h3.routes { clear: both; } .summary p label { font-weight: bold; diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss index c845812c8..8da042a7a 100644 --- a/app/assets/stylesheets/routes.css.scss +++ b/app/assets/stylesheets/routes.css.scss @@ -3,7 +3,7 @@ // You can use Sass (SCSS) here: http://sass-lang.com/ @import "common"; -#workspace.routes.index +#workspace.lines.show { .route:after { @include after_div_for_object; diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index ac441f3ad..9d4ec18ae 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -8,6 +8,7 @@ class LinesController < ChouetteController def show @map = LineMap.new referential, resource + @routes = @line.routes.paginate(:page => params[:page], :per_page => 10) show! end diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 958d23cf9..55a700315 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -8,10 +8,33 @@ class RoutesController < ChouetteController end def index - @per_page = 10 - index! + index! do |format| + format.html { redirect_to referential_line_path(@referential,@line) } + end end + def show + @stop_areas = resource.stop_areas.paginate(:page => params[:page], :per_page => 10) + show! + end + + def destroy + destroy! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end + + def create + create! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end + + def update + update! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end protected alias_method :route, :resource diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb new file mode 100644 index 000000000..72915fd2f --- /dev/null +++ b/app/helpers/routes_helper.rb @@ -0,0 +1,7 @@ +module RoutesHelper + def line_formatted_name( line) + return line.publishedname if line.number.blank? + "#{line.publishedname} [#{line.number}]" + end +end + diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index cd0e6b2ac..23c65573f 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -51,10 +51,18 @@ +
- <%= link_to @line.name, [@referential, @line] %> + <%= link_to line_formatted_name( @line), [@referential, @line] %>
@@ -24,12 +24,30 @@ <%= @route.comment %>
- - <%= @route.direction %> + + <% if @route.direction_code %> +
<%= @route.direction_code.inspect %>
+<%= @route.direction.inspect %>
+ <%= t("directions.label.#{@route.direction_code}").capitalize %> + <% else %> + <%= t(".undefined") %> + <% end %>- - <%= @route.wayback %> + + <% if @route.wayback_code %> + <%= t("waybacks.label.#{@route.wayback_code}").capitalize %> + <% else %> + <%= t(".undefined") %> + <% end %> +
++ + <% if @route.opposite_route %> + <%= link_to @route.opposite_route.name, [@referential, @line, @route] %> + <% else %> + <%= t(".no_opposite_route") %> + <% end %>
@@ -37,7 +55,7 @@
- <%= @route.creation_time %> + <%= l @route.creation_time %>
@@ -47,6 +65,13 @@