Merge remote-tracking branch 'upstream/develop' into wepay-integration

This commit is contained in:
Joshua Dwire 2016-05-25 11:14:14 -04:00
commit 6ddbbbc64d
4 changed files with 72 additions and 51 deletions

View File

@ -41,10 +41,10 @@ class AddDocuments extends Migration {
$t->timestamps(); $t->timestamps();
$t->foreign('account_id')->references('id')->on('accounts'); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$t->foreign('user_id')->references('id')->on('users'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$t->foreign('invoice_id')->references('id')->on('invoices'); $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$t->foreign('expense_id')->references('id')->on('expenses'); $t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade');
$t->unique( array('account_id','public_id') ); $t->unique( array('account_id','public_id') );

View File

@ -1311,6 +1311,7 @@ $LANG = array(
'new_start_date' => 'New start date', 'new_start_date' => 'New start date',
'security' => 'Security', 'security' => 'Security',
'see_whats_new' => 'See what\'s new in v:version', 'see_whats_new' => 'See what\'s new in v:version',
'wait_for_upload' => 'Please wait for the document upload to complete.',
'view_dashboard' => 'View Dashboard', 'view_dashboard' => 'View Dashboard',
'client_session_expired' => 'Session Expired', 'client_session_expired' => 'Session Expired',

View File

@ -249,7 +249,7 @@
public_id:document.public_id(), public_id:document.public_id(),
status:Dropzone.SUCCESS, status:Dropzone.SUCCESS,
accepted:true, accepted:true,
url:document.preview_url()||document.url(), url:document.url(),
mock:true, mock:true,
index:i index:i
}; };

View File

@ -998,7 +998,18 @@
}) })
// Initialize document upload // Initialize document upload
dropzone = new Dropzone('#document-upload .dropzone', { window.dropzone = false;
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (window.dropzone) {
return;
}
var target = $(e.target).attr('href') // activated tab
if (target != '#attached-documents') {
return;
}
window.dropzone = new Dropzone('#document-upload .dropzone', {
url:{!! json_encode(url('document')) !!}, url:{!! json_encode(url('document')) !!},
params:{ params:{
_token:"{{ Session::getToken() }}" _token:"{{ Session::getToken() }}"
@ -1023,7 +1034,7 @@
public_id:document.public_id(), public_id:document.public_id(),
status:Dropzone.SUCCESS, status:Dropzone.SUCCESS,
accepted:true, accepted:true,
url:document.preview_url()||document.url(), url:document.url(),
mock:true, mock:true,
index:i index:i
}; };
@ -1031,7 +1042,7 @@
dropzone.emit('addedfile', mockFile); dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile); dropzone.emit('complete', mockFile);
if(document.preview_url()){ if(document.preview_url()){
dropzone.emit('thumbnail', mockFile, document.preview_url()||document.url()); dropzone.emit('thumbnail', mockFile, document.preview_url());
} }
else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){ else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url()); dropzone.emit('thumbnail', mockFile, document.url());
@ -1039,6 +1050,7 @@
dropzone.files.push(mockFile); dropzone.files.push(mockFile);
} }
} }
});
@endif @endif
}); });
@ -1222,7 +1234,7 @@
} }
} }
preparePdfData(''); submitAction('');
} }
function getSendToEmails() { function getSendToEmails() {
@ -1257,6 +1269,11 @@
} }
function onFormSubmit(event) { function onFormSubmit(event) {
if (window.countUploadingDocuments > 0) {
alert("{!! trans('texts.wait_for_upload') !!}");
return false;
}
if (!isSaveValid()) { if (!isSaveValid()) {
model.showClientForm(); model.showClientForm();
return false; return false;
@ -1431,6 +1448,7 @@
model.invoice().invoice_number(number); model.invoice().invoice_number(number);
} }
window.countUploadingDocuments = 0;
@if ($account->hasFeature(FEATURE_DOCUMENTS)) @if ($account->hasFeature(FEATURE_DOCUMENTS))
function handleDocumentAdded(file){ function handleDocumentAdded(file){
// open document when clicked // open document when clicked
@ -1442,6 +1460,7 @@
if(file.mock)return; if(file.mock)return;
file.index = model.invoice().documents().length; file.index = model.invoice().documents().length;
model.invoice().addDocument({name:file.name, size:file.size, type:file.type}); model.invoice().addDocument({name:file.name, size:file.size, type:file.type});
window.countUploadingDocuments++;
} }
function handleDocumentRemoved(file){ function handleDocumentRemoved(file){
@ -1452,6 +1471,7 @@
function handleDocumentUploaded(file, response){ function handleDocumentUploaded(file, response){
file.public_id = response.document.public_id file.public_id = response.document.public_id
model.invoice().documents()[file.index].update(response.document); model.invoice().documents()[file.index].update(response.document);
window.countUploadingDocuments--;
refreshPDF(true); refreshPDF(true);
if(response.document.preview_url){ if(response.document.preview_url){