af83/chouette-core

View on GitHub
app/views/referential_vehicle_journeys/index.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :referential_vehicle_journeys, @workbench, @referential
- content_for :page_header_title, t('.title')

.page_content
  .container-fluid
    .form-group
      .row
        .col-lg-12
          = render 'filters'
    - if @vehicle_journeys&.any?
      .row
        .col-lg-12
          .select_table
            = table_builder_2 @vehicle_journeys,
              [ \
                TableBuilderHelper::Column.new( \
                  name: t('objectid'), \
                  attribute: Proc.new { |n| n.get_objectid.short_id }, \
                  sortable: false \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :published_journey_name,
                  attribute: Proc.new {|v| v.published_journey_name.presence||I18n.t('none')},
                  link_to: lambda { |vehicle_journey| workbench_referential_route_vehicle_journeys_path(@workbench, @referential, vehicle_journey.route) } \
                ),
                TableBuilderHelper::Column.new( \
                  key: :line, \
                  attribute: Proc.new {|v| v.route.line.name}, \
                  sortable: false,
                  link_to: lambda { |vehicle_journey| workbench_referential_line_path(@workbench, @referential, vehicle_journey.route.line) } \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :company, \
                  attribute: Proc.new {|v| v.route.line.company&.name}, \
                  sortable: false \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :route,
                  attribute: Proc.new {|v| v.route.name},
                  sortable: false,
                  link_to: lambda { |vehicle_journey| workbench_referential_line_route_path(@workbench, @referential, vehicle_journey.route.line, vehicle_journey.route) } \
                ),
                TableBuilderHelper::Column.new( \
                  key: :departure_time, \
                  attribute: Proc.new {|v| display_time_of_day(v.vehicle_journey_at_stops.first&.departure_local_time_of_day) }, \
                  sortable: @enable_complex_sort \
                ), \
                [@search.from_stop_area, @search.to_stop_area].compact.map{|stop| \
                  TableBuilderHelper::Column.new( \
                    attribute: Proc.new {|v| vjas = v.vehicle_journey_at_stops.where("stop_points.stop_area_id" => stop.id).last; vjas && display_time_of_day(vjas.arrival_local_time_of_day) }, \
                    sortable: false, \
                    name: stop.name \
                  )\
                }, \
                TableBuilderHelper::Column.new( \
                  key: :arrival_time, \
                  attribute: Proc.new {|v| display_time_of_day(v.vehicle_journey_at_stops.last&.arrival_local_time_of_day) }, \
                  sortable: @enable_complex_sort \
                ), \
              ].flatten.compact,
              cls: 'table has-filter has-search'

          = new_pagination @vehicle_journeys_for_paginate, 'pull-right'
    - else
      .row.mt-xs
        .col-lg-12
          = replacement_msg t('.search_no_results')