0003-js-delay-submit-until-autosave-ajax-request-is-finis.patch
wcs/qommon/static/js/qommon.forms.js | ||
---|---|---|
124 | 124 |
$(function() { |
125 | 125 |
var autosave_timeout_id = null; |
126 | 126 |
var autosave_is_running = false; |
127 |
var autosave_button_to_click_on_complete = null; |
|
128 | ||
127 | 129 |
if ($('form[data-has-draft]:not([data-autosave=false])').length == 1) { |
128 | 130 |
var last_auto_save = $('form[data-has-draft]').serialize(); |
129 | 131 |
function autosave() { |
... | ... | |
149 | 151 |
if (autosave_timeout_id !== null) { |
150 | 152 |
install_autosave(); |
151 | 153 |
} |
154 |
if (autosave_button_to_click_on_complete !== null) { |
|
155 |
autosave_button_to_click_on_complete.click(); |
|
156 |
} |
|
152 | 157 |
} |
153 | 158 |
}); |
154 | 159 |
} |
... | ... | |
391 | 396 |
} |
392 | 397 |
return true; |
393 | 398 |
}); |
399 |
$('form .buttons.submit button').on('click', function (event) { |
|
400 |
if (autosave_is_running) { |
|
401 |
autosave_button_to_click_on_complete = event.target; |
|
402 |
/* prevent more autosave */ |
|
403 |
autosave_timeout_id = null; |
|
404 |
event.preventDefault(); |
|
405 |
} |
|
406 |
}); |
|
394 | 407 |
$('form').on('submit', function(event) { |
395 | 408 |
var $form = $(this); |
396 | 409 |
/* prevent more autosave */ |
397 |
- |