Prevent duplicate bulk submission

This commit is contained in:
Hillel Coren 2017-12-03 10:58:23 +02:00
parent fc1afe05a5
commit 9a4af6c889
2 changed files with 10 additions and 1 deletions

View File

@ -2601,6 +2601,7 @@ $LANG = array(
'promotion_footer' => 'Your promotion will expire soon, :link to upgrade now.', 'promotion_footer' => 'Your promotion will expire soon, :link to upgrade now.',
'unable_to_delete_primary' => 'Note: to delete this company first delete all linked companies.', 'unable_to_delete_primary' => 'Note: to delete this company first delete all linked companies.',
'please_register' => 'Please register your account', 'please_register' => 'Please register your account',
'processing_request' => 'Processing request',
); );

View File

@ -8,7 +8,7 @@
</div> </div>
<div class="pull-left"> <div class="pull-left">
@if (in_array($entityType, [ENTITY_TASK, ENTITY_INVOICE, ENTITY_PRODUCT, ENTITY_PROJECT])) @if (in_array($entityType, [ENTITY_TASK, ENTITY_EXPENSE, ENTITY_PRODUCT, ENTITY_PROJECT]))
@can('create', 'invoice') @can('create', 'invoice')
{!! Button::primary(trans('texts.invoice'))->withAttributes(['class'=>'invoice', 'onclick' =>'submitForm_'.$entityType.'("invoice")'])->appendIcon(Icon::create('check')) !!} {!! Button::primary(trans('texts.invoice'))->withAttributes(['class'=>'invoice', 'onclick' =>'submitForm_'.$entityType.'("invoice")'])->appendIcon(Icon::create('check')) !!}
@endcan @endcan
@ -128,7 +128,15 @@
<script type="text/javascript"> <script type="text/javascript">
var submittedForm;
function submitForm_{{ $entityType }}(action, id) { function submitForm_{{ $entityType }}(action, id) {
// prevent duplicate form submissions
if (submittedForm) {
swal("{{ trans('texts.processing_request') }}")
return;
}
submittedForm = true;
if (id) { if (id) {
$('#public_id_{{ $entityType }}').val(id); $('#public_id_{{ $entityType }}').val(id);
} }