mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Prevent saving expense before documents have uploaded
This commit is contained in:
parent
85184f9a5b
commit
44fb6682e4
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{!! Former::open($url)->addClass('warn-on-exit main-form')->method($method) !!}
|
{!! Former::open($url)
|
||||||
|
->addClass('warn-on-exit main-form')
|
||||||
|
->onsubmit('return onFormSubmit(event)')
|
||||||
|
->method($method) !!}
|
||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
{!! Former::text('action') !!}
|
{!! Former::text('action') !!}
|
||||||
</div>
|
</div>
|
||||||
@ -154,6 +157,15 @@
|
|||||||
clientMap[client.public_id] = client;
|
clientMap[client.public_id] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFormSubmit(event) {
|
||||||
|
if (window.countUploadingDocuments > 0) {
|
||||||
|
alert("{!! trans('texts.wait_for_upload') !!}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function onClientChange() {
|
function onClientChange() {
|
||||||
var clientId = $('select#client_id').val();
|
var clientId = $('select#client_id').val();
|
||||||
var client = clientMap[clientId];
|
var client = clientMap[clientId];
|
||||||
@ -240,6 +252,7 @@
|
|||||||
dropzone.on("addedfile",handleDocumentAdded);
|
dropzone.on("addedfile",handleDocumentAdded);
|
||||||
dropzone.on("removedfile",handleDocumentRemoved);
|
dropzone.on("removedfile",handleDocumentRemoved);
|
||||||
dropzone.on("success",handleDocumentUploaded);
|
dropzone.on("success",handleDocumentUploaded);
|
||||||
|
dropzone.on("canceled",handleDocumentCanceled);
|
||||||
for (var i=0; i<model.documents().length; i++) {
|
for (var i=0; i<model.documents().length; i++) {
|
||||||
var document = model.documents()[i];
|
var document = model.documents()[i];
|
||||||
var mockFile = {
|
var mockFile = {
|
||||||
@ -362,6 +375,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.countUploadingDocuments = 0;
|
||||||
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
|
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
|
||||||
function handleDocumentAdded(file){
|
function handleDocumentAdded(file){
|
||||||
// open document when clicked
|
// open document when clicked
|
||||||
@ -373,6 +387,7 @@
|
|||||||
if(file.mock)return;
|
if(file.mock)return;
|
||||||
file.index = model.documents().length;
|
file.index = model.documents().length;
|
||||||
model.addDocument({name:file.name, size:file.size, type:file.type});
|
model.addDocument({name:file.name, size:file.size, type:file.type});
|
||||||
|
window.countUploadingDocuments++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDocumentRemoved(file){
|
function handleDocumentRemoved(file){
|
||||||
@ -382,11 +397,16 @@
|
|||||||
function handleDocumentUploaded(file, response){
|
function handleDocumentUploaded(file, response){
|
||||||
file.public_id = response.document.public_id
|
file.public_id = response.document.public_id
|
||||||
model.documents()[file.index].update(response.document);
|
model.documents()[file.index].update(response.document);
|
||||||
|
window.countUploadingDocuments--;
|
||||||
if(response.document.preview_url){
|
if(response.document.preview_url){
|
||||||
dropzone.emit('thumbnail', file, response.document.preview_url);
|
dropzone.emit('thumbnail', file, response.document.preview_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDocumentCanceled()
|
||||||
|
{
|
||||||
|
window.countUploadingDocuments--;
|
||||||
|
}
|
||||||
@endif
|
@endif
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1025,6 +1025,7 @@
|
|||||||
dropzone.on("addedfile",handleDocumentAdded);
|
dropzone.on("addedfile",handleDocumentAdded);
|
||||||
dropzone.on("removedfile",handleDocumentRemoved);
|
dropzone.on("removedfile",handleDocumentRemoved);
|
||||||
dropzone.on("success",handleDocumentUploaded);
|
dropzone.on("success",handleDocumentUploaded);
|
||||||
|
dropzone.on("canceled",handleDocumentCanceled);
|
||||||
for (var i=0; i<model.invoice().documents().length; i++) {
|
for (var i=0; i<model.invoice().documents().length; i++) {
|
||||||
var document = model.invoice().documents()[i];
|
var document = model.invoice().documents()[i];
|
||||||
var mockFile = {
|
var mockFile = {
|
||||||
@ -1465,11 +1466,15 @@
|
|||||||
model.invoice().documents()[file.index].update(response.document);
|
model.invoice().documents()[file.index].update(response.document);
|
||||||
window.countUploadingDocuments--;
|
window.countUploadingDocuments--;
|
||||||
refreshPDF(true);
|
refreshPDF(true);
|
||||||
|
|
||||||
if(response.document.preview_url){
|
if(response.document.preview_url){
|
||||||
dropzone.emit('thumbnail', file, response.document.preview_url);
|
dropzone.emit('thumbnail', file, response.document.preview_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDocumentCanceled()
|
||||||
|
{
|
||||||
|
window.countUploadingDocuments--;
|
||||||
|
}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user