diff options
| author | Luc Donnet | 2012-03-22 17:56:58 +0100 |
|---|---|---|
| committer | Luc Donnet | 2012-03-22 17:56:58 +0100 |
| commit | d753591230660f64d09e21ce5cc1cca1deb6491a (patch) | |
| tree | 7e1b363322562412901878c13ed851fe16453422 | |
| parent | 64fd52a1ba9a29c19409cd9778eed44e6e14fb33 (diff) | |
| download | chouette-core-d753591230660f64d09e21ce5cc1cca1deb6491a.tar.bz2 | |
Add stop area
24 files changed, 466 insertions, 96 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 946965170..10456c7d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: a80f47a66862abb0c46069e765676aee53e360ea + revision: 181c6fa75c4a82fb8c4bff4eec05ef1013b7ae61 specs: chouette-ninoxe (0.0.8) GeoRuby diff --git a/app/assets/stylesheets/companies.css.scss b/app/assets/stylesheets/companies.css.scss index 4c45138ee..563a25798 100644 --- a/app/assets/stylesheets/companies.css.scss +++ b/app/assets/stylesheets/companies.css.scss @@ -112,28 +112,4 @@ } } -/* FIXME a déplacer dans layout */ - -#sidebar ul { - padding: 0 8px; - - li { - margin: 4px 0; - } -} - -#sidebar ul.selection li { - a { - padding-left: 20px; - } - a.current { - text-decoration: none; - color: black !important; - background: url(image-path('user_interface/ui/accept.png')) no-repeat; - } - a.all { - background-image: none; - } -} - diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 14823294f..d65167cfa 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -6,3 +6,32 @@ $tabs_color: white; $text_color: #222; @import "user_interface/layout"; + +#sidebar ul { + padding: 0 8px; + + li { + margin: 4px 0; + } +} + +#sidebar ul.selection li { + a { + padding-left: 20px; + } + a.current { + text-decoration: none; + color: black !important; + background: url(image-path('user_interface/ui/accept.png')) no-repeat; + } + a.all { + background-image: none; + } +} + + +#map { + float: right; + width: 600px; + height: 400px; +} diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 022ba4955..5562c4e4b 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -143,34 +143,5 @@ } } -/* FIXME a déplacer dans layout */ - -#sidebar ul { - padding: 0 8px; - - li { - margin: 4px 0; - } -} - -#sidebar ul.selection li { - a { - padding-left: 20px; - } - a.current { - text-decoration: none; - color: black !important; - background: url(image-path('user_interface/ui/accept.png')) no-repeat; - } - a.all { - background-image: none; - } -} - -#map { - float: right; - width: 600px; - height: 400px; -} diff --git a/app/assets/stylesheets/networks.css.scss b/app/assets/stylesheets/networks.css.scss index 6a8f4bbc2..c05752623 100644 --- a/app/assets/stylesheets/networks.css.scss +++ b/app/assets/stylesheets/networks.css.scss @@ -111,28 +111,3 @@ } } -/* FIXME a déplacer dans layout */ - -#sidebar ul { - padding: 0 8px; - - li { - margin: 4px 0; - } -} - -#sidebar ul.selection li { - a { - padding-left: 20px; - } - a.current { - text-decoration: none; - color: black !important; - background: url(image-path('user_interface/ui/accept.png')) no-repeat; - } - a.all { - background-image: none; - } -} - - diff --git a/app/assets/stylesheets/stop_areas.css.scss b/app/assets/stylesheets/stop_areas.css.scss new file mode 100644 index 000000000..046066b9f --- /dev/null +++ b/app/assets/stylesheets/stop_areas.css.scss @@ -0,0 +1,119 @@ +// 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/ +@mixin div_for_object { + margin-bottom: 20px; + + .color { + width: 64px; + height: 64px; + float: left; + margin-right: 10px; + } + + img { + float: left; + margin-right: 10px; + } + + img.preview { + width: 90px; + height: 70px; + } + + a { + display:block; + text-decoration: underline; + margin: 5px 0px 0px 0px; + } + + .info { + font-size: 10px; + color: #777; + font-weight: normal; + line-height: 14px; + margin-top: 5px; + + a { + display:inline; + color: #777; + } + + .line{ + border: 1px solid #999; + padding: 2px; + } + + .actions { + margin-top: 14px; + a { + color: #666; + padding-left: 12px; + } + + a.edit { + background: url(image-path('user_interface/ui/edit-small.png')) no-repeat 0% 50%; + } + a.remove { + background: url(image-path('user_interface/ui/remove-small.png')) no-repeat 0% 50%; + } + } + + p { + margin:0; + } + } +} + +@mixin content_to_clear { + content: " "; + display: block; + height: 0; + clear: both; + visibility: hidden; +} + +@mixin after_div_for_object { + @include content_to_clear; +} + +#workspace.stop_areas.index +{ + .stop_area:after { + @include after_div_for_object; + } + + .stop_areas { + margin-top: 20px; + } + + .stop_areas:after { + @include content_to_clear; + } + + .stop_area { + @include div_for_object; + /* to create multi-column index */ + width: 350px; + float: left; + padding-right: 10px; + + } +} + + +#workspace .order { + float: right; + padding: 15px 0; + font-size: 0.8em; + + a { text-decoration: underline; } + + a.current { + font-weight: bold; + text-decoration: none; + } +} + + + diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index c9cd99327..925fae86b 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -1,6 +1,5 @@ class LinesController < ChouetteController defaults :resource_class => Chouette::Line - helper_method :sort_column, :sort_direction respond_to :html respond_to :xml respond_to :json @@ -17,14 +16,6 @@ class LinesController < ChouetteController @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page], :per_page => 10).includes([:network, :company]) end - def sort_column - %w(name number).include?(params[:sort]) ? params[:sort] : "name" - end - - def sort_direction - %w(asc desc).include?(params[:direction]) ? params[:direction] : "asc" - end - def resource_url(line = nil) referential_line_path(referential, line || resource) end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 5e4b9b024..8bd2c29a4 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -2,7 +2,7 @@ class StopAreasController < ChouetteController defaults :resource_class => Chouette::StopArea # belongs_to :network, :parent_class => Potimart::Network do - belongs_to :line, :parent_class => Chouette::Line#, :optional => true + belongs_to :line, :parent_class => Chouette::Line, :optional => true # end respond_to :html, :kml @@ -38,11 +38,12 @@ class StopAreasController < ChouetteController # end def line - @line ||= Chouette::Line.find(params[:line_id]) + @line ||= Chouette::Line.find(params[:line_id]) if params[:line_id] end def collection - @stop_areas ||= line.stop_areas + @q = line ? line.stop_areas.search(params[:q]) : referential.stop_areas.search(params[:q]) + @stop_areas ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page], :per_page => 10) end end diff --git a/app/models/referential.rb b/app/models/referential.rb index d0fdbd676..919c92a2d 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -17,6 +17,10 @@ class Referential < ActiveRecord::Base Chouette::Company.scoped end + def stop_areas + Chouette::StopArea.scoped + end + def switch raise "Referential not created" if new_record? Apartment::Database.switch(slug) diff --git a/app/views/companies/index.html.erb b/app/views/companies/index.html.erb index 6b047b0ce..b6ed91aff 100644 --- a/app/views/companies/index.html.erb +++ b/app/views/companies/index.html.erb @@ -8,7 +8,7 @@ <%= link_to t("cancel"), referential_companies_path(@referential) %> <% end %> -<%#= will_paginate @companies %> +<%= will_paginate @companies %> <div class="companies paginated_content"> <%= render :partial => "company", :collection => @companies %> </div> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 79f5d0b77..e1d3be438 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -36,6 +36,7 @@ <li><%= tab_link_to Chouette::Line, referential_lines_path(@referential) %></li> <li><%= tab_link_to Chouette::Network, referential_networks_path(@referential) %></li> <li><%= tab_link_to t('activerecord.models.company'), referential_companies_path(@referential) %></li> + <li><%= tab_link_to Chouette::StopArea, referential_stop_areas_path(@referential) %></li> <% end %> </ul> </div> diff --git a/app/views/lines/index.html.erb b/app/views/lines/index.html.erb index bd206ea4f..70d6daa6e 100644 --- a/app/views/lines/index.html.erb +++ b/app/views/lines/index.html.erb @@ -23,7 +23,7 @@ </p> <% end %> -<%#= will_paginate @lines %> +<%= will_paginate @lines %> <div class="lines paginated_content"> <%= render :partial => "line", :collection => @lines %> </div> diff --git a/app/views/networks/index.html.erb b/app/views/networks/index.html.erb index 96e4f8b0b..4514939f1 100644 --- a/app/views/networks/index.html.erb +++ b/app/views/networks/index.html.erb @@ -8,7 +8,7 @@ <%= link_to t("cancel"), referential_networks_path(@referential) %> <% end %> -<%#= will_paginate @networks %> +<%= will_paginate @networks %> <div class="networks paginated_content"> <%= render :partial => "network", :collection => @networks %> </div> diff --git a/app/views/stop_areas/_form.html.erb b/app/views/stop_areas/_form.html.erb new file mode 100644 index 000000000..926f4fb55 --- /dev/null +++ b/app/views/stop_areas/_form.html.erb @@ -0,0 +1,21 @@ +<%= semantic_form_for [@referential, @stop_area] do |form| %> + <%= form.inputs do %> + <%= form.input :name %> + <% if @stop_area.new_record? %> + <%= form.input :objectid %> + <% else %> + <li> + <label><%= @stop_area.human_attribute_name("objectid") %>: </label> + <%= @stop_area.objectid %> + </li> + <% end %> + <%= form.input :registration_number %> + <%= form.input :type, :as => :select, :collection => Chouette::StopArea.types, :include_blank => false, :member_label => Proc.new { |mode| t("area_types.label.#{mode}") } %> + <%= form.input :comment %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button %> + ou <%= link_to "revenir", [@referential, @stop_area] %> + <% end %> +<% end %> diff --git a/app/views/stop_areas/_stop_area.html.erb b/app/views/stop_areas/_stop_area.html.erb new file mode 100644 index 000000000..a0b681d48 --- /dev/null +++ b/app/views/stop_areas/_stop_area.html.erb @@ -0,0 +1,22 @@ +<%= div_for(stop_area) do %> + <%= link_to stop_area.name, [@referential, stop_area] %> + <div class="info"> + <p> + <% unless stop_area.geometry %> + <span class="warning"><%= t('.no_position') %></span> - + <% end %> + </p> + <p> + <%= stop_area.street_name %> <%= stop_area.country_code %> + </p> + <p> + <%= t('.lines') %> <% stop_area.lines.each do |line| %> + <span class="line"><%= line.number %></span> + <% end %> + </p> + <div class="actions"> + <%= link_to t("actions.edit"), edit_referential_stop_area_path(@referential, stop_area), :class => "edit" %> | + <%= link_to t("actions.destroy"), referential_stop_area_path(@referential, stop_area), :method => :delete, :confirm => t('networks.actions.destroy_confirm'), :class => "remove" %> + </div> + </div> +<% end %> diff --git a/app/views/stop_areas/edit.html.erb b/app/views/stop_areas/edit.html.erb new file mode 100644 index 000000000..10d937050 --- /dev/null +++ b/app/views/stop_areas/edit.html.erb @@ -0,0 +1,3 @@ +<%= title_tag t('stop_areas.edit.title', :stop_area => @stop_area.name ) %> + +<%= render "form" %> diff --git a/app/views/stop_areas/index.html.erb b/app/views/stop_areas/index.html.erb new file mode 100644 index 000000000..66de0e8ac --- /dev/null +++ b/app/views/stop_areas/index.html.erb @@ -0,0 +1,21 @@ +<%= title_tag t('stop_areas.index.title') %> + +<%= search_form_for @q, :url => referential_stop_areas_path(@referential), :html => {:method => :get} do |f| %> + <%= f.label :name_or_country_code_cont, "#{t('.name_or_country_code')} :" %> + <%= f.text_field :name_or_countrycode_cont %> + + <%= f.submit t('actions.search') %> <%= t("or") %> + <%= link_to t("cancel"), referential_stop_areas_path(@referential) %> +<% end %> + +<%= will_paginate @stop_areas %> +<div class="stop_areas paginated_content"> + <%= render :partial => "stop_area", :collection => @stop_areas %> +</div> +<%= will_paginate @stop_areas %> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li> +</ul> +<% end %> diff --git a/app/views/stop_areas/new.html.erb b/app/views/stop_areas/new.html.erb new file mode 100644 index 000000000..aed167a84 --- /dev/null +++ b/app/views/stop_areas/new.html.erb @@ -0,0 +1,3 @@ +<%= title_tag t('stop_area.new.title') %> + +<%= render "form" %> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb new file mode 100644 index 000000000..8868011d3 --- /dev/null +++ b/app/views/stop_areas/show.html.erb @@ -0,0 +1,43 @@ +<%= title_tag t('stop_areas.show.title', :stop_area => @stop_area.name ) %> + +<div class="stop_area_show"> + + <div class="summary"> + <p> + <label><%= @stop_area.human_attribute_name("name") %>: </label> + <%= @stop_area.name %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("objectid") %>: </label> + <%= @stop_area.objectid %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("registration_number") %>: </label> + <%= @stop_area.registration_number %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("type") %>: </label> + <%= t("area_types.label.#{@stop_area.type}") %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("comment") %>: </label> + <%= @stop_area.comment %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("creation_time") %>: </label> + <%= @stop_area.creation_time %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("creator_id") %>: </label> + <%= @stop_area.creator_id %> + </p> + </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> + <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> + <br> +</ul> +<% end %> diff --git a/config/initializers/ninoxe.rb b/config/initializers/ninoxe.rb index c9b6085a1..4003e2a15 100644 --- a/config/initializers/ninoxe.rb +++ b/config/initializers/ninoxe.rb @@ -23,3 +23,11 @@ class Chouette::Company end end + +class Chouette::StopArea + + def self.model_name + ActiveModel::Name.new Chouette::StopArea, Chouette, "StopArea" + end + +end diff --git a/config/locales/area_types.yml b/config/locales/area_types.yml new file mode 100644 index 000000000..ecaf45d78 --- /dev/null +++ b/config/locales/area_types.yml @@ -0,0 +1,17 @@ +en: + area_types: + label: + boarding_position: Boarding Position + quay: Quay + commercial_stop_point: Commercial Stop Point + stop_place: Stop Place + itl: Restriction Constraint + +fr: + area_types: + label: + boarding_position: "Point d'embarquement" + quay: Quai + commercial_stop_point: Arrêt commercial + stop_place: "Pôle d'échange" + itl: ITL diff --git a/config/locales/stop_areas.yml b/config/locales/stop_areas.yml new file mode 100644 index 000000000..65e5603c9 --- /dev/null +++ b/config/locales/stop_areas.yml @@ -0,0 +1,86 @@ +en: + stop_areas: + stop_area: + no_position: No Position + lines: "Lines :" + actions: + new: Add a new stop + edit: Edit this stop + destroy: Remove this stop + destroy_confirm: Are you sure you want destroy this stop? + new: + title: Add a new stop + edit: + title: Update stop %{stop_area} + show: + title: Stop %{stop_area} + index: + title: Stop areas + name_or_country_code: Name or Country code + selection: Selection + selection_all: All + activerecord: + models: + stop_area: Stop area + attributes: + stop_area: + 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_areas: + stop_area: + no_position: Pas de position + lines: "Lignes :" + actions: + new: Ajouter une zone + edit: Modifier cette zone + destroy: Supprimer cette zone + destroy_confirm: Etes vous sûr de détruire cette zone ? + new: + title: Ajouter une zone + edit: + title: "Modifier la zone %{stop_area}" + show: + title: Zone %{stop_area} + index: + name_or_country_code: Nom ou Code Postal + title: Zones + selection: Sélection + selection_all: Tous + activerecord: + models: + stop_area: Zone + attributes: + stop_area: + name: Nom + registration_number: "Numéro d'enregistrement" + published_name: Nom public + comment: Commentaire + area_type: "Type de zone" + 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/locales/stop_points.yml b/config/locales/stop_points.yml new file mode 100644 index 000000000..d26b88428 --- /dev/null +++ b/config/locales/stop_points.yml @@ -0,0 +1,80 @@ +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? + new: + title: Add a new stop + edit: + title: Update stop %{stop_point} + show: + title: Stop %{stop_point} + index: + title: Stop areas + name: Name + selection: Selection + selection_all: All + activerecord: + models: + stop_point: Stop area + 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 ? + new: + title: Ajouter un arrêt + edit: + title: "Modifier l'arrêt %{stop_point}" + show: + title: Arrêt %{stop_point} + index: + name: Nom + title: Arrêts + selection: Sélection + selection_all: Tous + activerecord: + models: + stop_point: Arrêt + 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 6af3900f4..ec89711f8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,9 +16,8 @@ ChouetteIhm::Application.routes.draw do resources :lines do resources :stop_areas end - resources :networks, :companies + resources :networks, :companies, :stop_areas - end # Sample resource route with options: |
