af83/chouette-core

View on GitHub
app/views/stop_areas/show.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :stop_area, @workbench, @stop_area
- page_header_content_for @stop_area
- javascript_additional_packs 'stop_areas/show'

/ PageContent
.page_content
  .container-fluid
    .row
      .col-lg-6.col-md-6.col-sm-12.col-xs-12
        = simple_block_for @stop_area, title: t("stop_areas.form.sections.identification") do |d|
          = d.attribute :objectid, as: :objectid
          = d.attribute :name
          - @stop_area.localized_names.keep_if { |key, value| value.present? }.each do |k, v|
            = d.attribute :name, value: v, label: label_for_country(k, Chouette::StopArea.tmf('name'))
          = d.attribute :public_code

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.hierarchy") do |d|
          = d.attribute :area_type, value: "#{Chouette::AreaType.find(@stop_area.area_type).try(:label)} (#{@stop_area.kind})"
          = d.attribute :parent, as: :association, link: ->(parent) { workbench_stop_area_referential_stop_area_path(@workbench, parent) }
          = d.attribute :children, as: :count, value: @stop_area.children, link: workbench_stop_area_referential_stop_areas_path(@workbench, :'search[parent_id]' => @stop_area.id)
        - if @stop_area.children.present?
          table.table.table-bordered
            thead
              tr
                th scope="col"
                  = Chouette::StopArea.tmf('id')
                th scope="col"
                  = Chouette::StopArea.tmf('name')
                th scope="col"
                  = Chouette::StopArea.tmf('distance')
            tbody
              - @stop_area.closest_children.limit(5).each do |c|
                tr
                  td
                    = c.get_objectid.short_id
                  td
                    = link_to(c.name, workbench_stop_area_referential_stop_area_path(@workbench, c))
                  td
                    - if distance = c.try(:distance)
                      = "#{distance.round(2)} m"
          - if @stop_area.children.count > 5
            = link_to t('stop_areas.show.more', count: (@stop_area.children.count - 5)), workbench_stop_area_referential_stop_areas_path(@workbench, :'search[parent_id]' => @stop_area.id), class: 'btn btn-link pull-right'

        = simple_block_for @stop_area, title: Chouette::StopArea.tmf('referent') do |d|
          - if @stop_area.is_referent
            = d.attribute :specific_stops, as: :count, value: @stop_area.specific_stops, link: workbench_stop_area_referential_stop_areas_path(@workbench, :'search[referent_id]' => @stop_area.id)
            - if @stop_area.closest_specific_stops.present?
              table.table.table-bordered
                thead
                  tr
                    th scope="col"
                      = Chouette::StopArea.tmf('id')
                    th scope="col"
                      = Chouette::StopArea.tmf('name')
                    th scope="col"
                      = Chouette::StopArea.tmf('distance')
                tbody
                  - @stop_area.closest_specific_stops.limit(5).each do |c|
                    tr
                      td
                        = c.get_objectid.short_id
                      td
                        = link_to(c.name, workbench_stop_area_referential_stop_area_path(@workbench, c))
                      td
                        - if distance = c.try(:distance)
                          = "#{distance.round(2)} m"
          - else
            = d.attribute :referent, as: :association, link: ->(referent) { workbench_stop_area_referential_stop_area_path(@workbench, referent) }

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.internals") do |d|
          = d.attribute :status, value_method: :human_status
          = d.attribute :stop_area_provider, as: :association, link: workbench_stop_area_referential_stop_area_provider_path(@workbench, @stop_area.stop_area_provider)
          = d.attribute :comment

        = render 'codes/block', model: @stop_area

      .col-lg-6.col-md-6.col-sm-12.col-xs-12
        - if @stop_area.longitude && @stop_area.latitude
          #connection_link_map.medium_map.mb-lg

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.location") do |d|
          = d.attribute :coordinates, value: geo_data(@stop_area, @stop_area_referential)
          = d.attribute :compass_bearing
          = d.attribute :street_name
          = d.attribute :zip_code
          = d.attribute :city_name
          = d.attribute :postal_region
          = d.attribute :country_code, as: :country
          = d.attribute :time_zone

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.usage") do |d|
          = d.attribute :waiting_time, as: :duration, value: @stop_area.waiting_time&.minutes
          = d.attribute :url, link: @stop_area.url
          = d.attribute :transport_mode, value: @stop_area.transport_mode&.human_name

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.fare") do |d|
          = d.attribute :fare_zones, as: :associations, value: @stop_area.fare_zones.sort_by(&:name), link: ->(fare_zone) { workbench_fare_zone_path(@workbench, fare_zone) }

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.accessibility") do |d|
          = d.attribute :mobility_impaired_accessibility, as: :enumerize
          = d.attribute :wheelchair_accessibility, as: :enumerize
          = d.attribute :step_free_accessibility, as: :enumerize
          = d.attribute :escalator_free_accessibility, as: :enumerize
          = d.attribute :lift_free_accessibility, as: :enumerize
          = d.attribute :audible_signals_availability, as: :enumerize
          = d.attribute :visual_signs_availability, as: :enumerize
          = d.attribute :accessibility_limitation_description

        = simple_block_for @stop_area, title: t("stop_areas.form.sections.custom_fields") do |d|
          - if @stop_area.custom_fields.empty?
            .mb-xs
              = replacement_msg t('stop_areas.no_custom_fields')
          - else
            - @stop_area.custom_fields.by_group do |custom_field_group, custom_fields|
              - if custom_field_group
                = content_tag(:div, "", class: "dl-term mb-6") + content_tag(:div, "", class: "dl-def mb-6")
                = content_tag(:div, custom_field_group.name, class: "dl-term") + content_tag(:div, "", class: "dl-def")

              - custom_fields.sort_by(&:position).each do |custom_field|
                = d.attribute :name, value: custom_field.display_value, label: custom_field.name
              end
            end

        - if has_feature?(:stop_area_connection_links)
          h4.underline= t('.connections.title')
          - if @connection_links.any?
            = stop_area_connections(@connection_links, @stop_area, @workbench)
          - unless @connection_links.any?
            .mb-xs
              = replacement_msg t('.connections.no_connection')

          .row
            .col-md-8
              = link_to t('connection_links.actions.new'), new_workbench_stop_area_referential_connection_link_path(@workbench, departure_id: @stop_area.id), class: 'btn btn-action large'
            .col-md-4
              = more_connections_link(@stop_area, @workbench) if @stop_area.connection_links.count > 4

        = render 'shared/documentable/documents', documentable: @stop_area, document_memberships_path: workbench_stop_area_referential_stop_area_document_memberships_path(@workbench, @stop_area)