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