diff options
| author | Marc Florisson | 2012-04-23 14:48:17 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-04-23 14:48:17 +0200 | 
| commit | 53cb5d9db1f3ccde220124e75dc04c91bd1802a3 (patch) | |
| tree | 1b75fd017bd401eb5e497e22f261d24c68026189 | |
| parent | ce3a470816e9b58a96ad23acaca87a581f507061 (diff) | |
| download | chouette-core-53cb5d9db1f3ccde220124e75dc04c91bd1802a3.tar.bz2 | |
add route views
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | .rvmrc | 1 | ||||
| -rw-r--r-- | app/assets/stylesheets/routes.css.scss | 66 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 30 | ||||
| -rw-r--r-- | app/views/routes/_form.html.erb | 26 | ||||
| -rw-r--r-- | app/views/routes/_list.html.erb | 21 | ||||
| -rw-r--r-- | app/views/routes/_route.html.erb | 4 | ||||
| -rw-r--r-- | app/views/routes/edit.html.erb | 4 | ||||
| -rw-r--r-- | app/views/routes/index.html.erb | 20 | ||||
| -rw-r--r-- | app/views/routes/new.html.erb | 4 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 57 | ||||
| -rw-r--r-- | config/locales/routes.yml | 71 | ||||
| -rw-r--r-- | config/locales/waybacks.yml | 11 | ||||
| -rw-r--r-- | config/routes.rb | 1 | 
14 files changed, 319 insertions, 0 deletions
| diff --git a/.gitignore b/.gitignore index aa1e11631..953761d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@  *~  public/assets/ +# for vim users +*.swp +*.swo @@ -0,0 +1 @@ +rvm jruby-1.6.6 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 %> + diff --git a/config/locales/routes.yml b/config/locales/routes.yml new file mode 100644 index 000000000..6a9d690f4 --- /dev/null +++ b/config/locales/routes.yml @@ -0,0 +1,71 @@ +en: +  routes: +    actions: +      new: Add a new route +      edit: Edit this route +      destroy: Remove this route +      destroy_confirm: Are you sure you want destroy this route? +    new: +      title: Add a new route +    edit: +      title: Update route %{route} +    show: +      title: Route %{route} +    index: +      title: Routes +      selection: Selection +      selection_all: All +  activerecord:         +    models:         +      route: Route +    attributes: +      route: +        line: Line +        name: Name +        published_name: Published name         +        comment: Comments +        number: Number +        direction: Direction +        wayback_code: Wayback +        opposite_route: Reversed route +        objectid: Neptune identifier +        object_version: Version +        creation_time: Created on +        creator_id: Created by  + +fr: +  routes: +    actions: +      new: Ajouter un itinéraire +      edit: Modifier cet itinéraire +      destroy: Supprimer cet itinéraire +      destroy_confirm: Etes vous sûr de détruire cet itinéraire ? +    new: +      title: Ajouter un itinéraire +    edit: +      title: "Modifier l'itinéraire %{route}" +    show: +      title: Itinéraire %{route} +    index: +      title: Itinéraires +      selection: Sélection +      selection_all: Tous +  activerecord:         +    models:         +      route: Itinéraire +    attributes: +      route: +        line: Ligne +        name: Nom +        published_name: Nom public         +        number: Indice +        comment: Commentaire +        direction: Direction +        wayback_code: Sens +        opposite_route: Itinéraire retour +        objectid: Identifiant Neptune +        object_version: Version +        creation_time: Créé le +        creator_id: Créé par + + diff --git a/config/locales/waybacks.yml b/config/locales/waybacks.yml new file mode 100644 index 000000000..6891b844d --- /dev/null +++ b/config/locales/waybacks.yml @@ -0,0 +1,11 @@ +en: +  waybacks: +    label: +      straight_forward: straight forward +      backward: backward +fr: +  waybacks: +    label: +      straight_forward: aller +      backward: retour + diff --git a/config/routes.rb b/config/routes.rb index df64353d0..4aaedc87b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,7 @@ ChouetteIhm::Application.routes.draw do    resources :referentials do      resources :lines, :networks do        resources :stop_areas +      resources :routes      end      resources :companies, :stop_areas, :time_tables | 
