diff options
Diffstat (limited to 'app')
19 files changed, 832 insertions, 7 deletions
diff --git a/app/controllers/referential_stop_areas_controller.rb b/app/controllers/referential_stop_areas_controller.rb new file mode 100644 index 000000000..06305bb1f --- /dev/null +++ b/app/controllers/referential_stop_areas_controller.rb @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +class ReferentialStopAreasController < ChouetteController + defaults :resource_class => Chouette::StopArea, :collection_name => 'stop_areas', :instance_name => 'stop_area' + + belongs_to :referential do + belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true + belongs_to :network, :parent_class => Chouette::Network, :optional => true, :polymorphic => true + belongs_to :connection_link, :parent_class => Chouette::ConnectionLink, :optional => true, :polymorphic => true + end + + respond_to :html, :kml, :xml, :json + respond_to :js, :only => :index + + def select_parent + @stop_area = stop_area + @parent = stop_area.parent + build_breadcrumb :edit + end + + def add_children + @stop_area = stop_area + @children = stop_area.children + build_breadcrumb :edit + end + + def add_routing_lines + @stop_area = stop_area + @lines = stop_area.routing_lines + build_breadcrumb :edit + end + + def add_routing_stops + @stop_area = stop_area + build_breadcrumb :edit + end + + def access_links + @stop_area = stop_area + @generic_access_links = stop_area.generic_access_link_matrix + @detail_access_links = stop_area.detail_access_link_matrix + build_breadcrumb :edit + end + + def index + request.format.kml? ? @per_page = nil : @per_page = 12 + @zip_codes = referential.stop_areas.collect(&:zip_code).compact.uniq + index! do |format| + format.html { + if collection.out_of_bounds? + redirect_to params.merge(:page => 1) + end + build_breadcrumb :index + } + end + end + + def new + @map = StopAreaMap.new( Chouette::StopArea.new).with_helpers(self) + @map.editable = true + new! do + build_breadcrumb :show + end + end + + def create + @map = StopAreaMap.new(Chouette::StopArea.new).with_helpers(self) + @map.editable = true + + create! + end + + def show + map.editable = false + @access_points = @stop_area.access_points + show! do |format| + unless stop_area.position or params[:default] or params[:routing] + format.kml { + render :nothing => true, :status => :not_found + } + + end + build_breadcrumb :show + end + end + + def edit + edit! do + stop_area.position ||= stop_area.default_position + map.editable = true + build_breadcrumb :edit + end + end + + def update + stop_area.position ||= stop_area.default_position + map.editable = true + + update! + end + + def default_geometry + count = referential.stop_areas.without_geometry.default_geometry! + flash[:notice] = I18n.translate("stop_areas.default_geometry_success", :count => count) + redirect_to stop_area_referential_stop_areas_path(@stop_area_referential) + end + + def zip_codes + respond_to do |format| + format.json { render :json => referential.stop_areas.collect(&:zip_code).compact.uniq.to_json } + end + end + + protected + + alias_method :stop_area, :resource + + def map + @map = StopAreaMap.new(stop_area).with_helpers(self) + end + + def collection + @q = parent.present? ? parent.stop_areas.search(params[:q]) : referential.stop_areas.search(params[:q]) + @stop_areas ||= + begin + stop_areas = @q.result(:distinct => true).order(:name) + stop_areas = stop_areas.paginate(:page => params[:page], :per_page => @per_page) if @per_page.present? + stop_areas + end + end + + private + + def stop_area_params + params.require(:stop_area).permit( :routing_stop_ids, :routing_line_ids, :children_ids, :stop_area_type, :parent_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :area_type, :registration_number, :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :zip_code, :city_name, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs, :coordinates, :url, :time_zone ) + end + +end diff --git a/app/models/referential.rb b/app/models/referential.rb index 55e7eff79..53286d61d 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -29,6 +29,10 @@ class Referential < ActiveRecord::Base # validates_presence_of :line_referential has_many :lines, through: :line_referential + belongs_to :stop_area_referential + # validates_presence_of :stop_area_referential + has_many :stop_areas, through: :stop_area_referential + def slug_excluded_values if ! slug.nil? if slug.start_with? "pg_" diff --git a/app/views/access_points/_access_point.html.erb b/app/views/access_points/_access_point.html.erb index 76cf16fd7..714e7dc12 100644 --- a/app/views/access_points/_access_point.html.erb +++ b/app/views/access_points/_access_point.html.erb @@ -2,20 +2,19 @@ <div class="panel-heading"> <div class="panel-title clearfix"> <span class="pull-right"> - <!-- FIXME #821 --> - <%#= link_to edit_referential_stop_area_access_point_path(@referential, @stop_area, access_point), :class => "btn btn-default btn-sm" do %> + <%= link_to edit_referential_stop_area_access_point_path(@referential, @stop_area, access_point), :class => "btn btn-default btn-sm" do %> <span class="fa fa-pencil"></span> - <%# end %> - <%#= link_to referential_stop_area_access_point_path(@referential, @stop_area, access_point), :method => :delete, :data => {:confirm => t('access_points.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %> + <% end %> + <%= link_to referential_stop_area_access_point_path(@referential, @stop_area, access_point), :method => :delete, :data => {:confirm => t('access_points.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %> <span class="fa fa-trash-o"></span> - <%# end %> + <% end %> </span> <h5> - <%#= link_to([@referential, @stop_area, access_point], :class => "preview", :title => "#{Chouette::StopArea.model_name.human.capitalize} #{access_point.name}") do %> + <%= link_to([@referential, @stop_area, access_point], :class => "preview", :title => "#{Chouette::StopArea.model_name.human.capitalize} #{access_point.name}") do %> <span class="name"> <%= image_tag "map/access_" + access_point.access_point_type + ".png" %> <%= truncate(access_point.name, :length => 20) %> </span> - <%# end %> + <% end %> </h5> </div> </div> diff --git a/app/views/referential_stop_areas/_form.html.erb b/app/views/referential_stop_areas/_form.html.erb new file mode 100644 index 000000000..d4fcf25e3 --- /dev/null +++ b/app/views/referential_stop_areas/_form.html.erb @@ -0,0 +1,160 @@ +<%= semantic_form_for [@referential, @stop_area] do |form| %> + <div class="row"> + <div class="container-fluid"> + <% if !manage_itl && @map %> + <%= @map.to_html %> + <% end %> + <%= form.inputs do %> + <%= form.input :id, :as => :hidden %> + <%= form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} %> + <%= form.input :stop_area_type, :as => :select, :input_html => { :disabled => !@stop_area.new_record? }, :collection => Chouette::StopArea.stop_area_types, :include_blank => false, :member_label => Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } %> + <div class="location_info"> + <h3><%= t("stop_areas.stop_area.localisation") %></h3> + <div id="prefetch"> + <label><%= t('.geolocalize') %></label> + <input class="typeahead form-control input-lg" maxlength="255" type="text" placeholder="<%= t('.address') %>" /> + </div> + <% unless @stop_area.projection.blank? or @stop_area.projection_type_label.empty? %> + <%= form.input :projection_xy, :label => t("projection_xy", :projection => @referential.projection_type_label), :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.projection_xy")} %> + <% end %> + <%= form.input :coordinates, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")} %> + <%= form.input :street_name %> + <%= form.input :country_code, required: format_restriction_for_locales(@referential) == '.hub' %> + <%= form.input :zip_code, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} %> + <%= form.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")} %> + </div> + <% end %> + </div> + </div> + <div class="stop_areas.stop_area.general_info"> + <h3><%= t("stop_area.general") %></h3> + <%= form.inputs do %> + <%= form.input :objectid, :required => !@stop_area.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.objectid")} %> + <%= form.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} %> + <%= form.input :fare_code, :as => :number %> + <%= form.input :nearest_topic_name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} %> + <%= form.input :comment, :as => :text, :input_html => { :rows => 5, :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.comment") } %> + <%= form.input :time_zone, :include_blank => true %> + <%= form.input :url %> + <% end %> + </div> + <div class="pmr_info"> + <h3><%= t("stop_areas.stop_area.accessibility") %></h3> + <%= form.inputs do %> + <% if !manage_itl %> + <%= form.input :mobility_restricted_suitability, :as => :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true %> + <%= form.input :stairs_availability, :as => :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true %> + <%= form.input :lift_availability, :as => :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true %> + <% end %> + <% end %> + </div> + + <%= form.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% end %> +<% end %> + +<script> + $(document).ready(function() { + var address_display = function( address ) { + var name = ""; + if ( address.house_number) { + name += address.house_number+" "; + } + name += address.road+", "; + if ( address.suburb) { + name += address.suburb+", "; + } + if ( address.postcode) { + name += address.postcode+" "; + } + if ( address.city) { + name += address.city; + } else if ( address.village) { + name += address.village; + } else if ( address.town) { + name += address.town; + } else if ( address.county ) { + name += address.county; + } else if ( address.country ) { + name += address.country; + } + + + return name; + }; + var filtering = function(list) { + // update map view + removeAddress(); + + var selection = $.grep( list, function(item) { + return (item.type == "house" || item.type == "residential" || + item.type == "tertiary" || item.type == "primary" || + item.type == "secondary") && item.address.road ; + }); + return $.map( selection, function( d) { + var city = ""; + if ( d.address.city) { + city = d.address.city; + } else if ( d.address.town) { + city = d.address.town; + } else if ( d.address.village) { + city = d.address.village; + } + return { postcode: d.address.postcode, + road: d.address.road, + lon: d.lon, lat: d.lat, + suburb: d.address.suburb, + city: city, + postcode: d.address.postcode, + the_key: address_display( d.address)}; + }); + }; + + var addressesEngine = new Bloodhound({ + datumTokenizer: function(d) { + return Bloodhound.tokenizers.whitespace(d.id+" : "+d.road); + }, + queryTokenizer: function(d) { + return Bloodhound.tokenizers.whitespace(d.id+" :: "+d.road); + }, + limit: 10, + remote: { + url: 'http://nominatim.openstreetmap.org/search?q=%QUERY&format=json&addressdetails=1&bounded=1&viewbox='+ + // FIXME #821 + '<%#= @referential.viewbox_left_top_right_bottom %>', + filter: filtering, + } + }); + + // kicks off the loading/processing of `local` and `prefetch` + var promise = addressesEngine.initialize(); + + // passing in `null` for the `options` arguments will result in the default + // options being used + $('#prefetch .typeahead').typeahead( + { + hint: true, + highlight: true, + minLength: 1 + }, + { + name: 'addresses', + displayKey: 'the_key', + source: addressesEngine.ttAdapter(), + } + ); + + $('.typeahead').on('typeahead:selected', function($e, datum) { + // update map view + addAddress( datum.lon, datum.lat, datum.road); + // update form fields + <% if @stop_area.new_record? %> + $('input[name="stop_area[street_name]"]').val(datum.road); + $('input[name="stop_area[zip_code]"]').val(datum.postcode); + $('input[name="stop_area[city_name]"]').val(datum.city); + <% end %> + }) + }); +</script> diff --git a/app/views/referential_stop_areas/_genealogical.html.erb b/app/views/referential_stop_areas/_genealogical.html.erb new file mode 100644 index 000000000..a76b972e2 --- /dev/null +++ b/app/views/referential_stop_areas/_genealogical.html.erb @@ -0,0 +1,66 @@ + <h3><%= genealogical_title %></h3> + + <% if @stop_area.parent.present? %> + <div class="parent"> + <%= link_to([@referential, @stop_area.parent], :title => t("area_types.label.#{ @stop_area.parent.stop_area_type}") + " #{ @stop_area.parent.name}") do %> + <%= image_tag "map/" + @stop_area.parent.stop_area_type + ".png" %><span><%= @stop_area.parent.name %></span> + <% end %> + </div> + <div class="link"><%= image_tag "icons/link.png"%></div> + <% elsif @stop_area.routing_lines.present? %> + <div class="lines"> + <% @stop_area.routing_lines.each do |line| %> + <div class="line"> + <%= link_to([@referential, line]) do %> + <span><%= line.name %></span> + <% end %> + </div> + <% end %> + </div> + <div class="link"><%= image_tag "icons/link.png"%></div> + <% else %> + <div class="no_parent"> </div> + <% end %> + + <div class="target"> + <%= image_tag "map/" + @stop_area.stop_area_type + ".png"%><span><%= @stop_area.name %></span> + </div> + + <% 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], :title => t("area_types.label.#{ child.stop_area_type}") + " #{ child.name}") do %> + <%= image_tag "map/" + child.stop_area_type + ".png" %><span><%= child.name %></span> + <% end %> + </div> + <% end %> + </div> + <% elsif @stop_area.routing_stops.present? %> + <div class="link"><%= image_tag "icons/link.png"%></div> + <div class="children"> + <% @stop_area.routing_stops.each do |stop| %> + <div class="child"> + <%= link_to([@referential, stop], :title => t("area_types.label.#{ stop.stop_area_type}") + " #{ stop.name}") do %> + <%= image_tag "map/" + stop.stop_area_type + ".png" %><span><%= "#{stop.name} #{' [' + stop.registration_number + ']' if stop.registration_number.present? }" %></span> + <% end %> + </div> + <% end %> + </div> + <% elsif @stop_area.routes.present? %> + <div class="link"><%= image_tag "icons/link.png"%></div> + <div class="children"> + <% @stop_area.routes.each do |route| %> + <div class="child"> + <%= link_to([@referential, route.line ]) do %> + <span><%= route.line.number %></span> + <% end %> + + <%= link_to([@referential, route.line , route]) do %> + <span><%= route.name %></span> + <% end %> + </div> + <% end %> + </div> + <% end %> diff --git a/app/views/referential_stop_areas/_stop_area.html.erb b/app/views/referential_stop_areas/_stop_area.html.erb new file mode 100644 index 000000000..2d2118aed --- /dev/null +++ b/app/views/referential_stop_areas/_stop_area.html.erb @@ -0,0 +1,53 @@ +<div id="index_item" class="panel panel-default stop_area"> + <div class="panel-heading"> + <div class="panel-title clearfix"> + <span class="pull-right"> + <%= link_to edit_referential_stop_area_path(@referential, stop_area), :class => "btn btn-default btn-sm" do %> + <span class="fa fa-pencil"></span> + <% end %> + <%= link_to referential_stop_area_path(@referential, stop_area), :method => :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %> + <span class="fa fa-trash-o"></span> + <% end %> + </span> + <h5> + <%= link_to([@referential, stop_area], :class => "preview", :title => t("area_types.label.#{stop_area.stop_area_type}") + " #{stop_area.name}") do %> + <span class="name"> + <%= image_tag "map/" + stop_area.stop_area_type + ".png" %> <%= truncate(stop_area.name, :length => 20) %> + </span> + <% end %> + </h5> + </div> + </div> + <div class="panel-body"> + <p> + <% unless stop_area.area_type == 'ITL' || stop_area.geometry %> + <span class="warning"><%= t('.no_position') %></span> + <% end %> + </p> + <p> + <%= stop_area.human_attribute_name('registration_number') %> : <%= stop_area.registration_number.present? ? stop_area.registration_number : t(".no_object") %> + </p> + <p> + <%= t('.address') %> : <%= (stop_area.zip_code.present? || stop_area.city_name.present?) ? "#{stop_area.zip_code} #{stop_area.city_name}" : t(".no_object") %> + </p> + <p> + <% if stop_area.area_type == 'ITL' %> + <%= t('.lines') %> : <% if stop_area.routing_lines.blank? %> + <%= t(".no_object") %> + <% else %> + <% stop_area.routing_lines.each do |line| %> + <span class="label label-default line"><%= line.number %></span> + <% end %> + <% end %> + <% else %> + <%= t('.lines') %> : <% if stop_area.lines.blank? %> + <%= t(".no_object") %> + <% else %> + <% stop_area.lines.each do |line| %> + <span class="label label-default line"><%= line.number || truncate( line.name, :length => 4 ) %></span> + <% end %> + <% end %> + <% end %> + </p> + </div> +</div> diff --git a/app/views/referential_stop_areas/_stop_areas.html.erb b/app/views/referential_stop_areas/_stop_areas.html.erb new file mode 100644 index 000000000..9c7a82d6d --- /dev/null +++ b/app/views/referential_stop_areas/_stop_areas.html.erb @@ -0,0 +1,9 @@ +<div class="page_info"> + <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @stop_areas %> +</div> +<div class="stop_areas paginated_content"> + <%= paginated_content(@stop_areas) %> +</div> +<div class="pagination"> + <%= will_paginate @stop_areas, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer %> +</div> diff --git a/app/views/referential_stop_areas/access_links.html.erb b/app/views/referential_stop_areas/access_links.html.erb new file mode 100644 index 000000000..3cea2fbdd --- /dev/null +++ b/app/views/referential_stop_areas/access_links.html.erb @@ -0,0 +1,46 @@ +<%= title_tag t('stop_areas.access_links.title', :stop_area => @stop_area.name ) %> + +<div class="stop_area_show"> + +<div class="panel-group" id="generic"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <a data-toggle="collapse" data-parent="#generic" href="#generic_access_links"> + <%= t('.generic_access_links') %> + </a> + </h4> + </div> + <div id="generic_access_links" class="panel-collapse collapse in"> + <div class="panel-body"> + <div class="access_link_pairs"> + <table> + <%= render :partial => "access_link_pairs/access_link_pair", :collection => access_links_pairs(@generic_access_links) %> + </table> + </div> + </div> + </div> + </div> +</div> + +<div class="panel-group" id="detail"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <a data-toggle="collapse" data-parent="#detail" href="#detail_access_links"> + <%= t('.detail_access_links') %> + </a> + </h4> + </div> + <div id="detail_access_links" class="panel-collapse collapse"> + <div class="panel-body"> + <div class="access_link_pairs"> + <table> + <%= render :partial => "access_link_pairs/access_link_pair", :collection => access_links_pairs(@detail_access_links) %> + </table> + </div> + </div> + </div> + </div> +</div> + diff --git a/app/views/referential_stop_areas/add_children.html.erb b/app/views/referential_stop_areas/add_children.html.erb new file mode 100644 index 000000000..4d30ba674 --- /dev/null +++ b/app/views/referential_stop_areas/add_children.html.erb @@ -0,0 +1,19 @@ +<%= title_tag t('stop_areas.add_children.title', :stop_area => @stop_area.name ) %> + +<%= semantic_form_for [@referential, @stop_area] do |form| %> +<div> + <%= form.inputs do %> + <%= form.input :children_ids, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?relation=children&target_type=#{@stop_area.area_type}", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', @children, :view_path => 'app/views', :format => :json, :scope => self ).render } %> + <% end %> + + <%= form.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% end %> +</div> +<% end %> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/referential_stop_areas/add_routing_lines.html.erb b/app/views/referential_stop_areas/add_routing_lines.html.erb new file mode 100644 index 000000000..84d03f8b2 --- /dev/null +++ b/app/views/referential_stop_areas/add_routing_lines.html.erb @@ -0,0 +1,32 @@ +<%= 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.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% 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, + hintText: '<%= t('search_hint') %>', + noResultsText: '<%= t('no_result_text') %>', + searchingText: '<%= t('searching_term') %>' + }); + }); +</script> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/referential_stop_areas/add_routing_stops.html.erb b/app/views/referential_stop_areas/add_routing_stops.html.erb new file mode 100644 index 000000000..310e2f8b0 --- /dev/null +++ b/app/views/referential_stop_areas/add_routing_stops.html.erb @@ -0,0 +1,19 @@ +<%= 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 => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=itl_excluded", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', @stop_area.routing_stops, :view_path => 'app/views', :format => :json, :scope => self).render } %> + <% end %> + + <%= form.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% end %> +</div> +<% end %> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/referential_stop_areas/edit.html.erb b/app/views/referential_stop_areas/edit.html.erb new file mode 100644 index 000000000..10d937050 --- /dev/null +++ b/app/views/referential_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/referential_stop_areas/index.html.erb b/app/views/referential_stop_areas/index.html.erb new file mode 100644 index 000000000..17f36d562 --- /dev/null +++ b/app/views/referential_stop_areas/index.html.erb @@ -0,0 +1,38 @@ +<%= title_tag t('stop_areas.index.title') %> + +<div id="country_codes"> + <%= @country_codes.to_json %> +</div> + +<%= search_form_for @q, :url => referential_stop_areas_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> +<div class="panel panel-default"> + <div class="panel-heading"> + <div class="input-group col-md-9"> + <%= f.text_field :name_cont, :placeholder => "#{t('.name')}", :class => 'form-control' %> + <div class="input-group-btn"> + <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button> + </div> + </div><!-- /input-group --> + <a data-toggle="collapse" data-parent="#search" href="#advanced_search"> + <i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %> + </a> + </div> + + <div id="advanced_search" class="panel-collapse collapse"> + <div class="panel-body"> + <%= f.text_field :zip_code_cont, :placeholder => "#{t('.zip_code')}", :class => 'form-control typeahead' %> + <%= f.select(:area_type_cont, options_from_collection_for_select(Chouette::StopArea.stop_area_types, 'name', Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } ), { :include_blank => "#{t('.area_type')}" }, { :class => 'form-control' }) %> + </div> + </div> +</div> +<% end %> + +<div id="stop_areas"><%= render 'stop_areas' %></div> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li> + <li><%#= link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator" %></li> +</ul> + +<% end %> diff --git a/app/views/referential_stop_areas/index.js.erb b/app/views/referential_stop_areas/index.js.erb new file mode 100644 index 000000000..1621823cc --- /dev/null +++ b/app/views/referential_stop_areas/index.js.erb @@ -0,0 +1 @@ +$('#stop_areas').html('<%= escape_javascript(render("stop_areas")) %>');
\ No newline at end of file diff --git a/app/views/referential_stop_areas/index.kml.erb b/app/views/referential_stop_areas/index.kml.erb new file mode 100644 index 000000000..f43f130b6 --- /dev/null +++ b/app/views/referential_stop_areas/index.kml.erb @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <% @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.stop_area_type %></stop_area_type> + <stop_area_type_label><%= t("area_types.label.#{stop_area.stop_area_type}") %></stop_area_type_label> + <%= stop_area.geometry.kml_representation.html_safe %> + </Placemark> + <% end %> + </Document> +</kml> diff --git a/app/views/referential_stop_areas/new.html.erb b/app/views/referential_stop_areas/new.html.erb new file mode 100644 index 000000000..9fcf4390e --- /dev/null +++ b/app/views/referential_stop_areas/new.html.erb @@ -0,0 +1,3 @@ +<%= title_tag t('stop_areas.new.title') %> + +<%= render "form" %> diff --git a/app/views/referential_stop_areas/select_parent.html.erb b/app/views/referential_stop_areas/select_parent.html.erb new file mode 100644 index 000000000..3f550d370 --- /dev/null +++ b/app/views/referential_stop_areas/select_parent.html.erb @@ -0,0 +1,19 @@ +<%= title_tag t('stop_areas.select_parent.title', :stop_area => @stop_area.name ) %> + +<%= semantic_form_for [@referential, @stop_area] do |form| %> +<div> + <%= form.inputs do %> + <%= form.input :parent_id, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?relation=parent&target_type=#{@stop_area.area_type}", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'), :searching_text => t('searching_term'), :tokenLimit => 1, :input_html => { :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', [@parent].compact, :view_path => 'app/views', :format => :json, :scope => self ).render } %> + <% end %> + + <%= form.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% end %> +</div> +<% end %> + +<% content_for :sidebar do %> +<ul class="actions"> +</ul> +<% end %> diff --git a/app/views/referential_stop_areas/show.html.erb b/app/views/referential_stop_areas/show.html.erb new file mode 100644 index 000000000..7083abd10 --- /dev/null +++ b/app/views/referential_stop_areas/show.html.erb @@ -0,0 +1,176 @@ +<%= title_tag t('stop_areas.show.title', :stop_area => @stop_area.name ) %> + +<div class="stop_area_show"> + <% if show_map? %> + <%= @map.to_html %> + <% end %> + <div class="summary"> + <p> + <label><%= @stop_area.human_attribute_name("comment") %>: </label> + <%= @stop_area.comment %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("nearest_topic_name") %>: </label> + <%= @stop_area.nearest_topic_name %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("street_name") %>: </label> + <%= @stop_area.street_name %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("country_code") %>: </label> + <%= @stop_area.country_code %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("zip_code") %>: </label> + <%= @stop_area.zip_code %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("city_name") %>: </label> + <%= @stop_area.city_name %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("fare_code") %>: </label> + <%= @stop_area.fare_code %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("time_zone") %>: </label> + <%= @stop_area.time_zone %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("url") %>: </label> + <%= @stop_area.url %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("registration_number") %>: </label> + <%= @stop_area.registration_number %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("stop_area_type") %>: </label> + <%= t("area_types.label.#{@stop_area.stop_area_type}") %> + <i class="fa fa-info-circle" data-toggle="tooltip" data-placement="right" title="<%= t('.not_editable') %>"></i> + </p> + <% if !manage_itl %> + <p> + <label><%= @stop_area.human_attribute_name("mobility_restricted_suitability") %>: </label> + <% if (!@stop_area.mobility_restricted_suitability.nil?) %> + <%= t((@stop_area.mobility_restricted_suitability == true).to_s) %> + <% else %> + <%=t("unknown") %> + <% end %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("stairs_availability") %>: </label> + <% if (!@stop_area.stairs_availability.nil?) %> + <%= t((@stop_area.stairs_availability == true).to_s) %> + <% else %> + <%=t("unknown") %> + <% end %> + </p> + <p> + <label><%= @stop_area.human_attribute_name("lift_availability") %>: </label> + <% if (!@stop_area.lift_availability.nil?) %> + <%= t((@stop_area.lift_availability == true).to_s) %> + <% else %> + <%=t("unknown") %> + <% end %> + </p> + <p> <label><%= t('stop_areas.show.geographic_data') %> </label></p> + <% if @stop_area.long_lat_type == nil %> + <span class='geo_data'><%= t('stop_areas.show.no_geographic_data') %></span> + <% else %> + <% if !@stop_area.projection.nil? %> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("projection") %>: </span> + <%= @referential.projection_type_label %> + </p> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("projection_x") %>: </span> + <%= @stop_area.projection_x %> + </p> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("projection_y") %>: </span> + <%= @stop_area.projection_y %> + </p> + <% end %> + <% if !@stop_area.long_lat_type.nil? %> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("long_lat_type") %>: </span> + <%= @stop_area.long_lat_type %> + </p> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("longitude") %>: </span> + <%= @stop_area.longitude %> + </p> + <p> + <span class='geo_data'><%= @stop_area.human_attribute_name("latitude") %>: </span> + <%= @stop_area.latitude %> + </p> + <% end %> + <% end %> + <% end %> + </div> +</div> +<p class="after_map" /> + +<div class="genealogical clearfix"> + <%= render "stop_areas/genealogical" %> +</div> + +<% if manage_access_points %> +<div> + <h3><%= t('.access_points') %></h3> + + <div class="access_points paginated_content"> + <%= paginated_content @access_points, "access_points/access_point" %> + </div> +</div> +<% end %> + +<% content_for :sidebar do %> + <table> + <tr><td> + <ul class="actions"> + <li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li> + <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, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, :class => "remove" %></li> + </ul> + </td></tr> + <% if manage_itl %> + <tr><td> + <h4><%= t(".itl_managment") %></h4> + <ul class="actions"> + <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> + <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> + </ul> + </td></tr> + <% else %> + <tr><td> + <h4><%= t(".stop_managment") %></h4> + <ul class="actions"> + <li><%= link_to t('stop_areas.actions.select_parent'), select_parent_referential_stop_area_path(@referential, @stop_area), :class => "parent" %></li> + <% if @stop_area.parent == nil %> + <li><%= link_to t('stop_areas.actions.clone_as_parent'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, :hierarchy => "parent"), :class => "clone" %></li> + <% end %> + <% if manage_children %> + <li><%= link_to t('stop_areas.actions.add_children'), add_children_referential_stop_area_path(@referential, @stop_area), :class => "children" %></li> + <li><%= link_to t('stop_areas.actions.clone_as_child'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, :hierarchy => "child"), :class => "clone" %></li> + <% end %> + </ul> + </td></tr> + + <% if manage_access_points %> + <tr><td> + <h4><%= t(".access_managment") %></h4> + <ul class="actions"> + <li><%= link_to t('access_points.actions.new'), new_referential_stop_area_access_point_path(@referential,@stop_area), :class => "add" %></li> + <li><%= link_to t('stop_areas.actions.manage_access_links'), access_links_referential_stop_area_path(@referential,@stop_area), :class => "access_link" %></li> + </ul> + </td></tr> + <% end %> + + <% end %> + </table> + <br> + <%= creation_tag(@stop_area) %> +<% end %> diff --git a/app/views/referential_stop_areas/show.kml.erb b/app/views/referential_stop_areas/show.kml.erb new file mode 100644 index 000000000..39a764bd6 --- /dev/null +++ b/app/views/referential_stop_areas/show.kml.erb @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <% if !params["children"].nil? %> + <% @stop_area.children.each do |child| %> + <Placemark id="<%= child.id %>" > + <name><%= child.name %></name> + <stop_area_type><%= child.stop_area_type %></stop_area_type> + <%= (child.position or child.default_position).kml_representation.html_safe %> + </Placemark> + <% end %> + <% elsif !params["routing"].nil? %> + <% @stop_area.routing_stops.each do |child| %> + <Placemark id="<%= child.id %>" > + <name><%= child.name %></name> + <stop_area_type><%= child.stop_area_type %></stop_area_type> + <%= (child.position or child.default_position).kml_representation.html_safe %> + </Placemark> + <% end %> + <% else %> + <Placemark id="<%= @stop_area.id %>" > + <name><%= @stop_area.name %></name> + <stop_area_type><%= @stop_area.stop_area_type %></stop_area_type> + <%= (@stop_area.position or @stop_area.default_position).kml_representation.html_safe %> + </Placemark> + <% end %> + </Document> +</kml> |
