Fix doble submit specs

We have a custom implementation to avoid doble submissions which causes
some custom problems 😌

This commit should fix the following three specs
spec/features/comments/legislation_annotations_spec.rb:367
spec/features/comments/legislation_questions_spec.rb:333
spec/features/custom/probe_option_comments_spec.rb:298

One of the custom problems comes from ajax:success[1] not being
triggered, instead only ajax:complete seems to be triggered

We should remove this custom implementation and use the standard
solution provided in rails[2]

[1]
https://github.com/AyuntamientoMadrid/consul/blob/master/app/assets/java
scripts/prevent_double_submission.js.coffee#L28

[2]
https://stackoverflow.com/questions/9570912/how-to-disable-a-form-submit
-button-a-l%C3%A0-ruby-on-rails-way/9572893#9572893
This commit is contained in:
rgarcia
2018-02-20 17:33:54 +01:00
committed by Bertocq
parent 752ffd678f
commit 7f30d0c620

View File

@@ -22,11 +22,15 @@ App.PreventDoubleSubmission =
initialize: ->
$('form').on('submit', (event) ->
unless event.target.id == "new_officing_voter" || "admin_download_emails"
unless event.target.id == "new_officing_voter" ||
event.target.id == "admin_download_emails"
buttons = $(this).find(':button, :submit')
App.PreventDoubleSubmission.disable_buttons(buttons)
).on('ajax:success', (event) ->
unless event.target.id == "new_officing_voter"
unless event.target.id == "new_officing_voter" ||
event.target.id == "admin_download_emails"
buttons = $(this).find(':button, :submit')
App.PreventDoubleSubmission.reset_buttons(buttons)
)