aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorVlatka Pavisic2017-04-18 18:17:17 +0200
committerVlatka Pavisic2017-04-18 18:17:23 +0200
commit33e796dc89b36f7c57adb9d462c0cc35a15be623 (patch)
tree1a9d3df51ed18aba8cdf08cee8276287a5bdf5db /app/assets/javascripts
parent07f17622daadc36db95fcf087798842f783e0f09 (diff)
downloadchouette-core-33e796dc89b36f7c57adb9d462c0cc35a15be623.tar.bz2
Refs #3132 #3135 #3136 ITL StopArea validations
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/routing_constraint_zones.coffee10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/assets/javascripts/routing_constraint_zones.coffee b/app/assets/javascripts/routing_constraint_zones.coffee
index 7460a64a7..458189b36 100644
--- a/app/assets/javascripts/routing_constraint_zones.coffee
+++ b/app/assets/javascripts/routing_constraint_zones.coffee
@@ -4,18 +4,24 @@ fill_stop_points_options = ->
referential_id = document.location.pathname.match(/\d+/g)[0]
line_id = document.location.pathname.match(/\d+/g)[1]
route_id = $('#routing_constraint_zone_route_id').val()
+ if errors_on_form()
+ stop_point_ids = eval($('#stop_point_ids').val())
$.ajax
url: "/referentials/#{referential_id}/lines/#{line_id}/routes/#{route_id}/stop_points"
dataType: 'json'
success: (data, textStatus, jqXHR) ->
for stop_point in data
- stop_point_select.append "<option value='#{stop_point.id}'>#{stop_point.name}</option>"
+ selected = $.inArray(stop_point.id, stop_point_ids) != -1
+ stop_point_select.append "<option value='#{stop_point.id}'" + "#{if selected then ' selected' else ''}" + ">#{stop_point.name}</option>"
error: (jqXHR, textStatus, errorThrown) ->
console.log textStatus
console.log errorThrown
+errors_on_form = ->
+ document.location.pathname.endsWith('routing_constraint_zones') && $('#new_routing_constraint_zone').length
+
$(document).on 'turbolinks:load', ->
- if document.location.pathname.endsWith('new')
+ if document.location.pathname.endsWith('new') || errors_on_form()
fill_stop_points_options()
$('#routing_constraint_zone_route_id').change(fill_stop_points_options)