aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/journey_patterns_helper.rb
blob: 3472d90a6a5487593fb41f75dcbb3b3089dd250c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module JourneyPatternsHelper

  def journey_name( journey_pattern)
    unless journey_pattern.name.blank?
      return truncate(journey_pattern.name, :length => 30)
    end

    unless journey_pattern.stop_points.empty?
      return truncate( t('journey_patterns.journey_pattern.from_to',
        :departure => journey_pattern.stop_points.first.stop_area.name,
        :arrival => journey_pattern.stop_points.last.stop_area.name), :length => 30)
    end

    journey_pattern.id.to_s
  end

  def stop_point_ids_label(journey_pattern)
    return journey_pattern.human_attribute_name(:stop_point_ids) if journey_pattern.vehicle_journeys.empty?

    "#{journey_pattern.human_attribute_name(:stop_point_ids)}. #{t('journey_patterns.form.warning', :count => journey_pattern.vehicle_journeys.count)}"
  end
  def icon_code(stop_point, journey)
    code = "stop_area"
    if stop_point.stop_area.id == journey.route.stop_areas.first.id
      code << "_green"
    elsif stop_point.stop_area.id == journey.route.stop_areas.last.id
      code << "_red"
    else
      code << "_black"
    end
    unless journey.stop_points.include?( stop_point)
      code << "_unselected"
    end
    code
  end
end