diff options
| author | Luc Donnet | 2014-12-11 17:42:15 +0100 |
|---|---|---|
| committer | Luc Donnet | 2014-12-11 17:42:15 +0100 |
| commit | a0433013264531e825268d0ae1a0da873d368313 (patch) | |
| tree | d52bf2868ed0edea7181ba7f58ffecc4a597cd31 | |
| parent | 38cc4cf370129bf0b88bba9c62df1b165261430f (diff) | |
| download | chouette-core-a0433013264531e825268d0ae1a0da873d368313.tar.bz2 | |
Add boarding and alighting to routes controller
| -rw-r--r-- | Gemfile | 6 | ||||
| -rw-r--r-- | Gemfile.lock | 35 | ||||
| -rw-r--r-- | app/assets/stylesheets/main/routes.css.scss | 8 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 17 | ||||
| -rw-r--r-- | app/helpers/stop_areas_helper.rb | 12 | ||||
| -rw-r--r-- | app/views/routes/edit_boarding_alighting.html.erb | 27 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 12 | ||||
| -rw-r--r-- | config/locales/enumerize.en.yml | 17 | ||||
| -rw-r--r-- | config/locales/enumerize.fr.yml | 17 | ||||
| -rw-r--r-- | config/locales/routes.yml | 13 | ||||
| -rw-r--r-- | config/locales/stop_points.yml | 10 | ||||
| -rw-r--r-- | config/routes.rb | 4 | ||||
| -rw-r--r-- | db/migrate/20141210134214_add_boarding_and_alighting_to_stop_point.ninoxe_engine.rb | 10 | ||||
| -rw-r--r-- | db/schema.rb | 6 |
14 files changed, 179 insertions, 15 deletions
@@ -26,6 +26,7 @@ gem 'devise_invitable' # Map, Geolocalization gem "map_layers", "0.0.4" gem "georuby-ext", "0.0.5" +gem "georuby", "2.3.0" # Fix version for georuby-ext because api has changed # User interface gem 'language_engine', '0.0.5' @@ -75,9 +76,9 @@ gem 'google-analytics-rails' gem 'will_paginate', '~> 3.0' gem 'ransack' gem 'squeel' -#gem 'ninoxe', :git => 'https://github.com/afimb/ninoxe.git' +gem 'ninoxe', :git => 'https://github.com/afimb/ninoxe.git' #gem 'ninoxe',:path => '~/workspace/chouette/ninoxe' -gem 'ninoxe', '~> 1.1.3' +#gem 'ninoxe', '~> 1.1.3' gem 'acts_as_list', '0.1.6' gem "acts_as_tree-1.8", '1.1.0', :require => "acts_as_tree" @@ -94,6 +95,7 @@ group :development do gem 'guard' gem 'guard-rspec' gem 'rails-erd' + gem 'meta_request' end group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index 86a48b041..6560ec708 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,17 @@ +GIT + remote: https://github.com/afimb/ninoxe.git + revision: 37fdb46bfa9c089a231ea5e7e093a9b78cc11b5e + specs: + ninoxe (1.1.3) + activerecord (~> 3.2.13) + acts-as-taggable-on (>= 3) + acts_as_list (>= 0.1.6) + acts_as_tree (>= 1.1.0) + deep_cloneable (~> 2.0.0) + enumerize (~> 0.8.0) + foreigner (= 1.6.0) + georuby-ext (= 0.0.5) + GEM remote: http://rubygems.org/ remote: https://rails-assets.org/ @@ -56,6 +70,7 @@ GEM builder (3.0.4) calendar_helper (0.2.5) open4 + callsite (0.0.11) capistrano (2.13.5) highline net-scp (>= 1.0.0) @@ -108,6 +123,8 @@ GEM dr-apartment (0.14.1) dr-ffi-proj4 (0.0.3) ffi (>= 1.0.0) + enumerize (0.8.0) + activesupport (>= 3.2) erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) @@ -186,6 +203,10 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) map_layers (0.0.4) + meta_request (0.3.4) + callsite (~> 0.0, >= 0.0.11) + rack-contrib (~> 1.1) + railties (>= 3.0.0, < 5.0.0) metaclass (0.0.1) mime-types (1.25.1) mocha (0.14.0) @@ -201,14 +222,6 @@ GEM net-ssh (2.6.2) net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) - ninoxe (1.1.3) - activerecord (~> 3.2.13) - acts-as-taggable-on (>= 3) - acts_as_list (>= 0.1.6) - acts_as_tree (>= 1.1.0) - deep_cloneable (~> 2.0.0) - foreigner (= 1.6.0) - georuby-ext (= 0.0.5) nokogiri (1.5.10) nokogiri (1.5.10-java) open4 (1.3.0) @@ -222,6 +235,8 @@ GEM rack (1.4.5) rack-cache (1.2) rack (>= 0.4) + rack-contrib (1.2.0) + rack (>= 0.9.1) rack-ssl (1.3.4) rack rack-test (0.6.2) @@ -400,6 +415,7 @@ DEPENDENCIES factory_girl_rails (= 1.7) font-awesome-sass (~> 4.2.0) formtastic (= 2.3.1) + georuby (= 2.3.0) georuby-ext (= 0.0.5) google-analytics-rails gravatar_image_tag @@ -414,9 +430,10 @@ DEPENDENCIES language_engine (= 0.0.5) launchy map_layers (= 0.0.4) + meta_request modernizr-rails (~> 2.0.6) morrisjs-rails - ninoxe (~> 1.1.3) + ninoxe! pg (~> 0.11.0) rabl rails (= 3.2.18) diff --git a/app/assets/stylesheets/main/routes.css.scss b/app/assets/stylesheets/main/routes.css.scss index 31891f39e..7714c13a3 100644 --- a/app/assets/stylesheets/main/routes.css.scss +++ b/app/assets/stylesheets/main/routes.css.scss @@ -34,6 +34,14 @@ } } +#workspace.routes.edit_boarding_alighting{ + + .stop_area{ + padding-top: 7px; + } + +} + #workspace.routes.show { } diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 391a14d88..6454ce068 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -15,6 +15,21 @@ class RoutesController < ChouetteController end end + def edit_boarding_alighting + @route = route + build_breadcrumb :edit + end + + def save_boarding_alighting + @route = route + + if @route.update_attributes(params[:route]) + redirect_to referential_line_route_path(@referential, @line, @route) + else + render "edit_boarding_alighting" + end + end + def show @map = RouteMap.new(route).with_helpers(self) @stop_points = route.stop_points.paginate(:page => params[:page]) @@ -26,7 +41,7 @@ class RoutesController < ChouetteController # overwrite inherited resources to use delete instead of destroy # foreign keys will propagate deletion) def destroy_resource(object) - object.delete + object.delete end def destroy diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb index e287af7f3..ce0dab85a 100644 --- a/app/helpers/stop_areas_helper.rb +++ b/app/helpers/stop_areas_helper.rb @@ -1,4 +1,16 @@ module StopAreasHelper + def explicit_name(stop_area) + name = localization = "" + + name += truncate(stop_area.name, :length => 30) || "" + name += (" <small>["+ ( truncate(stop_area.registration_number, :length => 10) || "") + "]</small>") if stop_area.registration_number + + localization += stop_area.zip_code || "" + localization += ( truncate(stop_area.city_name, :length => 15) ) if stop_area.city_name + + ( "#{image_tag( stop_area_picture_url(stop_area)) }" + " <span style='height:25px; line-height:25px; margin-left: 5px; '>" + name + " <small style='height:25px; line-height:25px; margin-left: 10px; color: #555;'>" + localization + "</small></span>").html_safe + end + def genealogical_title return t(".stop_areas.genealogical.genealogical_routing") if @stop_area.stop_area_type == 'itl' t("stop_areas.genealogical.genealogical") diff --git a/app/views/routes/edit_boarding_alighting.html.erb b/app/views/routes/edit_boarding_alighting.html.erb new file mode 100644 index 000000000..fc3378425 --- /dev/null +++ b/app/views/routes/edit_boarding_alighting.html.erb @@ -0,0 +1,27 @@ +<%= title_tag t('routes.edit_boarding_alighting.title', :route => @route.name ) %> + +<%= simple_form_for ["save_boarding_alighting", @referential, @line, @route] do |form| %> +<table class="table table-hover"> + <thead> + <th><%= t(".stop_area_name") %></th> + <th><%= t(".for_boarding") %></th> + <th><%= t(".for_alighting") %></th> + </thead> + <tbody> + <%= form.simple_fields_for :stop_points do |stop_points_form| %> + <tr> + <td> + <%= explicit_name(stop_points_form.object.stop_area) %> + </td> + <td><%= stop_points_form.input :for_boarding, :label => false, include_blank: t("simple_form.include_blanks.defaults.for_boarding") %></td> + <td><%= stop_points_form.input :for_alighting, :label => false, include_blank: t("simple_form.include_blanks.defaults.for_alighting") %></td> + </tr> + <% end %> + </tbody> +</table> + + <div class="submit"> + <%= form.button :submit, :class => "" %> + <%= link_to t("cancel"), referential_line_route_path(@referential, @line, @route) %> + </div> +<% end %> diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index fe1a9c956..e1f59cde9 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -93,18 +93,26 @@ <li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li> <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, :data => {:confirm => t('routes.actions.destroy_confirm')}, :class => "remove" %></li> -<% if @route.stop_points.size >= 2 %> +</ul> +<ul class="actions"> + <% if @route.stop_points.size >= 2 %> <li><%= link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), :class => "add" %></li> <% end %> + <% if @route.stop_points.present? %> + <li><%= link_to t('routes.actions.edit_boarding_alighting'), edit_boarding_alighting_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li> + <% end %> <% if @route.journey_patterns.size > 0 %> <li> <%= link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], :class => "clock" %> </li> <% end %> +</ul> + +<ul class="actions"> <li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li> <li><%= link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :zip), :class => "export" %></li> </ul> - <%= creation_tag(@route) %> +<%= creation_tag(@route) %> <% end %> diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml new file mode 100644 index 000000000..574c316cd --- /dev/null +++ b/config/locales/enumerize.en.yml @@ -0,0 +1,17 @@ +en: + simple_form: + include_blanks: + defaults: + for_boarding: "Undefined" + for_alighting: "Undefined" + enumerize: + for_boarding: + normal: "Regularly scheduled pickup" + forbidden: "No pickup available" + request_stop: "Pickup if requested" + is_flexible: "Booking requested for pickup" + for_alighting: + normal: "Regularly scheduled drop off" + forbidden: "No drop off available" + request_stop: "Drop off if requested" + is_flexible: "Booking requested for drop off"
\ No newline at end of file diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml new file mode 100644 index 000000000..0dad16319 --- /dev/null +++ b/config/locales/enumerize.fr.yml @@ -0,0 +1,17 @@ +fr: + simple_form: + include_blanks: + defaults: + for_boarding: "Non défini" + for_alighting: "Non défini" + enumerize: + for_boarding: + normal: "Montée autorisée" + forbidden: "Montée interdite" + request_stop: "Montée sur demande au conducteur" + is_flexible: "Montée sur réservation" + for_alighting: + normal: "Descente autorisée" + forbidden: "Descente interdite" + request_stop: "Descente sur demande au conducteur" + is_flexible: "Descente sur réservation"
\ No newline at end of file diff --git a/config/locales/routes.yml b/config/locales/routes.yml index b68f1802a..1807ef30d 100644 --- a/config/locales/routes.yml +++ b/config/locales/routes.yml @@ -3,6 +3,7 @@ en: actions: new: "Add a new route" edit: "Edit this route" + edit_boarding_alighting: "Stop alighting and boarding" destroy: "Remove this route" destroy_confirm: "Are you sure you want destroy this route?" export_kml: "Export KML route" @@ -25,6 +26,11 @@ en: title: "Routes" selection: "Selection" selection_all: "All" + edit_boarding_alighting: + title: "Stop alighting and boarding properties" + stop_area_name: "Stop area name" + for_boarding: "Boarding" + for_alighting: "Alighting" route: no_journey_pattern: "No Journey pattern" wayback: @@ -58,6 +64,7 @@ en: object_version: "Version" creation_time: "Created on" creator_id: "Created by" + no_journey_pattern: "No journey pattern" formtastic: titles: route: @@ -68,6 +75,7 @@ fr: actions: new: "Ajouter une séquence d'arrêts" edit: "Modifier cette séquence d'arrêts" + edit_boarding_alighting: "Contraintes de montée - descente" destroy: "Supprimer cette séquence d'arrêts" destroy_confirm: "Etes vous sûr de supprimer cette séquence d'arrêts ?" export_kml: "Export KML de la séquence d'arrêts" @@ -90,6 +98,11 @@ fr: title: "Séquences d'arrêts" selection: "Sélection" selection_all: "Tous" + edit_boarding_alighting: + title: "Contraintes de montée - descente aux arrêts" + stop_area_name: "Nom de l'arrêt" + for_boarding: "Montée" + for_alighting: "Descente" route: no_journey_pattern: "Pas de mission" wayback: diff --git a/config/locales/stop_points.yml b/config/locales/stop_points.yml index cead1f93b..819ed4c0f 100644 --- a/config/locales/stop_points.yml +++ b/config/locales/stop_points.yml @@ -33,6 +33,11 @@ en: attributes: stop_point: lines: "lines" + simple_form: + labels: + stop_point: + for_boarding: "Pickup" + for_alighting: "Drop off" fr: stop_points: reorder_success: "La list des arrêts a été mise à jour" @@ -68,3 +73,8 @@ fr: attributes: stop_point: lines: "Lignes" + simple_form: + labels: + stop_point: + for_boarding: "Montée" + for_alighting: "Descente" diff --git a/config/routes.rb b/config/routes.rb index 530e17409..37cff975e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,6 +76,10 @@ ChouetteIhm::Application.routes.draw do resources :lines, :networks, :group_of_lines do resources :routes do + member do + get 'edit_boarding_alighting' + put 'save_boarding_alighting' + end resources :journey_patterns do member do get 'new_vehicle_journey' diff --git a/db/migrate/20141210134214_add_boarding_and_alighting_to_stop_point.ninoxe_engine.rb b/db/migrate/20141210134214_add_boarding_and_alighting_to_stop_point.ninoxe_engine.rb new file mode 100644 index 000000000..7faceeded --- /dev/null +++ b/db/migrate/20141210134214_add_boarding_and_alighting_to_stop_point.ninoxe_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from ninoxe_engine (originally 20141210123519) +class AddBoardingAndAlightingToStopPoint < ActiveRecord::Migration + def change + add_column :stop_points, :for_boarding, :string + add_column :stop_points, :for_alighting, :string + + add_column :vehicle_journey_at_stops, :for_boarding, :string + add_column :vehicle_journey_at_stops, :for_alighting, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 89cbf7d87..ba4a8fd52 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20141105123538) do +ActiveRecord::Schema.define(:version => 20141210134214) do create_table "access_links", :force => true do |t| t.integer "access_point_id", :limit => 8 @@ -419,6 +419,8 @@ ActiveRecord::Schema.define(:version => 20141105123538) do t.datetime "creation_time" t.string "creator_id" t.integer "position" + t.string "for_boarding" + t.string "for_alighting" end add_index "stop_points", ["objectid"], :name => "stop_points_objectid_key", :unique => true @@ -541,6 +543,8 @@ ActiveRecord::Schema.define(:version => 20141105123538) do t.time "waiting_time" t.time "elapse_duration" t.time "headway_frequency" + t.string "for_boarding" + t.string "for_alighting" end add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_pointid" |
