diff options
| author | Michel Etienne | 2012-06-07 14:25:25 +0200 |
|---|---|---|
| committer | Michel Etienne | 2012-06-07 14:25:25 +0200 |
| commit | 99be0398f6f9826d6250bc061c721854bef07674 (patch) | |
| tree | fb7497919329d751dc742ffa9fddce1d331ca094 | |
| parent | cd34f2cbb0e29c7b59cb60af43571f6fd8cc5bda (diff) | |
| download | chouette-core-99be0398f6f9826d6250bc061c721854bef07674.tar.bz2 | |
manage routing constraint links
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | app/controllers/stop_area_routing_lines_controller.rb | 21 | ||||
| -rw-r--r-- | app/controllers/stop_area_routing_stops_controller.rb | 21 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 9 | ||||
| -rw-r--r-- | app/views/stop_areas/add_routing_lines.html.erb | 30 | ||||
| -rw-r--r-- | app/views/stop_areas/add_routing_stops.html.erb | 30 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.erb | 5 | ||||
| -rw-r--r-- | config/locales/stop_areas.yml | 20 | ||||
| -rw-r--r-- | config/routes.rb | 17 |
9 files changed, 142 insertions, 13 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 974b8e661..11d34806a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: 18e831101b63ea349c9121137ab7210b5dfca958 + revision: b33ed7a79024422e94d041858b7053eede7399f8 specs: ninoxe (0.0.8) GeoRuby diff --git a/app/controllers/stop_area_routing_lines_controller.rb b/app/controllers/stop_area_routing_lines_controller.rb new file mode 100644 index 000000000..9ba6fb40c --- /dev/null +++ b/app/controllers/stop_area_routing_lines_controller.rb @@ -0,0 +1,21 @@ +class StopAreaRoutingLinesController < ChouetteController + + respond_to :json, :only => :index + + def index + respond_to do |format| + format.json { render :json => routing_lines_maps } + end + end + + def routing_lines_maps + routing_lines.collect do |line| + { :id => line.id.to_s, :name => "#{line.number} - #{line.name}" } + end + end + + def routing_lines + referential.lines.all.select{ |p| p.name =~ /#{params[:q]}/i || p.number =~ /#{params[:q]}/i } + end + +end diff --git a/app/controllers/stop_area_routing_stops_controller.rb b/app/controllers/stop_area_routing_stops_controller.rb new file mode 100644 index 000000000..c5e7980f9 --- /dev/null +++ b/app/controllers/stop_area_routing_stops_controller.rb @@ -0,0 +1,21 @@ +class StopAreaRoutingStopsController < ChouetteController + + respond_to :json, :only => :index + + def index + respond_to do |format| + format.json { render :json => routing_stops_maps } + end + end + + def routing_stops_maps + routing_stops.collect do |stop| + { :id => stop.id.to_s, :name => "#{stop.name} #{stop.country_code}" } + end + end + + def routing_stops + referential.stop_areas.find(params[:stop_area_id]).possible_children.select{ |p| p.name =~ /#{params[:q]}/i } + end + +end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 0c8da7838..55bf713a7 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -24,12 +24,12 @@ class StopAreasController < ChouetteController @children = stop_area.children end - def add_lines + def add_routing_lines @stop_area = stop_area @lines = stop_area.routing_lines end - def add_stops + def add_routing_stops @stop_area = stop_area @stops = stop_area.routing_stops end @@ -59,6 +59,11 @@ class StopAreasController < ChouetteController edit! end +# def update +# puts :resource +# update! +# end + protected alias_method :stop_area, :resource diff --git a/app/views/stop_areas/add_routing_lines.html.erb b/app/views/stop_areas/add_routing_lines.html.erb new file mode 100644 index 000000000..967d502d8 --- /dev/null +++ b/app/views/stop_areas/add_routing_lines.html.erb @@ -0,0 +1,30 @@ +<%= title_tag t('stop_areas.add_routing_lines.title', :stop_area => @stop_area.name ) %> + +<%= semantic_form_for [@referential, @stop_area] do |form| %> +<div> + <%= form.inputs do %> + <%= form.input :routing_line_ids, :as => :text, :input_html => { :"data-pre" => ( @lines.map { |line| { :id => line.id.to_s, :name => "#{line.number} - #{line.name}" } } ).to_json } %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button %> + <%= t('or') %> + <%= link_to t('cancel'), [@referential, @stop_area] %> + <% end %> +</div> +<% end %> + +<script> + $(function() { + $( "#stop_area_routing_line_ids" ).tokenInput('<%= referential_stop_area_stop_area_routing_lines_path(@referential, @stop_area, :format => :json) %>', { + crossDomain: false, + prePopulate: $('#stop_area_routing_line_id').data('pre'), + minChars: 1, + }); + }); +</script> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/stop_areas/add_routing_stops.html.erb b/app/views/stop_areas/add_routing_stops.html.erb new file mode 100644 index 000000000..49c0cad7a --- /dev/null +++ b/app/views/stop_areas/add_routing_stops.html.erb @@ -0,0 +1,30 @@ +<%= title_tag t('stop_areas.add_routing_stops.title', :stop_area => @stop_area.name ) %> + +<%= semantic_form_for [@referential, @stop_area] do |form| %> +<div> + <%= form.inputs do %> + <%= form.input :routing_stop_ids, :as => :text, :input_html => { :"data-pre" => ( @stops.map { |stop| { :id => stop.id.to_s, :name => "#{stop.name} #{stop.country_code}" } } ).to_json } %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button %> + <%= t('or') %> + <%= link_to t('cancel'), [@referential, @stop_area] %> + <% end %> +</div> +<% end %> + +<script> + $(function() { + $( "#stop_area_routing_stop_ids" ).tokenInput('<%= referential_stop_area_stop_area_routing_stops_path(@referential, @stop_area, :format => :json) %>', { + crossDomain: false, + prePopulate: $('#stop_area_routing_stop_id').data('pre'), + minChars: 3, + }); + }); +</script> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb index 887c60089..acd85bfcf 100644 --- a/app/views/stop_areas/show.html.erb +++ b/app/views/stop_areas/show.html.erb @@ -147,13 +147,14 @@ <ul class="actions"> <li><%= link_to t('stop_areas.actions.edit'), edit_referential_stop_area_path(@referential, @stop_area), :class => "edit" %></li> <li><%= link_to t('stop_areas.actions.destroy'), referential_stop_area_path(@referential, @stop_area), :method => :delete, :confirm => t('stop_areas.actions.destroy_confirm'), :class => "remove" %></li> + <p> <% if @stop_area.stop_area_type == 'itl' %> - <li><%= link_to t('stop_areas.actions.add_lines'), add_lines_referential_stop_area_path(@referential, @stop_area), :class => "add_lines" %></li> + <li><%= link_to t('stop_areas.actions.add_routing_lines'), add_routing_lines_referential_stop_area_path(@referential, @stop_area), :class => "add_routing_lines" %></li> <% else %> <li><%= link_to t('stop_areas.actions.select_parent'), select_parent_referential_stop_area_path(@referential, @stop_area), :class => "select_parent" %></li> <% end %> <% if @stop_area.stop_area_type == 'itl' %> - <li><%= link_to t('stop_areas.actions.add_stops'), add_stops_referential_stop_area_path(@referential, @stop_area), :class => "add_stops" %></li> + <li><%= link_to t('stop_areas.actions.add_routing_stops'), add_routing_stops_referential_stop_area_path(@referential, @stop_area), :class => "add_routing_stops" %></li> <% elsif @stop_area.stop_area_type != 'boarding_position' && @stop_area.stop_area_type != 'quay' %> <li><%= link_to t('stop_areas.actions.add_children'), add_children_referential_stop_area_path(@referential, @stop_area), :class => "add_children" %></li> <% end %> diff --git a/config/locales/stop_areas.yml b/config/locales/stop_areas.yml index ee16bed99..2aeb158db 100644 --- a/config/locales/stop_areas.yml +++ b/config/locales/stop_areas.yml @@ -10,8 +10,8 @@ en: destroy_confirm: Are you sure you want destroy this stop? select_parent: Manage Parent add_children: Manage Children - add_lines: "Manage constraint's lines" - add_stops: "Manage constraint's stops" + add_routing_lines: "Manage constraint's lines" + add_routing_stops: "Manage constraint's stops" new: title: Add a new stop edit: @@ -32,6 +32,10 @@ en: title: Manage parent of stop area %{stop_area} add_children: title: Manage children of stop area %{stop_area} + add_lines: + title: Manage lines of routing constraint %{stop_area} + add_stops: + title: Manage stop areas of routing constraint %{stop_area} activerecord: models: stop_area: @@ -59,6 +63,8 @@ en: creation_time: Created on creatorid: Created by children_ids: Children + routing_stop_ids: Attached stops + routing_line_ids: Attached lines parent: Parent formtastic: hints: @@ -78,8 +84,8 @@ fr: destroy_confirm: Etes vous sûr de détruire cet arrêt ? select_parent: Gérer le parent add_children: Gérer les fils - add_lines: "Gérer les lignes de l'ITL" - add_stops: "Gérer les arrêts de l'ITL" + add_routing_lines: "Gérer les lignes de l'ITL" + add_routing_stops: "Gérer les arrêts de l'ITL" new: title: Ajouter un arrêt edit: @@ -100,6 +106,10 @@ fr: title: "Gérer le parent de l'arrêt %{stop_area}" add_children: title: "Gérer les fils de l'arrêt %{stop_area}" + add_routing_lines: + title: "Gérer les lignes de l'ITL %{stop_area} " + add_routing_stops: + title: "Gérer les arrêts de l'ITL %{stop_area} " activerecord: models: stop_area: @@ -128,6 +138,8 @@ fr: creation_time: Créé le creator_id: Créé par children_ids: Fils + routing_stop_ids: "Arrêts concernés par l'ITL" + routing_line_ids: "Lignes affectées par l'ITL" parent: Parent formtastic: hints: diff --git a/config/routes.rb b/config/routes.rb index a6ff78a7a..6645ac927 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,9 +25,13 @@ ChouetteIhm::Application.routes.draw do resources :stop_areas do resources :stop_area_parents resources :stop_area_children + resources :stop_area_routing_lines + resources :stop_area_routing_stops member do get 'add_children' get 'select_parent' + get 'add_routing_lines' + get 'add_routing_stops' end end resources :routes do @@ -53,13 +57,13 @@ ChouetteIhm::Application.routes.draw do resources :stop_areas do resources :stop_area_parents resources :stop_area_children - resources :stop_area_lines - resources :stop_area_stops + resources :stop_area_routing_lines + resources :stop_area_routing_stops member do get 'add_children' get 'select_parent' - get 'add_lines' - get 'add_stops' + get 'add_routing_lines' + get 'add_routing_stops' end end @@ -70,9 +74,14 @@ ChouetteIhm::Application.routes.draw do end resources :stop_areas do resources :stop_area_parents + resources :stop_area_children + resources :stop_area_routing_lines + resources :stop_area_routing_stops member do get 'add_children' get 'select_parent' + get 'add_routing_lines' + get 'add_routing_stops' end end end |
