aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2016-11-30 14:18:38 +0100
committerAlban Peignier2016-11-30 14:50:05 +0100
commitec923ea9bf980a846d5b3d588796fc4ac528adaf (patch)
tree9701cb51e37427831c31de7094df70e737a0c4ad
parentfdd5f8faf5c5e22fc486df99d60a5d0184af1b98 (diff)
downloadchouette-core-ec923ea9bf980a846d5b3d588796fc4ac528adaf.tar.bz2
Add StopArea#user_objectid in json used by routes/_form. Refs #2127
-rw-r--r--app/helpers/routes_helper.rb2
-rw-r--r--app/models/chouette/stop_area.rb8
-rw-r--r--app/views/autocomplete_stop_areas/index.rabl3
3 files changed, 11 insertions, 2 deletions
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index 99278625d..d4cadcd5a 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -15,7 +15,7 @@ module RoutesHelper
def route_json_for_edit(route)
route.stop_points.includes(:stop_area).map do |stop_point|
- stop_area_attributes = stop_point.stop_area.attributes.slice("name","city_name", "zip_code")
+ stop_area_attributes = stop_point.stop_area.attributes.slice("name","city_name", "zip_code", "user_objectid")
stop_point_attributes = stop_point.attributes.slice("for_boarding","for_alighting")
stop_area_attributes.merge(stop_point_attributes).merge(stoppoint_id: stop_point.id, stoparea_id: stop_point.stop_area.id)
end.to_json
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index 815304cca..50fe18f64 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -83,6 +83,14 @@ class Chouette::StopArea < Chouette::ActiveRecord
end
end
+ def user_objectid
+ if objectid =~ /^.*:([0-9A-Za-z_-]+):STIF$/
+ $1
+ else
+ id.to_s
+ end
+ end
+
def children_in_depth
return [] if self.children.empty?
diff --git a/app/views/autocomplete_stop_areas/index.rabl b/app/views/autocomplete_stop_areas/index.rabl
index 6d81442c7..adec16cff 100644
--- a/app/views/autocomplete_stop_areas/index.rabl
+++ b/app/views/autocomplete_stop_areas/index.rabl
@@ -9,7 +9,8 @@ node do |stop_area|
:short_name => truncate(stop_area.name, :length => 30) || "",
:zip_code => stop_area.zip_code || "",
:city_name => stop_area.city_name || "",
- :short_city_name => truncate(stop_area.city_name, :length => 15) || ""
+ :short_city_name => truncate(stop_area.city_name, :length => 15) || "",
+ :user_objectid => stop_area.user_objectid
}
end