diff options
| author | Marc Florisson | 2012-05-15 15:39:53 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-05-15 15:39:53 +0200 | 
| commit | 63f7a0b5183f52b8791adf2a61521e12f652a98e (patch) | |
| tree | 77cb710b8adc0536c3592c0b742d28793f070285 | |
| parent | a2260f9d3737188d22504f705825ed5a846bb861 (diff) | |
| download | chouette-core-63f7a0b5183f52b8791adf2a61521e12f652a98e.tar.bz2 | |
add route and stop_point views
| -rw-r--r-- | Gemfile | 2 | ||||
| -rw-r--r-- | Gemfile.lock | 29 | ||||
| -rw-r--r-- | app/assets/images/icons/link-small.png | bin | 0 -> 228 bytes | |||
| -rw-r--r-- | app/assets/images/icons/move.png | bin | 0 -> 594 bytes | |||
| -rw-r--r-- | app/assets/stylesheets/routes.css.scss | 25 | ||||
| -rw-r--r-- | app/assets/stylesheets/stop_points.css.scss | 56 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/stop_point_areas_controller.rb | 22 | ||||
| -rw-r--r-- | app/controllers/stop_points_controller.rb | 29 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 18 | ||||
| -rw-r--r-- | app/views/stop_points/_stop_point.html.erb | 20 | ||||
| -rw-r--r-- | app/views/stop_points/index.html.erb | 70 | ||||
| -rw-r--r-- | app/views/stop_points/new.html.erb | 31 | ||||
| -rw-r--r-- | config/locales/routes.yml | 4 | ||||
| -rw-r--r-- | config/locales/stop_points.yml | 87 | ||||
| -rw-r--r-- | config/routes.rb | 9 | ||||
| -rw-r--r-- | spec/views/routes/show.html.erb_spec.rb | 2 | 
17 files changed, 304 insertions, 102 deletions
| @@ -31,7 +31,7 @@ gem 'RedCloth'  gem "acts_as_tree", :git => "git://github.com/dryade/acts_as_tree.git"  gem 'apartment', :git => 'git://github.com/dryade/apartment.git' -gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' +gem 'ninoxe', :path => '~/dev/chouette-ninoxe' #:git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe'  gem 'acts_as_list', '0.1.6'  gem 'composite_primary_keys', '4.1.2' diff --git a/Gemfile.lock b/Gemfile.lock index b6b129246..64f671c64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,4 @@  GIT -  remote: git://chouette.dryade.priv/ninoxe -  revision: 0f2f0ab0d030c395464f43e4d5da79f5b74a89c6 -  specs: -    ninoxe (0.0.8) -      GeoRuby -      activerecord (~> 3.1.3) -      acts_as_list (= 0.1.6) -      composite_primary_keys (= 4.1.2) -      geokit -      rails (= 3.1.3) - -GIT    remote: git://github.com/dryade/activerecord-jdbc-adapter.git    revision: 0bf424bc3bcaf9f44646976cc4c1a8e9e57f11b4    specs: @@ -48,11 +36,21 @@ GIT      user_interface (0.0.1)        rails (~> 3.1.0) +PATH +  remote: ~/dev/chouette-ninoxe +  specs: +    ninoxe (0.0.8) +      GeoRuby +      activerecord (~> 3.1.3) +      acts_as_list (= 0.1.6) +      composite_primary_keys (= 4.1.2) +      geokit +      rails (= 3.1.3) +  GEM    remote: http://rubygems.org/    specs:      GeoRuby (1.3.4) -    RedCloth (4.2.9)      RedCloth (4.2.9-java)      SyslogLogger (1.4.1)      actionmailer (3.1.3) @@ -89,7 +87,6 @@ GEM      acts_as_list (0.1.6)      addressable (2.2.8)      arel (2.2.3) -    bcrypt-ruby (3.0.1)      bcrypt-ruby (3.0.1-java)      bouncy-castle-java (1.5.0146.1)      builder (3.0.0) @@ -135,7 +132,6 @@ GEM      factory_girl_rails (1.7.0)        factory_girl (~> 2.6.0)        railties (>= 3.0.0) -    ffi (1.0.11)      ffi (1.0.11-java)      formtastic (2.0.2)        rails (~> 3.0) @@ -162,8 +158,6 @@ GEM        bouncy-castle-java (>= 1.5.0146.1)      jruby-rack (1.1.5)      json (1.7.3-java) -    launchy (2.1.0) -      addressable (~> 2.2.6)      launchy (2.1.0-java)        addressable (~> 2.2.6)        ffi (~> 1.0.9) @@ -184,7 +178,6 @@ GEM      net-ssh (2.3.0)      net-ssh-gateway (1.1.0)        net-ssh (>= 1.99.1) -    nokogiri (1.5.2)      nokogiri (1.5.2-java)      orm_adapter (0.0.7)      polyamorous (0.5.0) diff --git a/app/assets/images/icons/link-small.png b/app/assets/images/icons/link-small.pngBinary files differ new file mode 100644 index 000000000..27cc0d9ee --- /dev/null +++ b/app/assets/images/icons/link-small.png diff --git a/app/assets/images/icons/move.png b/app/assets/images/icons/move.pngBinary files differ new file mode 100644 index 000000000..2e9bc42be --- /dev/null +++ b/app/assets/images/icons/move.png diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss index 3e2e5b5ed..a5c63bf01 100644 --- a/app/assets/stylesheets/routes.css.scss +++ b/app/assets/stylesheets/routes.css.scss @@ -58,39 +58,40 @@          font-weight: bold;      } -    .stop_area:after {  +    .stop_point:after {           @include after_div_for_object;        } -    .stop_areas { +    .stop_points {          margin-top: 20px;      } -    .stop_areas:after { +    .stop_points:after {          @include content_to_clear;      } -    .route_stop_areas { +    .route_stop_points {          clear: both; +        margin: 0px; +        padding: 0px;      } -    .stop_area { +    .stop_point {          @include div_for_object;          /* to create multi-column index */          width: 350px;          float: left;          padding-right: 10px; -        .area_type { +        .position {              width: 25px; -            height: 64px; +            height: 20px;              float: left; +            background-color: #61970B; +            font-weight: bold; +            color: white;              margin-right: 10px; -             - -            a { -                text-decoration: none;                    -            }             +            padding-left: 4px;          }      } diff --git a/app/assets/stylesheets/stop_points.css.scss b/app/assets/stylesheets/stop_points.css.scss new file mode 100644 index 000000000..d774fe0e7 --- /dev/null +++ b/app/assets/stylesheets/stop_points.css.scss @@ -0,0 +1,56 @@ +// Place all the styles related to the lines controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +@import "common"; + +#workspace.stop_points.index +{ +    .stop_point { +        margin-top: 8px; +        margin-bottom: 8px; + +        .description:after { +          clear: both; +          float: left; +        } + +        .description { +          .position { +              width: 25px; +              height: 20px; +              float: left; +              background-color: #61970B; +              font-weight: bold; +              color: white; +              margin-right: 10px; +              padding-left: 4px; +          } +          .info { +            margin-bottom: 5px; +            font-size: 10px; +            color: #777; +            font-weight: normal; +            line-height: 14px; +            .actions { +              margin-top: 3px; +              a { +                padding-left: 15px; +              } +              a.link { +                  background: url(image-path('icons/link-small.png')) no-repeat 0% 50%; +              } +              a.remove { +                  background: url(image-path('user_interface/ui/remove-small.png')) no-repeat 0% 50%; +              } +            } +          } +        } +        .handle { +          float: left; +          cursor: move; +          margin-right: 7px; +          margin-bottom: 20px; +        } +    } +} + diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 2ed39b0ac..fa429fbac 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -16,7 +16,7 @@ class RoutesController < ChouetteController    def show      @map = RouteMap.new referential, resource -    @stop_areas = resource.stop_areas.paginate(:page => params[:page], :per_page => 10) +    @stop_points = resource.stop_points.paginate(:page => params[:page], :per_page => 10)      show!    end diff --git a/app/controllers/stop_point_areas_controller.rb b/app/controllers/stop_point_areas_controller.rb new file mode 100644 index 000000000..b307936f0 --- /dev/null +++ b/app/controllers/stop_point_areas_controller.rb @@ -0,0 +1,22 @@ +class StopPointAreasController < ChouetteController + +  respond_to :json, :only => :index + +  def index +    respond_to do |format|   +      format.json { render :json => areas_maps }   +    end   +  end + +  def areas_maps +    areas.collect do |area| +      { :id => area.id.to_s, :name => "#{area.name} #{area.country_code}" } +    end +  end + +  def areas  +    Chouette::StopPoint.area_candidates.select{ |p| p.name =~ /#{params[:q]}/i  }        +  end + +end + diff --git a/app/controllers/stop_points_controller.rb b/app/controllers/stop_points_controller.rb new file mode 100644 index 000000000..a5e5f2a79 --- /dev/null +++ b/app/controllers/stop_points_controller.rb @@ -0,0 +1,29 @@ +class StopPointsController < ChouetteController +  defaults :resource_class => Chouette::StopPoint + +  respond_to :html + +  belongs_to :referential do +    belongs_to :line, :parent_class => Chouette::Line do +      belongs_to :route, :parent_class => Chouette::Route +    end +  end + +  def index      +    index! +  end + +  def create +    create! do |success, failure| +      success.html { redirect_to referential_line_route_path(@referential,@line,@route) } +    end +  end + + +  def sort +    parent.reorder!( params[:stop_point]) +    render :nothing => true +  end + +end + diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index c933d3c11..b98bab92a 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -64,18 +64,26 @@  </div> -<h3 class="route_stop_areas"><%= t('.stop_areas') %></h3> -<%= will_paginate @stop_areas %> -<div class="stop_areas paginated_content"> -  <%= render :partial => "stop_areas/stop_area", :collection => @stop_areas %> +<h3 class="route_stop_points"><%= t('.stop_points') %></h3> +<div class="pagination"> +  <div class="page_info"> +    <%= page_entries_info @stop_points %> +  </div> +  <%= will_paginate @stop_points, :container => false %> +</div> +<div class="stop_points paginated_content"> +  <%= render :partial => "stop_points/stop_point", :collection => @stop_points %> +</div> +<div class="pagination"> +  <%= will_paginate @stop_points, :container => false %>  </div> -<%= will_paginate @stop_areas %>  <% 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>    <li> +    <%= link_to  t('stop_points.actions.index'), referential_line_route_stop_points_path(@referential, @line, @route), :class => "edit" %>    </li>  </ul>  <% end %> diff --git a/app/views/stop_points/_stop_point.html.erb b/app/views/stop_points/_stop_point.html.erb new file mode 100644 index 000000000..3d9297b32 --- /dev/null +++ b/app/views/stop_points/_stop_point.html.erb @@ -0,0 +1,20 @@ +<%= div_for(stop_point) do %> +  <span class="position"> +    <%= stop_point.position + 1 %> +  </span> +  <%= link_to stop_point.stop_area.name, [@referential, stop_point.stop_area] %> +  <div class="info"> +    <p>       +      <% unless stop_point.stop_area.geometry %> +      <span class="warning"><%= t('.no_position') %></span> - +      <% end %> +    </p> +    <p>  +      <%= t('.lines') %> <% stop_point.stop_area.lines.each do |line| %> +        <span class="line"><%= line.number %></span> +      <% end %> - +      <%= stop_point.stop_area.human_attribute_name('country_code') %> <%= stop_point.stop_area.country_code %> +    </p> +  </div> +<% end %> + diff --git a/app/views/stop_points/index.html.erb b/app/views/stop_points/index.html.erb new file mode 100644 index 000000000..54ba8cfe6 --- /dev/null +++ b/app/views/stop_points/index.html.erb @@ -0,0 +1,70 @@ +<%= title_tag t('stop_points.index.title', :route => @route.name ) %> + +<div class="stop_points_index"> +  <div class="summary"> +    <p> +      <label><%= @route.class.model_name.human %>: </label> +      <%= link_to @route.name, [@referential, @line, @route] %> +    </p> +    <p> +      <label><%= @route.human_attribute_name(:line) %>: </label> +      <%= link_to line_formatted_name( @line), [@referential, @line] %> +    </p> +  </div> +   +  <h3><%= t('stop_points.index.subtitle')%></h3> +<% if @route.stop_points.empty? %> +  <p><%= t('.no_stop_point') %></p> +<% end %> +  <ul id="stop_areas"> +    <% for stop_point in @route.stop_points %> +      <%= content_tag_for :li, stop_point do %> +        <div class="handle" alt="<%= t('stop_points.index.move') %>" title="<%= t('stop_points.index.move') %>" ><%= image_tag "icons/move.png" %></div> +        <div class="description"> +          <span class="position"> +            <%= stop_point.position + 1 %> +          </span> +          <%= stop_point.stop_area.name %> +          <div class="info"> +            <%= stop_point.stop_area.human_attribute_name('country_code') %> <%= stop_point.stop_area.country_code %> +            <div class="actions">   +              <%= link_to t("stop_points.actions.show"), referential_stop_area_path(@referential, stop_point.stop_area), :class => "link" %> | +              <%= link_to t("actions.destroy"), referential_line_route_stop_point_path(@referential, @line, @route, stop_point), :method => :delete, :confirm =>  t('stop_points.actions.destroy_confirm'), :class => "remove" %> +            </div> +          </div> +        </div> +      <% end %> +    <% end %> +  </ul> +<% content_for :sidebar do %> +<ul class="actions"> +  <li><%= link_to t('stop_points.actions.new'), new_referential_line_route_stop_point_path(@referential, @line, @route), :class => "add" %> +  </li> +</ul> +<% end %> +<script> +// Sorting the list + +  $(document).ready(function(){ +    $('#stop_areas').sortable({ +      axis: 'y', +      dropOnEmpty: false, +      handle: '.handle', +      cursor: 'crosshair', +      items: 'li', +      opacity: 0.4, +      scroll: true, +      update: function(){ +      $.ajax({ +        type: 'post', +        data: $('#stop_areas').sortable('serialize'), +        dataType: 'script', +        complete: function(request){ +        $('#stop_areas').effect('highlight'); +      }, +      url: "<%= sort_referential_line_route_stop_points_path( @referential, @line, @route)%>"}) +      } +    }); +  }); +</script> +</div> diff --git a/app/views/stop_points/new.html.erb b/app/views/stop_points/new.html.erb new file mode 100644 index 000000000..a69840bf6 --- /dev/null +++ b/app/views/stop_points/new.html.erb @@ -0,0 +1,31 @@ +<%= title_tag  t('.title', :route => @route.name) %> + +<%= semantic_form_for [@referential, @line, @route, @stop_point] do |form| %> +<div> +  <%= form.inputs do %>  +    <%= form.input :stop_area_id, :label => t('.select_area'),:input_html => { :"data-pre" => [].to_json }  %> +  <% end %>   +   +  <%= form.buttons do %> +    <%= form.commit_button %> +    ou <%= link_to "revenir", referential_line_route_stop_points_path(@referential, @line, @route) %> +  <% end %> +</div> +<% end %> + +<script> +	$(function() { +          $( "#stop_point_stop_area_id" ).tokenInput('<%= referential_stop_point_areas_path(@referential, :format => :json) %>', {  +       crossDomain: false,  +       prePopulate: $('#stop_area_id').data('pre'), +       tokenLimit: 1, +       minChars: 3, +    }); +	}); +</script> +                          +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> + diff --git a/config/locales/routes.yml b/config/locales/routes.yml index a4cd3a366..149bdb508 100644 --- a/config/locales/routes.yml +++ b/config/locales/routes.yml @@ -11,7 +11,7 @@ en:        title: Update route %{route}      show:        title: Route %{route} -      stop_areas: "Routes's stop areas list"  +      stop_points: "Stop point on route list"         no_opposite_route: No reversed route associated        undefined: Undefined      index: @@ -49,7 +49,7 @@ fr:        title: "Modifier l'itinéraire %{route}"      show:        title: Itinéraire %{route} de la ligne %{line} -      stop_areas: "Liste des arrêts de l'itinéraire"  +      stop_points: "Liste des arrêts de l'itinéraire"         no_opposite_route: Aucun itinéraire associé en sens opposé        undefined: Non défini      index: diff --git a/config/locales/stop_points.yml b/config/locales/stop_points.yml index d26b88428..450b6924e 100644 --- a/config/locales/stop_points.yml +++ b/config/locales/stop_points.yml @@ -1,80 +1,45 @@  en:    stop_points:      actions: -      new: Add a new stop -      edit: Edit this stop -      destroy: Remove this stop -      destroy_confirm: Are you sure you want destroy this stop? +      show: Show +      index: Stops on route list +      new: Add a new stop on route +      edit: Edit this stop on route +      destroy: Remove this stop on route +      destroy_confirm: Are you sure you want destroy this stop on route ?      new: -      title: Add a new stop -    edit: -      title: Update stop %{stop_point} -    show: -      title: Stop %{stop_point} +      title: Add a new stop route +      select_area: Select a stop area      index: -      title: Stop areas -      name: Name -      selection: Selection -      selection_all: All +      title: Stops on route %{route} +      subtitle: Stops on route ordered +      move: Move +      no_stop_point: No stop point on route    activerecord:              models:         -      stop_point: Stop area +      stop_point: Stop point on route      attributes:        stop_point: -        name: Name -        registration_number: Registration number -        comment: Comments -        areatype: Area type -        nearest_topic_name: Nearest point of interest -        street_name: Street name -        country_code: INSEE code -        fare_code: Fare code -        x: x-position -        y: y-position -        longitude: Longitude -        latitude: Latitude -        objectid: Neptune identifier -        object_version: Version -        creation_time: Created on -        creator_id: Created by   fr:    stop_points:      actions: -      new: Ajouter un arrêt -      edit: Modifier cet arrêt -      destroy: Supprimer cet arrêt -      destroy_confirm: Etes vous sûr de détruire cet arrêt ? +      show: Consulter +      index: Liste des arrêts sur itinéraire +      new: Ajouter un arrêt sur itinéraire +      edit: Modifier cet arrêt sur itinéraire +      destroy: Supprimer cet arrêt sur itinéraire +      destroy_confirm: Etes vous sûr de détruire cet arrêt sur itinéraire ?      new: -      title: Ajouter un arrêt -    edit: -      title: "Modifier l'arrêt %{stop_point}" -    show: -      title: Arrêt %{stop_point} +      title: "Ajouter un arrêt à l'itinéraire %{route}" +      select_area: "Sélectionner un arrêt"      index: -      name: Nom -      title: Arrêts -      selection: Sélection -      selection_all: Tous +      title: "Liste des arrêts de l'itinéraire %{route}" +      subtitle: "Arrêts dans l'ordre du parcours " +      move: Déplacer +      no_stop_point: Aucun arrêt sur itinéraire    activerecord:              models:         -      stop_point: Arrêt +      stop_point: Arrêt sur itinéraire      attributes:        stop_point: -        name: Nom -        registration_number: "Numéro d'enregistrement" -        published_name: Nom public         -        comment: Commentaire -        area_type: "Type d'arrêt" -        nearest_topic_name: "Point d'intérêt le plus proche" -        street_name: Nom de la rue -        country_code: Code INSEE -        fare_code: Zone tarifaire -        x: Position X -        y: Position Y -        longitude: Longitude -        latitude: Latitude -        object_id: Identifiant Neptune -        object_version: Version -        creation_time: Créé le -        creator_id: Créé par diff --git a/config/routes.rb b/config/routes.rb index 491d16b43..e6aaeb2bf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ ChouetteIhm::Application.routes.draw do    # Sample resource route (maps HTTP verbs to controller actions automatically):    #   resources :products    resources :referentials do +    resources :stop_point_areas      resources :lines, :networks do        resources :stop_areas do          resources :stop_area_parents @@ -24,7 +25,13 @@ ChouetteIhm::Application.routes.draw do            get 'select_parent'          end        end         -      resources :routes +      resources :routes do +        resources :stop_points do +          collection do +              post :sort +          end +        end +      end      end      resources :companies, :stop_areas   diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb index 05d783eb0..5fa7485b7 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -5,7 +5,7 @@ describe "/routes/show" do    let!(:referential) { assign :referential, create(:referential) }    let!(:line) { assign :line, create(:line) }    let!(:route) { assign :route, create(:route, :line => line) } -  let!(:stop_areas) { assign :stop_areas, Array.new(2) { create(:stop_area) }.paginate } +  let!(:stop_points) { assign :stop_points, Array.new(2) { create(:stop_point) }.paginate }    let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) }    it "should render h2 with the route name" do | 
