mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Simplify duplicate submission check
This commit is contained in:
parent
b3031bcc7c
commit
2ea132cf49
@ -1472,10 +1472,9 @@
|
||||
}
|
||||
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($('#saveButton').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
$('#saveButton, #emailButton, #draftButton').attr('disabled', true);
|
||||
// if save fails ensure user can try again
|
||||
$.post('{{ url($url) }}', $('.main-form').serialize(), function(data) {
|
||||
@ -1497,7 +1496,6 @@
|
||||
function handleSaveFailed(data) {
|
||||
$('#saveButton, #emailButton, #draftButton').attr('disabled', false);
|
||||
$('#emailModal div.modal-footer button').attr('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
var error = '';
|
||||
if (data) {
|
||||
var error = firstJSONError(data.responseJSON) || data.statusText;
|
||||
|
@ -272,7 +272,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
NINJA.formIsChanged = {{ isset($formIsChanged) && $formIsChanged ? 'true' : 'false' }};
|
||||
NINJA.formIsSubmitted = false;
|
||||
|
||||
$(function () {
|
||||
$('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').change(function () {
|
||||
|
@ -36,7 +36,6 @@
|
||||
},
|
||||
onError: function(e) {
|
||||
$form.find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
|
||||
// Show the errors on the form
|
||||
if (e.details && e.details.invalidFieldKeys.length) {
|
||||
@ -56,18 +55,17 @@
|
||||
$('#js-error-message').html(e.message).fadeIn();
|
||||
}
|
||||
},
|
||||
onPaymentMethodReceived: function(e) {
|
||||
if (NINJA.formIsSubmitted) {
|
||||
onPaymentMethodReceived: function(event) {
|
||||
if ($form.find('button').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
$form.find('button').prop('disabled', true);
|
||||
$('#js-error-message').hide();
|
||||
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$form.append($('<input type="hidden" name="sourceToken"/>').val(e.nonce));
|
||||
$form.append($('<input type="hidden" name="sourceToken"/>').val(event.nonce));
|
||||
// and submit
|
||||
$form.get(0).submit();
|
||||
}
|
||||
|
@ -47,11 +47,10 @@
|
||||
|
||||
$(function() {
|
||||
$('.payment-form').submit(function(event) {
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($form.find('button').is(':disabled')) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
var $form = $(this);
|
||||
|
@ -219,7 +219,12 @@
|
||||
});
|
||||
|
||||
function onFormSubmit(event) {
|
||||
if ($('#saveButton').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@if ($payment)
|
||||
$('#saveButton').attr('disabled', true);
|
||||
return true;
|
||||
@else
|
||||
// warn if amount is more than balance/credit will be created
|
||||
@ -228,10 +233,6 @@
|
||||
var amount = $('#amount').val();
|
||||
|
||||
if (NINJA.parseFloat(amount) <= invoice.balance || confirm("{{ trans('texts.amount_greater_than_balance') }}")) {
|
||||
if (NINJA.formIsSubmitted) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
$('#saveButton').attr('disabled', true);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -56,7 +56,6 @@
|
||||
}
|
||||
}
|
||||
$('.payment-form').find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').html(message).fadeIn();
|
||||
} else {
|
||||
$('#sourceToken').val(result.token);
|
||||
@ -64,10 +63,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($('.payment-form').find('button').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
$('.payment-form').find('button').prop('disabled', true);
|
||||
|
@ -47,10 +47,9 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($form.find('button').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
$form.find('button').prop('disabled', true);
|
||||
@ -98,7 +97,6 @@
|
||||
error = "{{trans('texts.country_not_supported')}}";
|
||||
}
|
||||
$form.find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').html(error).fadeIn();
|
||||
} else {
|
||||
// response contains id and card, which contains additional card details
|
||||
|
@ -49,10 +49,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($form.find('button').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
$form.find('button').prop('disabled', true);
|
||||
@ -73,7 +72,6 @@
|
||||
// Show the errors on the form
|
||||
var error = response.error.message;
|
||||
$form.find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').html(error).fadeIn();
|
||||
} else {
|
||||
// response contains id and card, which contains additional card details
|
||||
|
@ -45,13 +45,11 @@
|
||||
// Show the errors on the form
|
||||
var error = response.error_description;
|
||||
$form.find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').text(error).fadeIn();
|
||||
} else {
|
||||
if (NINJA.formIsSubmitted) {
|
||||
if ($form.find('button').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
// response contains id and card, which contains additional card details
|
||||
var token = response.credit_card_id;
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
@ -65,7 +63,6 @@
|
||||
// Show the errors on the form
|
||||
var error = response.error_description;
|
||||
$form.find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').text(error).fadeIn();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user