aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorFlorent Peyraud2017-07-06 12:42:53 +0200
committerFlorent Peyraud2017-07-06 12:42:53 +0200
commite3f7a67d922614363fe798992af4f656b77f0eb5 (patch)
tree81c00cf3094d724c91f428035ea9e540c377a7bf /app/assets/javascripts
parent3c39ff76da22a410f1c81acabad626f15a63d800 (diff)
parent74e94da83d6ea64dcb1e70e69c2fef046453e4a1 (diff)
downloadchouette-core-e3f7a67d922614363fe798992af4f656b77f0eb5.tar.bz2
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/cleanup.coffee11
-rw-r--r--app/assets/javascripts/routing_constraint_zones.coffee80
2 files changed, 20 insertions, 71 deletions
diff --git a/app/assets/javascripts/cleanup.coffee b/app/assets/javascripts/cleanup.coffee
index 169a006a9..7f6594018 100644
--- a/app/assets/javascripts/cleanup.coffee
+++ b/app/assets/javascripts/cleanup.coffee
@@ -2,8 +2,13 @@ $(document).on("change", 'input[name="clean_up[date_type]"]', (e) ->
type = $(this).val()
end_date = $('.cleanup_end_date_wrapper')
- if type == 'between'
- end_date.removeClass('hidden').show()
- else
+ if type == 'before'
+ end_date.hide()
+ $("label[for='clean_up_begin_date_3i']").html("Date de fin de purge");
+ else if type == 'after'
end_date.hide()
+ $("label[for='clean_up_begin_date_3i']").html("Date de début de purge");
+ else
+ $("label[for='clean_up_begin_date_3i']").html("Date de début de purge");
+ end_date.show()
)
diff --git a/app/assets/javascripts/routing_constraint_zones.coffee b/app/assets/javascripts/routing_constraint_zones.coffee
index 8721dfb38..2fd83fa28 100644
--- a/app/assets/javascripts/routing_constraint_zones.coffee
+++ b/app/assets/javascripts/routing_constraint_zones.coffee
@@ -1,73 +1,17 @@
-@ITL_stoppoints = ->
- routeID = $('#routing_constraint_zone_route_id').val()
-
- if (routeID)
- origin = window.location.origin
- path = window.location.pathname.split('/', 5).join('/')
- reqURL = origin + path + '/routes/' + routeID + '/stop_points.json'
+$ ->
+ update_stop_points = () ->
+ url = $('#routing_constraint_zone_route_id').attr("data-url")
+ route_id = $('#routing_constraint_zone_route_id').val()
$.ajax
- url: reqURL
- dataType: 'json'
+ url: url
+ dataType: 'script'
+ data: { route_id: route_id }
error: (jqXHR, textStatus, errorThrown) ->
- console.log(errorThrown)
- success: (collection, textStatus, jqXHR) ->
- html = ''
- stopAreaBaseURL = origin + window.location.pathname.split('/', 3).join('/') + '/stop_areas/'
-
- collection.forEach (item, index) ->
- html += "<div class='nested-fields'><div class='wrapper'>
- <div><a href='" + stopAreaBaseURL + item.stop_area_id + "' class='navlink' title='Voir l&#39;arrêt'><span>" + item.name + "</span></a></div>
- <div><span>" + item.city_name + " (" + item.zip_code + ")</span></div>
- <div>
- <span class='has_radio'>
- <input type='checkbox' name='routing_constraint_zone[stop_point_ids][" + index + "]' value='" + item.id + "'>
- <span class='radio-label'></span>
- </span>
- </div>
- </div></div>"
-
- $('#ITL_stoppoints').find('.nested-fields').remove()
- $('#ITL_stoppoints').find('.nested-head').after(html)
-
- # VALIDATION
- selection = []
-
- totalItems = collection.length
-
- $('#ITL_stoppoints').on 'click', "input[type='checkbox']", (e) ->
- v = $(e.target).val()
+ console.log("ERROR")
+ success: (data, textStatus, jqXHR) ->
+ console.log("SUCCESS")
- if ( $.inArray(v, selection) != -1 )
- selection.splice(selection.indexOf(v), 1)
- else
- selection.push(v)
-
- alertMsg1 = "<div class='alert alert-danger' style='margin-bottom:15px;'>
- <p class='small'>Un ITL doit comporter au moins deux arrêts</p>
- </div>"
- alertMsg2 = "<div class='alert alert-danger' style='margin-bottom:15px;'>
- <p class='small'>Un ITL ne peut recouvrir tous les arrêts d'un itinéraire</p>
- </div>"
-
- $(document).on 'click', "input[type='submit']", (e)->
- inputName = $('#routing_constraint_zone_name').val()
-
- $('.alert-danger').remove()
-
- if ( selection.length < 2 && inputName != "" )
- e.preventDefault()
- $('#routing_constraint_zone_name').closest('.form-group').removeClass('has-error').find('.help-block').remove()
- $('#ITL_stoppoints').prepend(alertMsg1)
-
- if ( selection.length == totalItems && inputName != "" )
- e.preventDefault()
- $('#routing_constraint_zone_name').closest('.form-group').removeClass('has-error').find('.help-block').remove()
- $('#ITL_stoppoints').prepend(alertMsg2)
-
-$ ->
- ITL_stoppoints()
+ $("#itl_form #routing_constraint_zone_route_id").on 'change', -> update_stop_points()
- $('#routing_constraint_zone_route_id').on 'change', ->
- $('.alert-danger').remove()
- ITL_stoppoints()
+ update_stop_points()