diff options
| -rw-r--r-- | app/helpers/stop_areas_helper.rb | 35 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.slim | 259 | ||||
| -rw-r--r-- | spec/views/stop_areas/show.html.erb_spec.rb | 8 | 
3 files changed, 118 insertions, 184 deletions
| diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb index db8d40920..65e82e6f0 100644 --- a/app/helpers/stop_areas_helper.rb +++ b/app/helpers/stop_areas_helper.rb @@ -1,24 +1,24 @@  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 -     +      ( "<img src='#{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'     +    return t("stop_areas.genealogical.genealogical_routing") if @stop_area.stop_area_type == 'itl'      t("stop_areas.genealogical.genealogical")    end -  +    def show_map?      manage_itl || @stop_area.long_lat_type != nil -  end   +  end    def manage_access_points      @stop_area.stop_area_type == 'stop_place' || @stop_area.stop_area_type == 'commercial_stop_point' @@ -32,7 +32,7 @@ module StopAreasHelper    def manage_children      @stop_area.stop_area_type == 'stop_place' || @stop_area.stop_area_type == 'commercial_stop_point'    end -   +    def access_links_pairs(access_links)      hpairs = Hash.new      pairs = Array.new @@ -54,10 +54,27 @@ module StopAreasHelper      end      pairs    end -   +    def pair_key(access_link)      "#{access_link.access_point.id}-#{access_link.stop_area.id}"    end +  def geo_data(sa, sar) +    if sa.long_lat_type.nil? +      content_tag :span, I18n.t('stop_areas.show.no_geographic_data') +    else +      if !sa.projection.nil? +        p = content_tag :span, "#{sa.human_attribute_name(:projection)} : #{sar.projection_type_label}" +        px = content_tag :span, "#{sa.human_attribute_name(:projection_x)} : #{sa.projection_x}" +        py = content_tag :span, "#{sa.human_attribute_name(:projection_y)} : #{sa.projection_y}" + +      elsif !sa.long_lat_type.nil? +        lonlat = content_tag :span, "#{sa.human_attribute_name(:long_lat_type)} : #{sa.long_lat_type}" +        lon = content_tag :span, "#{sa.human_attribute_name(:longitude)} : #{sa.longitude}" +        lat = content_tag :span, "#{sa.human_attribute_name(:latitude)} : #{sa.latitude}" +      end +    end +  end +  end diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index 50e535cb5..10cfe836c 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -1,171 +1,88 @@ -= title_tag t('stop_areas.show.title', stop_area: @stop_area.name) - -.stop_area_show -  = @map.to_html if show_map? - -  .summary -    - if @stop_area.deleted_at -      p -        label = @stop_area.human_attribute_name('deleted') -    p -      label = "#{@stop_area.human_attribute_name('comment')} : " -      = @stop_area.comment - -    p -      label = "#{@stop_area.human_attribute_name('nearest_topic_name')} : " -      = @stop_area.nearest_topic_name - -    p -      label = "#{@stop_area.human_attribute_name('street_name')} : " -      = @stop_area.street_name - -    p -      label = "#{@stop_area.human_attribute_name('country_code')} : " -      = @stop_area.country_code - -    p -      label = "#{@stop_area.human_attribute_name('zip_code')} : " -      = @stop_area.zip_code - -    p -      label = "#{@stop_area.human_attribute_name('city_name')} : " -      = @stop_area.city_name - -    p -      label = "#{@stop_area.human_attribute_name('fare_code')} : " -      = @stop_area.fare_code - -    p -      label = "#{@stop_area.human_attribute_name('time_zone')} : " -      = @stop_area.time_zone - -    p -      label = "#{@stop_area.human_attribute_name('url')} : " -      = @stop_area.url - -    p -      label = "#{@stop_area.human_attribute_name('registration_number')} : " -      = @stop_area.registration_number - -    p -      label = "#{@stop_area.human_attribute_name('stop_area_type')} : " -      = t("area_types.label.#{@stop_area.stop_area_type}") -      i.fa.fa-info-circle data-toggle="tooltip" data-placement="right" title="#{t('.not_editable')}" - -    - if !manage_itl -      p -        label = "#{@stop_area.human_attribute_name('mobility_restricted_suitability')} : " -        - if !@stop_area.mobility_restricted_suitability.nil? -          = t((@stop_area.mobility_restricted_suitability == true).to_s) -        - else -          = t("unknown") - -      p -        label = "#{@stop_area.human_attribute_name('stairs_availability')} : " -        - if !@stop_area.stairs_availability.nil? -          = t((@stop_area.stairs_availability == true).to_s) -        - else -          = t("unknown") - -      p -        label = "#{@stop_area.human_attribute_name('lift_availability')} : " -        - if !@stop_area.lift_availability.nil? -          = t((@stop_area.lift_availability == true).to_s) -        - else -          = t("unknown") - -      p -        label = t('stop_areas.show.geographic_data') - -      - if @stop_area.long_lat_type == nil -        span.geo_data = t('stop_areas.show.no_geographic_data') -      - else -        - if !@stop_area.projection.nil? -          p -            span.geo_data = "#{@stop_area.human_attribute_name('projection')} : " -            = @stop_area_referential.projection_type_label - -          p -            span.geo_data = "#{@stop_area.human_attribute_name('projection_x')} : " -            = @stop_area.projection_x - -          p -            span.geo_data = "#{@stop_area.human_attribute_name('projection_y')} : " -            = @stop_area.projection_y - -        - if !@stop_area.long_lat_type.nil? -          p -            span.geo_data = "#{@stop_area.human_attribute_name('long_lat_type')} : " -            = @stop_area.long_lat_type - -          p -            span.geo_data = "#{@stop_area.human_attribute_name('longitude')} : " -            = @stop_area.longitude - -          p -            span.geo_data = "#{@stop_area.human_attribute_name('latitude')} : " -            = @stop_area.latitude - -p.after_map - -.genealogical.clearfix -  == render 'stop_areas/genealogical' - -- if manage_access_points -  div -    h3 = t('.access_points') - -    .access_points.paginated_content -      = paginated_content @access_points, "access_points/access_point", {referential: @stop_area_referential} - -- content_for :sidebar do -  table -    tr -      td -        ul.actions -          - if policy(Chouette::StopArea).new? -            li = link_to t('stop_areas.actions.new'), new_stop_area_referential_stop_area_path(@stop_area_referential), class: 'add' -          - if policy(@stop_area).update? -            li = link_to t('stop_areas.actions.edit'), edit_stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), class: 'edit' -          - if policy(@stop_area).destroy? -            li = link_to t('stop_areas.actions.destroy'), stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), method: :delete, :data => {:confirm =>  t('stop_areas.actions.destroy_confirm')}, class: 'remove' - -    - if manage_itl #Fixme - -      / tr -      /   td -      /     h4 = t(".itl_managment") -      /     ul.actions -      /       li = link_to t('stop_areas.actions.add_routing_lines'), add_routing_lines_stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), class: 'add_routing_lines' -      /       li = link_to t('stop_areas.actions.add_routing_stops'), add_routing_stops_stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), class: 'add_routing_stops' - -    - else -      tr -        td -          h4 = t(".stop_managment") -          ul.actions -            li -              / = link_to t('stop_areas.actions.select_parent'), select_parent_referential_stop_area_path(@referential, @stop_area), :class => "parent" -            - 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" - -            - if manage_children -              li -                / = link_to t('stop_areas.actions.add_children'), add_children_referential_stop_area_path(@referential, @stop_area), :class => "children" -              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" - -      - if manage_access_points -        tr -          td -            h4 = t(".access_managment") -            ul.actions -              li -                / = link_to t('access_points.actions.new'), new_referential_stop_area_access_point_path(@referential,@stop_area), :class => "add" -              li -                / = link_to t('stop_areas.actions.manage_access_links'), access_links_referential_stop_area_path(@referential,@stop_area), :class => "access_link" - -  br - -  = creation_tag(@stop_area) +/ PageHeader += pageheader 'map-marker', +             @stop_area.name, +             'Lorem ipsum dolor sit amet' + +  .row +    .col-lg-12.text-right.mb-sm +      - if policy(Chouette::StopArea).new? +        = link_to t('stop_areas.actions.new'), new_stop_area_referential_stop_area_path(@stop_area_referential), class: 'btn btn-primary' +      - if policy(@stop_area).update? +        = link_to t('stop_areas.actions.edit'), edit_stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), class: 'btn btn-primary' +      - if policy(@stop_area).destroy? +        = link_to stop_area_referential_stop_area_path(@stop_area_referential, @stop_area), method: :delete, data: {confirm: t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-primary' do +          span.fa.fa-trash +          span = t('stop_areas.actions.destroy') + +/ PageContent +.page_content +  .container-fluid +    .row +      .col-lg-6.col-md-6.col-sm-12.col-xs-12 +        = definition_list t('metadatas'), +          { 'Supprimé' => (@stop_area.deleted_at ? t('true') : t('false')), +            @stop_area.human_attribute_name(:comment) => @stop_area.comment, +            @stop_area.human_attribute_name(:nearest_topic_name) => @stop_area.nearest_topic_name, +            @stop_area.human_attribute_name(:street_name) => @stop_area.street_name, +            @stop_area.human_attribute_name(:country_code) => @stop_area.country_code, +            @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, +            @stop_area.human_attribute_name(:city_name) => @stop_area.city_name, +            @stop_area.human_attribute_name(:fare_code) => @stop_area.fare_code, +            @stop_area.human_attribute_name(:time_zone) => @stop_area.time_zone, +            @stop_area.human_attribute_name(:url) => @stop_area.url, +            @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number, +            @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}") } + +      - if !manage_itl +        .col-lg-6.col-md-6.col-sm-12.col-xs-12 +          = definition_list t('metadatas'), +            { @stop_area.human_attribute_name(:mobility_restricted_suitability) => (@stop_area.mobility_restricted_suitability.nil? ? t('unknown') : t((@stop_area.mobility_restricted_suitability == true).to_s)), +              @stop_area.human_attribute_name(:stairs_availability) => (@stop_area.stairs_availability.nil? ? t('unknown') : t((@stop_area.stairs_availability == true).to_s)), +              @stop_area.human_attribute_name(:lift_availability) => (@stop_area.lift_availability.nil? ? t('unknown') : t((@stop_area.lift_availability == true).to_s)), +              t('stop_areas.show.geographic_data') => geo_data(@stop_area, @stop_area_referential)} + +          / - if !manage_itl +          /   p +          /     label = t('stop_areas.show.geographic_data') +          /  +          /   - if @stop_area.long_lat_type == nil +          /     span.geo_data = t('stop_areas.show.no_geographic_data') +          /   - else +          /     - if !@stop_area.projection.nil? +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('projection')} : " +          /         = @stop_area_referential.projection_type_label +          /  +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('projection_x')} : " +          /         = @stop_area.projection_x +          /  +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('projection_y')} : " +          /         = @stop_area.projection_y +          /  +          /     - if !@stop_area.long_lat_type.nil? +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('long_lat_type')} : " +          /         = @stop_area.long_lat_type +          /  +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('longitude')} : " +          /         = @stop_area.longitude +          /  +          /       p +          /         span.geo_data = "#{@stop_area.human_attribute_name('latitude')} : " +          /         = @stop_area.latitude + +    .row +      .col-lg-12 +        .genealogical.clearfix +          == render 'stop_areas/genealogical' + +    - if manage_access_points +      .row +        .col-lg-12 +          h3 = t('.access_points') + +          .access_points.paginated_content +            = paginated_content @access_points, "access_points/access_point", {referential: @stop_area_referential} diff --git a/spec/views/stop_areas/show.html.erb_spec.rb b/spec/views/stop_areas/show.html.erb_spec.rb index 76bd02827..0c9c6663b 100644 --- a/spec/views/stop_areas/show.html.erb_spec.rb +++ b/spec/views/stop_areas/show.html.erb_spec.rb @@ -7,9 +7,9 @@ describe "/stop_areas/show", :type => :view do    let!(:access_points) { assign :access_points, [] }    let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) } -  it "should render h2 with the stop_area name" do +  it "should render h1 with the stop_area name" do      render -    expect(rendered).to have_selector("h2", :text => Regexp.new(stop_area.name)) +    expect(rendered).to have_selector("h1", :text => Regexp.new(stop_area.name))    end    # it "should display a map with class 'stop_area'" do @@ -19,12 +19,12 @@ describe "/stop_areas/show", :type => :view do    it "should render a link to edit the stop_area" do      render -    expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']") +    expect(rendered).to have_selector("a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']")    end    it "should render a link to remove the stop_area" do      render -    expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}'][class='remove']") +    expect(rendered).to have_selector("a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']")    end  end | 
