diff options
| author | Luc Donnet | 2012-04-26 14:31:09 +0200 |
|---|---|---|
| committer | Luc Donnet | 2012-04-26 14:31:09 +0200 |
| commit | 856016f8fa214c9f924d68019aaa96c6589aa1c8 (patch) | |
| tree | 32ffab6405a727882f35e2345556b712368658e0 | |
| parent | 283c635d1547ae012a1aca0fd02329bb203c240f (diff) | |
| download | chouette-core-856016f8fa214c9f924d68019aaa96c6589aa1c8.tar.bz2 | |
Add links between stop areas
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | Gemfile.lock | 10 | ||||
| -rw-r--r-- | app/assets/images/icons/link.png | bin | 0 -> 946 bytes | |||
| -rw-r--r-- | app/assets/images/map/boarding_position.png (renamed from app/assets/images/map/boardingposition.png) | bin | 3440 -> 3440 bytes | |||
| -rw-r--r-- | app/assets/images/map/commercial_stop_point.png (renamed from app/assets/images/map/commercialstoppoint.png) | bin | 3561 -> 3561 bytes | |||
| -rw-r--r-- | app/assets/images/map/stop_place.png (renamed from app/assets/images/map/stopplace.png) | bin | 3809 -> 3809 bytes | |||
| -rw-r--r-- | app/assets/stylesheets/stop_areas.css.scss | 55 | ||||
| -rw-r--r-- | app/views/stop_areas/_stop_area.html.erb | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/index.html.erb | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/index.kml.erb | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.erb | 42 | ||||
| -rw-r--r-- | app/views/stop_areas/show.kml.erb | 2 | ||||
| -rw-r--r-- | config/locales/stop_areas.yml | 2 | ||||
| -rw-r--r-- | db/schema.rb | 12 | ||||
| -rw-r--r-- | spec/requests/stop_areas_spec.rb | 59 |
15 files changed, 178 insertions, 11 deletions
@@ -27,6 +27,7 @@ gem 'will_paginate', '~> 3.0' gem 'ransack' gem 'squeel' +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' diff --git a/Gemfile.lock b/Gemfile.lock index ca7be4d26..0f0de5dc0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: d6e74962215872d521fe0830e101f2cc3a5e8bf0 + revision: 8b4136d1c06cc03c22443cae4408b5b173dca9b5 specs: ninoxe (0.0.8) GeoRuby @@ -40,6 +40,13 @@ GIT user_interface (0.0.1) rails (~> 3.1.0) +GIT + remote: git@github.com:dryade/acts_as_tree.git + revision: 36ced5234beafdb3b21c2c2e2aa1686d37061497 + specs: + acts_as_tree (1.1.0) + activerecord (>= 3.0.0) + GEM remote: http://rubygems.org/ specs: @@ -292,6 +299,7 @@ DEPENDENCIES SyslogLogger activerecord-jdbcpostgresql-adapter! activerecord-jdbcsqlite3-adapter + acts_as_tree! apartment! capistrano capistrano-ext diff --git a/app/assets/images/icons/link.png b/app/assets/images/icons/link.png Binary files differnew file mode 100644 index 000000000..dcc09c640 --- /dev/null +++ b/app/assets/images/icons/link.png diff --git a/app/assets/images/map/boardingposition.png b/app/assets/images/map/boarding_position.png Binary files differindex f3ffe75d9..f3ffe75d9 100644 --- a/app/assets/images/map/boardingposition.png +++ b/app/assets/images/map/boarding_position.png diff --git a/app/assets/images/map/commercialstoppoint.png b/app/assets/images/map/commercial_stop_point.png Binary files differindex 2c87dc31a..2c87dc31a 100644 --- a/app/assets/images/map/commercialstoppoint.png +++ b/app/assets/images/map/commercial_stop_point.png diff --git a/app/assets/images/map/stopplace.png b/app/assets/images/map/stop_place.png Binary files differindex b5058573e..b5058573e 100644 --- a/app/assets/images/map/stopplace.png +++ b/app/assets/images/map/stop_place.png diff --git a/app/assets/stylesheets/stop_areas.css.scss b/app/assets/stylesheets/stop_areas.css.scss index 691fddaa2..60fba8749 100644 --- a/app/assets/stylesheets/stop_areas.css.scss +++ b/app/assets/stylesheets/stop_areas.css.scss @@ -45,8 +45,59 @@ padding-left:15px; } - .summary p label { - font-weight: bold; + .summary{ + height: 400px; + + p label { + font-weight: bold; + } + } + + .genealogical{ + margin-top: 20px; + + .parent{ + border: 2px solid black; + float: left; + padding: 3px 15px 3px 3px; + height: 25px; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + + .target{ + border: 2px solid #86b41d; + float: left; + padding: 3px 15px 3px 3px; + height: 25px; + font-weight: bold; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + + .children{ + float: left; + + .child{ + border: 2px solid black; + padding: 3px 15px 3px 3px; + height: 25px; + margin-bottom: 5px; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + } + + .link{ + float: left; + padding: 7px; + margin-right: 10px; + margin-left: 10px; + height: 25px; + } } } diff --git a/app/views/stop_areas/_stop_area.html.erb b/app/views/stop_areas/_stop_area.html.erb index 56c153226..cd4f71456 100644 --- a/app/views/stop_areas/_stop_area.html.erb +++ b/app/views/stop_areas/_stop_area.html.erb @@ -1,7 +1,7 @@ <%= div_for(stop_area) do %> <%= link_to([@referential, stop_area], :class => "preview") do %> <div class="area_type"> - <%= image_tag "map/" + stop_area.area_type.to_s.downcase + ".png" %> + <%= image_tag "map/" + stop_area.type + ".png" %> </div> <% end %> <%= link_to stop_area.name, [@referential, stop_area] %> diff --git a/app/views/stop_areas/index.html.erb b/app/views/stop_areas/index.html.erb index d9587f36b..deb5b1643 100644 --- a/app/views/stop_areas/index.html.erb +++ b/app/views/stop_areas/index.html.erb @@ -25,7 +25,7 @@ <ul class="selection"> <% Chouette::StopArea.types.each do |area_type| %> -<li><%= link_with_search (image_tag("map/" + area_type.name.downcase + ".png")+t("area_types.label.#{area_type.to_s}")), "areatype_eq" => area_type.name %></li> +<li><%= link_with_search (image_tag("map/" + area_type + ".png")+t("area_types.label.#{area_type.to_s}")), "areatype_eq" => area_type.name %></li> <% end %> <li><%= link_with_search (image_tag("map/all.png")+t(".selection_all")), {"areatype_eq" => nil}, :class => "all" %></li> </ul> diff --git a/app/views/stop_areas/index.kml.erb b/app/views/stop_areas/index.kml.erb index a40e99a6c..0d8e85d2c 100644 --- a/app/views/stop_areas/index.kml.erb +++ b/app/views/stop_areas/index.kml.erb @@ -4,7 +4,7 @@ <% @stop_areas.where("latitude is not null and longitude is not null").each do |stop_area| %> <Placemark id="<%= stop_area.id %>" > <name><%= stop_area.name %></name> - <stop_area_type><%= stop_area.area_type %></stop_area_type> + <stop_area_type><%= stop_area.type %></stop_area_type> <%= stop_area.geometry.kml_representation.html_safe %> </Placemark> <% end %> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb index 108a69a2b..b786eec34 100644 --- a/app/views/stop_areas/show.html.erb +++ b/app/views/stop_areas/show.html.erb @@ -79,12 +79,48 @@ <p> <label><%= @stop_area.human_attribute_name("creator_id") %>: </label> <%= @stop_area.creator_id %> - </p> - + </p> + </div> + + + <div class="genealogical"> + <% if @stop_area.parent.present? || @stop_area.children.present? %> + <h3><%= t(".genealogical") %></h3> + <% end %> + + <% if @stop_area.parent.present? %> + <div class="parent"> + <%= link_to([@referential, stop_area.parent]) do %> + <%= image_tag "map/" + @stop_area.parent.type + ".png" %><span><%= @stop_area.parent.name %></span> + <% end %> + <%= link_to image_tag("user_interface/ui/remove.png"), referential_stop_area_path(@referential, @stop_area.parent), :method => :delete, :confirm => t('stop_areas.actions.destroy_confirm'), :class => "remove" %> + </div> + <div class="link"><%= image_tag "icons/link.png"%></div> + <% end %> + + <% if @stop_area.parent.present? || @stop_area.children.present? %> + <div class="target"> + <%= image_tag "map/" + @stop_area.type + ".png"%><span><%= @stop_area.name %></span> + </div> + <% end %> + <% if @stop_area.children.present? %> + <div class="link"><%= image_tag "icons/link.png"%></div> + <div class="children"> + <% @stop_area.children.each do |child| %> + <div class="child"> + <%= link_to([@referential, child]) do %> + <%= image_tag "map/" + child.type + ".png" %><span><%= child.name %></span> + <% end %> + <%= link_to image_tag("user_interface/ui/remove.png"), referential_stop_area_path(@referential, child), :method => :delete, :confirm => t('stop_areas.actions.destroy_confirm'), :class => "remove" %> + </div> + <% end %> + </div> + <% end %> </div> + </div> - + <% content_for :sidebar do %> <ul class="actions"> <li><%= link_to t('stop_areas.actions.edit'), edit_referential_stop_area_path(@referential, @stop_area), :class => "edit" %></li> diff --git a/app/views/stop_areas/show.kml.erb b/app/views/stop_areas/show.kml.erb index f30597f24..60ea5f612 100644 --- a/app/views/stop_areas/show.kml.erb +++ b/app/views/stop_areas/show.kml.erb @@ -3,7 +3,7 @@ <Document> <Placemark id="<%= @stop_area.id %>" > <name><%= @stop_area.name %></name> - <stop_area_type><%= @stop_area.area_type %></stop_area_type> + <stop_area_type><%= @stop_area.type %></stop_area_type> <%= @stop_area.geometry.kml_representation.html_safe %> </Placemark> </Document> diff --git a/config/locales/stop_areas.yml b/config/locales/stop_areas.yml index bc1254ac9..ca4751dbe 100644 --- a/config/locales/stop_areas.yml +++ b/config/locales/stop_areas.yml @@ -16,6 +16,7 @@ en: title: Stop %{stop_area} geographic_data: Geographic data no_geographic_data: None + genealogical: Links between stop area index: title: Stop areas name_or_country_code: Name or Country code @@ -69,6 +70,7 @@ fr: title: Arrêt %{stop_area} geographic_data: Données géographiques no_geographic_data: Aucune + genealogical: Lien entre arrêts index: name_or_country_code: Nom ou Code Postal title: Arrêts diff --git a/db/schema.rb b/db/schema.rb index c21ab020c..07dc4922d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120425080337) do +ActiveRecord::Schema.define(:version => 20120425125542) do create_table "company", :force => true do |t| t.string "objectid" @@ -116,6 +116,16 @@ ActiveRecord::Schema.define(:version => 20120425080337) do add_index "stoparea", ["objectid"], :name => "stoparea_objectid_key", :unique => true add_index "stoparea", ["parentid"], :name => "index_stoparea_on_parentid" + create_table "stoppoint", :force => true do |t| + t.integer "routeid", :limit => 8 + t.integer "stopareaid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.integer "position" + end + create_table "timetable", :force => true do |t| t.string "objectid", :null => false t.integer "objectversion", :default => 1 diff --git a/spec/requests/stop_areas_spec.rb b/spec/requests/stop_areas_spec.rb new file mode 100644 index 000000000..bd01c59ba --- /dev/null +++ b/spec/requests/stop_areas_spec.rb @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "StopAreas" do + login_user + + let!(:referential) { create(:referential).switch } + let!(:stop_areas) { referential; Array.new(2) { Factory(:stop_area) } } + subject { stop_areas.first } + + describe "list" do + it "display stop_areas" do + visit referential_stop_areas_path(referential) + page.should have_content(stop_areas.first.name) + page.should have_content(stop_areas.last.name) + end + + end + + + describe "show" do + it "display stop_area" do + visit referential_stop_areas_path(referential) + click_link "#{stop_areas.first.name}" + page.should have_content(stop_areas.first.name) + end + + it "display map" do + visit referential_stop_areas_path(referential) + click_link "#{stop_areas.first.name}" + page.should have_selector("#map", :class => 'stop_area') + end + + end + + describe "new" do + it "creates stop_area and return to show" do + visit referential_stop_areas_path(referential) + click_link "Ajouter un arrêt" + fill_in "Nom", :with => "StopArea 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + #fill_in "Identifiant Neptune", :with => "test:StopArea:1" + click_button("Créer Arrêt") + page.should have_content("StopArea 1") + end + end + + describe "edit and return to show" do + it "edit stop_area" do + visit referential_stop_area_path(referential, subject) + click_link "Modifier cet arrêt" + fill_in "Nom", :with => "StopArea Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Arrêt") + page.should have_content("StopArea Modified") + end + end + +end |
