aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/route_section.js.coffee18
-rw-r--r--app/maps/stop_area_map.rb1
-rw-r--r--app/models/route_sections_selector.rb22
3 files changed, 18 insertions, 23 deletions
diff --git a/app/assets/javascripts/route_section.js.coffee b/app/assets/javascripts/route_section.js.coffee
index 74f095772..e4a1021c3 100644
--- a/app/assets/javascripts/route_section.js.coffee
+++ b/app/assets/javascripts/route_section.js.coffee
@@ -36,14 +36,14 @@ class @RouteSectionMap
if id
features = route_section_geometry.getFeaturesByAttribute('id', id.toString())
if features.length > 0
- feature = features[0]
- style = null
- if !erase
- style =
- strokeWidth: 3
- strokeColor: 'green'
- feature.style = style
- feature.layer.redraw()
+ $.each features, (key, feature) ->
+ style = null
+ if !erase
+ style =
+ strokeWidth: 3
+ strokeColor: 'green'
+ feature.style = style
+ feature.layer.redraw()
@changeStyle = (el) ->
id = $(el).val()
@@ -54,6 +54,7 @@ class @RouteSectionMap
RouteSectionMap.featureStyle value, true
return
RouteSectionMap.featureStyle id, false
+ RouteSectionMap.editRoute el
jQuery ->
$route_sections_selector = $('[name^="route_sections_selector[sections_attributes]"]')
@@ -77,7 +78,6 @@ jQuery ->
$('#new_route_sections_selector select').on 'change', ->
RouteSectionMap.changeStyle this
- RouteSectionMap.editRoute this
$('form.route_section').find('button[type="submit"]').on 'click', (e) ->
e.preventDefault();
diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb
index 93ec9ecdb..32f48c552 100644
--- a/app/maps/stop_area_map.rb
+++ b/app/maps/stop_area_map.rb
@@ -26,7 +26,6 @@ class StopAreaMap < ApplicationMap
if stop_area.new_record?
page << <<EOF
var createStyleMap = function() {
- var defProp = {strokeColor: "red"};
var defProp = {strokeColor: "black", strokeOpacity: 1, strokeWidth: 2, fillColor: "white", fillOpacity: 1};
var defStyle = OpenLayers.Util.applyDefaults(defProp, OpenLayers.Feature.Vector.style["default"]);
return new OpenLayers.StyleMap({'default': defStyle});
diff --git a/app/models/route_sections_selector.rb b/app/models/route_sections_selector.rb
index ba8a2cc9a..85d049862 100644
--- a/app/models/route_sections_selector.rb
+++ b/app/models/route_sections_selector.rb
@@ -21,16 +21,8 @@ class RouteSectionsSelector
save
end
- # def persisted?
- # false
- # end
-
delegate :stop_points, to: :itinerary
- def route_sections
- @route_sections ||= itinerary.route_sections.to_a
- end
-
def sections
@sections ||= create_sections
end
@@ -38,7 +30,9 @@ class RouteSectionsSelector
def create_sections
[].tap do |sections|
stop_points.each_cons(2).each_with_index do |(departure, arrival), index|
- sections << Section.new(departure.stop_area, arrival.stop_area, route_sections[index])
+ journey_pattern_section = Chouette::JourneyPatternSection.find_by(journey_pattern: @itinerary, rank: index)
+ route_section = journey_pattern_section ? journey_pattern_section.route_section : nil
+ sections << Section.new(departure.stop_area, arrival.stop_area, route_section, index)
end
end
end
@@ -51,16 +45,18 @@ class RouteSectionsSelector
end
def save
- itinerary.update_attribute :route_section_ids, sections.map(&:route_section_id)
+ sections.each do |s|
+ Chouette::JourneyPatternSection.update_by_journey_pattern_rank(itinerary.id, s.route_section_id, s.rank)
+ end
end
class Section
extend ActiveModel::Translation
- attr_accessor :departure, :arrival, :route_section_id
+ attr_accessor :departure, :arrival, :rank, :route_section_id
- def initialize(departure, arrival, route_section = nil)
- @departure, @arrival = departure, arrival
+ def initialize(departure, arrival, route_section = nil, rank = nil)
+ @departure, @arrival, @rank = departure, arrival, rank
self.route_section = route_section
end