aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarc Florisson2012-04-23 14:48:17 +0200
committerMarc Florisson2012-04-23 14:48:17 +0200
commit53cb5d9db1f3ccde220124e75dc04c91bd1802a3 (patch)
tree1b75fd017bd401eb5e497e22f261d24c68026189 /app
parentce3a470816e9b58a96ad23acaca87a581f507061 (diff)
downloadchouette-core-53cb5d9db1f3ccde220124e75dc04c91bd1802a3.tar.bz2
add route views
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/routes.css.scss66
-rw-r--r--app/controllers/routes_controller.rb30
-rw-r--r--app/views/routes/_form.html.erb26
-rw-r--r--app/views/routes/_list.html.erb21
-rw-r--r--app/views/routes/_route.html.erb4
-rw-r--r--app/views/routes/edit.html.erb4
-rw-r--r--app/views/routes/index.html.erb20
-rw-r--r--app/views/routes/new.html.erb4
-rw-r--r--app/views/routes/show.html.erb57
9 files changed, 232 insertions, 0 deletions
diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss
new file mode 100644
index 000000000..c845812c8
--- /dev/null
+++ b/app/assets/stylesheets/routes.css.scss
@@ -0,0 +1,66 @@
+// Place all the styles related to the routes controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+@import "common";
+
+#workspace.routes.index
+{
+ .route:after {
+ @include after_div_for_object;
+ }
+
+ .routes {
+ margin-top: 20px;
+ }
+
+ .routes:after {
+ @include content_to_clear;
+ }
+
+ .route {
+ @include div_for_object;
+
+ /* to create multi-column index */
+ width: 350px;
+ float: left;
+ padding-right: 10px;
+
+ .color {
+ width: 64px;
+ height: 64px;
+ float: left;
+ margin-right: 10px;
+ border: 1px solid #999;
+
+ a {
+ text-decoration: none;
+ }
+ }
+
+ .number {
+ font-size: 16px;
+ text-align: center;
+ font-weight: bold;
+ padding-top: 21px;
+ }
+ }
+}
+
+#workspace.routes.edit, #workspace.routes.new
+{
+ #route_color{ width: 100px;
+ color: white;
+ font-weight: bold;}
+}
+
+#workspace.routes.show
+{
+ .route_color{ color: white;
+ font-weight: bold;
+ padding: 0 5px 0 5px;}
+
+ .summary p label {
+ font-weight: bold;
+ }
+}
+
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
new file mode 100644
index 000000000..958d23cf9
--- /dev/null
+++ b/app/controllers/routes_controller.rb
@@ -0,0 +1,30 @@
+class RoutesController < ChouetteController
+ defaults :resource_class => Chouette::Route
+
+ respond_to :html, :xml, :json
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true
+ end
+
+ def index
+ @per_page = 10
+ index!
+ end
+
+ protected
+
+ alias_method :route, :resource
+
+ def collection
+ @q = parent.routes.search(params[:q])
+ @routes ||=
+ begin
+ routes = @q.result(:distinct => true).order(:name)
+ routes = routes.paginate(:page => params[:page], :per_page => @per_page) if @per_page.present?
+ routes
+ end
+ end
+
+end
+
diff --git a/app/views/routes/_form.html.erb b/app/views/routes/_form.html.erb
new file mode 100644
index 000000000..fb4604328
--- /dev/null
+++ b/app/views/routes/_form.html.erb
@@ -0,0 +1,26 @@
+<%= semantic_form_for [@referential, @line, @route] do |form| %>
+ <%= form.inputs do %>
+ <%= form.input :name %>
+ <%= form.input :published_name %>
+ <%= form.input :number %>
+ <%= form.input :comment %>
+ <%= form.input :oppositerouteid, :as => :select, :collection => Hash[@line.routes.map{|r| [r.name,r.id]}] %>
+ <%= form.input :direction, :as => :select, :collection => { "Aller" => 'A', "Retour" => "R"} %>
+ <%= form.input :wayback_code, :as => :select, :collection => Chouette::Route.waybacks, :include_blank => false, :member_label => Proc.new { |mode| t("waybacks.label.#{mode}") } %>
+ <% if @route.new_record? %>
+ <%= form.input :objectid %>
+ <% else %>
+ <li>
+ <label><%= @route.human_attribute_name("objectid") %>: </label>
+ <%= @route.objectid %>
+ </li>
+ <% end %>
+ <% end %>
+
+ <%= form.buttons do %>
+ <%= form.commit_button true %>
+ <li><%= t('or') %></li>
+ <li><%= link_to t('cancel'), :back %></li>
+ <% end %>
+<% end %>
+
diff --git a/app/views/routes/_list.html.erb b/app/views/routes/_list.html.erb
new file mode 100644
index 000000000..b253c3f75
--- /dev/null
+++ b/app/views/routes/_list.html.erb
@@ -0,0 +1,21 @@
+<%= title_tag t('routes.index.title') %>
+
+<%= search_form_for @q, :url => referential_line_routes_path(@referential, @line), :html => {:method => :get} do |f| %>
+ <%= f.text_field :name_cont %>
+
+ <%= f.submit t('actions.search') %> <%= t("or") %>
+ <%= link_to t("cancel"), referential_line_path(@referential,@line) %>
+<% end %>
+
+<%= will_paginate @line.routes %>
+<div class="routes paginated_content">
+ <%= render :partial => "route", :collection => @line.routes %>
+</div>
+<%= will_paginate @line.routes %>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li>
+</ul>
+<% end %>
+
diff --git a/app/views/routes/_route.html.erb b/app/views/routes/_route.html.erb
new file mode 100644
index 000000000..ed9528673
--- /dev/null
+++ b/app/views/routes/_route.html.erb
@@ -0,0 +1,4 @@
+<%= div_for(route) do %>
+ <%= link_to route.name, referential_line_route_path( @referential, @line, route) %>
+<% end %>
+
diff --git a/app/views/routes/edit.html.erb b/app/views/routes/edit.html.erb
new file mode 100644
index 000000000..dcfa0e8da
--- /dev/null
+++ b/app/views/routes/edit.html.erb
@@ -0,0 +1,4 @@
+<%= title_tag t('routes.edit.title', :route => @route.name ) %>
+
+<%= render "form" %>
+
diff --git a/app/views/routes/index.html.erb b/app/views/routes/index.html.erb
new file mode 100644
index 000000000..fba0ef859
--- /dev/null
+++ b/app/views/routes/index.html.erb
@@ -0,0 +1,20 @@
+<%= title_tag t('routes.index.title') %>
+
+<%= search_form_for @q, :url => referential_line_routes_path(@referential, @line), :html => {:method => :get} do |f| %>
+ <%= f.text_field :name_cont %>
+
+ <%= f.submit t('actions.search') %> <%= t("or") %>
+ <%= link_to t("cancel"), referential_line_path(@referential,@line) %>
+<% end %>
+
+<%= will_paginate @routes %>
+<div class="routes paginated_content">
+ <%= render :partial => "route", :collection => @routes %>
+</div>
+<%= will_paginate @routes %>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li>
+</ul>
+<% end %>
diff --git a/app/views/routes/new.html.erb b/app/views/routes/new.html.erb
new file mode 100644
index 000000000..a144fcdee
--- /dev/null
+++ b/app/views/routes/new.html.erb
@@ -0,0 +1,4 @@
+<%= title_tag t('routes.new.title') %>
+
+<%= render "form" %>
+
diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb
new file mode 100644
index 000000000..1d43c4284
--- /dev/null
+++ b/app/views/routes/show.html.erb
@@ -0,0 +1,57 @@
+<%= title_tag t('routes.show.title', :route => @route.name ) %>
+
+<div class="route_show">
+
+ <div class="summary">
+ <p>
+ <label><%= @route.human_attribute_name(:line) %>: </label>
+ <%= link_to @line.name, [@referential, @line] %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:name) %>: </label>
+ <%= @route.name %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:published_name) %>: </label>
+ <%= @route.published_name %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:number) %>: </label>
+ <%= @route.number %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:comment) %>: </label>
+ <%= @route.comment %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:direction) %>: </label>
+ <%= @route.direction %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:wayback) %>: </label>
+ <%= @route.wayback %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name("objectid") %>: </label>
+ <%= @route.objectid %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name("creation_time") %>: </label>
+ <%= @route.creation_time %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name("creator_id") %>: </label>
+ <%= @route.creator_id %>
+ </p>
+ </div>
+
+</div>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('routes.actions.edit'), edit_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li>
+ <li><%= link_to t('routes.actions.destroy'), referential_line_route_path(@referential, @line, @route), :method => :delete, :confirm => t('routes.actions.destroy_confirm'), :class => "remove" %></li>
+ <br>
+</ul>
+<% end %>
+