From 6d6f8f5caba264a92c476806870f529c2a4be252 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 29 Dec 2015 12:23:50 +0200 Subject: [PATCH] Fix for dev channel Chrome crash --- ...014_10_06_195330_add_invoice_design_table.php | 2 +- .../2015_07_27_183830_add_pdfmake_support.php | 2 +- public/js/built.js | 16 ++++------------ public/js/script.js | 16 ++++------------ resources/views/invoices/edit.blade.php | 4 +++- resources/views/invoices/knockout.blade.php | 4 ++-- storage/templates/modern.js | 2 +- 7 files changed, 16 insertions(+), 30 deletions(-) diff --git a/database/migrations/2014_10_06_195330_add_invoice_design_table.php b/database/migrations/2014_10_06_195330_add_invoice_design_table.php index 81442b001b..582b59a09d 100644 --- a/database/migrations/2014_10_06_195330_add_invoice_design_table.php +++ b/database/migrations/2014_10_06_195330_add_invoice_design_table.php @@ -14,7 +14,7 @@ class AddInvoiceDesignTable extends Migration { { Schema::table('invoice_designs', function($table) { - $table->text('javascript')->nullable(); + $table->mediumText('javascript')->nullable(); }); Schema::table('accounts', function($table) diff --git a/database/migrations/2015_07_27_183830_add_pdfmake_support.php b/database/migrations/2015_07_27_183830_add_pdfmake_support.php index 19ca03a25b..b9294315a4 100644 --- a/database/migrations/2015_07_27_183830_add_pdfmake_support.php +++ b/database/migrations/2015_07_27_183830_add_pdfmake_support.php @@ -14,7 +14,7 @@ class AddPdfmakeSupport extends Migration { { Schema::table('invoice_designs', function($table) { - $table->text('pdfmake')->nullable(); + $table->mediumText('pdfmake')->nullable(); }); } diff --git a/public/js/built.js b/public/js/built.js index 11a81b35e0..6c00fbe7cb 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -29885,34 +29885,26 @@ var isChrome = !!window.chrome && !isOpera && !isEdge; // Chrome 1+ var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0; var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 -var pdfDoc; -var invoiceOld; var refreshTimer; function generatePDF(invoice, javascript, force, cb) { if (!invoice || !javascript) { return; } //console.log('== generatePDF - force: %s', force); - if (force || !invoiceOld) { + if (force) { refreshTimer = null; } else { if (refreshTimer) { - clearTimeout(refreshTimer); + clearTimeout(refreshTimer); } refreshTimer = setTimeout(function() { generatePDF(invoice, javascript, true, cb); }, 500); - return pdfDoc; + return; } invoice = calculateAmounts(invoice); - var a = copyObject(invoice); - var b = copyObject(invoiceOld); - if (_.isEqual(a, b)) { - return pdfDoc; - } - invoiceOld = invoice; - pdfDoc = GetPdfMake(invoice, javascript, cb); + var pdfDoc = GetPdfMake(invoice, javascript, cb); if (cb) { pdfDoc.getDataUrl(cb); diff --git a/public/js/script.js b/public/js/script.js index 071faac66e..8749599e59 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -7,34 +7,26 @@ var isChrome = !!window.chrome && !isOpera && !isEdge; // Chrome 1+ var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0; var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 -var pdfDoc; -var invoiceOld; var refreshTimer; function generatePDF(invoice, javascript, force, cb) { if (!invoice || !javascript) { return; } //console.log('== generatePDF - force: %s', force); - if (force || !invoiceOld) { + if (force) { refreshTimer = null; } else { if (refreshTimer) { - clearTimeout(refreshTimer); + clearTimeout(refreshTimer); } refreshTimer = setTimeout(function() { generatePDF(invoice, javascript, true, cb); }, 500); - return pdfDoc; + return; } invoice = calculateAmounts(invoice); - var a = copyObject(invoice); - var b = copyObject(invoiceOld); - if (_.isEqual(a, b)) { - return pdfDoc; - } - invoiceOld = invoice; - pdfDoc = GetPdfMake(invoice, javascript, cb); + var pdfDoc = GetPdfMake(invoice, javascript, cb); if (cb) { pdfDoc.getDataUrl(cb); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index e62d9ab98c..850edec65e 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -735,11 +735,12 @@ $('.client-input').val(getClientDisplayName(selected)); // if there's an invoice number pattern we'll apply it now setInvoiceNumber(selected); + refreshPDF(true); } else if (oldId) { model.loadClient($.parseJSON(ko.toJSON(new ClientModel()))); model.invoice().client().country = false; + refreshPDF(true); } - refreshPDF(true); }); // If no clients exists show the client form when clicking on the client select input @@ -841,6 +842,7 @@ } @endif model.product_key(key); + onItemChange(); break; } } diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index 1fac09fe8a..92901846d5 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -128,7 +128,7 @@ function ViewModel(data) { var email = $("[name='client[contacts][0][email]']").val(); var firstName = $("[name='client[contacts][0][first_name]']").val(); var lastName = $("[name='client[contacts][0][last_name]']").val(); - var name = $('#name').val(); + var name = $("[name='client[name]']").val(); if (name) { // @@ -141,7 +141,7 @@ function ViewModel(data) { var isValid = true; $('input.client-email').each(function(item, value) { var email = $(value).val(); - if (!name && (!email || !isValidEmailAddress(email))) { + if (!first_name && (!email || !isValidEmailAddress(email))) { isValid = false; } }); diff --git a/storage/templates/modern.js b/storage/templates/modern.js index dd939edf74..2fc9c734be 100644 --- a/storage/templates/modern.js +++ b/storage/templates/modern.js @@ -9,7 +9,7 @@ }, { "stack": "$clientDetails", - "margin": [260, 80, 0, 0] + "margin": [0, 80, 0, 0] } ] },