mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge pull request #2810 from FELDSAM-INC/feature/option-to-disable-relatime-preview
Option to disable PDF realtime preview
This commit is contained in:
commit
694de222a7
@ -820,6 +820,7 @@ class AccountController extends BaseController
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$account->live_preview = Input::get('live_preview') ? true : false;
|
$account->live_preview = Input::get('live_preview') ? true : false;
|
||||||
|
$account->realtime_preview = Input::get('realtime_preview') ? true : false;
|
||||||
|
|
||||||
// Automatically disable live preview when using a large font
|
// Automatically disable live preview when using a large font
|
||||||
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
|
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
|
||||||
|
@ -127,6 +127,7 @@ class Account extends Eloquent
|
|||||||
'enable_client_portal_dashboard',
|
'enable_client_portal_dashboard',
|
||||||
'page_size',
|
'page_size',
|
||||||
'live_preview',
|
'live_preview',
|
||||||
|
'realtime_preview',
|
||||||
'invoice_number_padding',
|
'invoice_number_padding',
|
||||||
'enable_second_tax_rate',
|
'enable_second_tax_rate',
|
||||||
'auto_bill_on_due_date',
|
'auto_bill_on_due_date',
|
||||||
|
@ -352,6 +352,7 @@ class AccountTransformer extends EntityTransformer
|
|||||||
'enable_client_portal_dashboard' => (bool) $account->enable_client_portal_dashboard,
|
'enable_client_portal_dashboard' => (bool) $account->enable_client_portal_dashboard,
|
||||||
'page_size' => $account->page_size,
|
'page_size' => $account->page_size,
|
||||||
'live_preview' => (bool) $account->live_preview,
|
'live_preview' => (bool) $account->live_preview,
|
||||||
|
'realtime_preview' => (bool) $account->realtime_preview,
|
||||||
'invoice_number_padding' => (int) $account->invoice_number_padding,
|
'invoice_number_padding' => (int) $account->invoice_number_padding,
|
||||||
'enable_second_tax_rate' => (bool) $account->enable_second_tax_rate,
|
'enable_second_tax_rate' => (bool) $account->enable_second_tax_rate,
|
||||||
'auto_bill_on_due_date' => (bool) $account->auto_bill_on_due_date,
|
'auto_bill_on_due_date' => (bool) $account->auto_bill_on_due_date,
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddRealtimePreviewToAccounts extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function ($table) {
|
||||||
|
$table->boolean('realtime_preview')->after('live_preview')->default(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function ($table) {
|
||||||
|
$table->dropColumn('realtime_preview');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -2041,7 +2041,9 @@ $LANG = array(
|
|||||||
'update_credit' => 'Update Credit',
|
'update_credit' => 'Update Credit',
|
||||||
'updated_credit' => 'Successfully updated credit',
|
'updated_credit' => 'Successfully updated credit',
|
||||||
'edit_credit' => 'Edit Credit',
|
'edit_credit' => 'Edit Credit',
|
||||||
'live_preview_help' => 'Display a live PDF preview on the invoice page.<br/>Disable this to improve performance when editing invoices.',
|
'realtime_preview' => 'Realtime Preview',
|
||||||
|
'realtime_preview_help' => 'Realtime refresh PDF preview on the invoice page when editing invoice.<br/>Disable this to improve performance when editing invoices.',
|
||||||
|
'live_preview_help' => 'Display a live PDF preview on the invoice page.',
|
||||||
'force_pdfjs_help' => 'Replace the built-in PDF viewer in :chrome_link and :firefox_link.<br/>Enable this if your browser is automatically downloading the PDF.',
|
'force_pdfjs_help' => 'Replace the built-in PDF viewer in :chrome_link and :firefox_link.<br/>Enable this if your browser is automatically downloading the PDF.',
|
||||||
'force_pdfjs' => 'Prevent Download',
|
'force_pdfjs' => 'Prevent Download',
|
||||||
'redirect_url' => 'Redirect URL',
|
'redirect_url' => 'Redirect URL',
|
||||||
|
@ -172,6 +172,7 @@
|
|||||||
|
|
||||||
{!! Former::open('settings/account_management') !!}
|
{!! Former::open('settings/account_management') !!}
|
||||||
{!! Former::populateField('live_preview', intval($account->live_preview)) !!}
|
{!! Former::populateField('live_preview', intval($account->live_preview)) !!}
|
||||||
|
{!! Former::populateField('realtime_preview', intval($account->realtime_preview)) !!}
|
||||||
{!! Former::populateField('force_pdfjs', intval(Auth::user()->force_pdfjs)) !!}
|
{!! Former::populateField('force_pdfjs', intval(Auth::user()->force_pdfjs)) !!}
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
@ -221,6 +222,11 @@
|
|||||||
->help(trans('texts.live_preview_help') . '<br/>' . trans('texts.recommend_on'))
|
->help(trans('texts.live_preview_help') . '<br/>' . trans('texts.recommend_on'))
|
||||||
->value(1) !!}
|
->value(1) !!}
|
||||||
|
|
||||||
|
{!! Former::checkbox('realtime_preview')
|
||||||
|
->text(trans('texts.enable'))
|
||||||
|
->help(trans('texts.realtime_preview_help'))
|
||||||
|
->value(1) !!}
|
||||||
|
|
||||||
{!! Former::checkbox('force_pdfjs')
|
{!! Former::checkbox('force_pdfjs')
|
||||||
->text(trans('texts.enable'))
|
->text(trans('texts.enable'))
|
||||||
->value(1)
|
->value(1)
|
||||||
@ -378,6 +384,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCheckboxes() {
|
||||||
|
var checked = $('#live_preview').is(':checked');
|
||||||
|
$('#realtime_preview').prop('disabled', ! checked);
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
function updatePlanModal() {
|
function updatePlanModal() {
|
||||||
var plan = $('#plan').val();
|
var plan = $('#plan').val();
|
||||||
@ -407,6 +418,9 @@
|
|||||||
updatePlanModal();
|
updatePlanModal();
|
||||||
onPlanChange();
|
onPlanChange();
|
||||||
|
|
||||||
|
$('#live_preview').change(updateCheckboxes);
|
||||||
|
updateCheckboxes();
|
||||||
|
|
||||||
if(window.location.hash) {
|
if(window.location.hash) {
|
||||||
var hash = window.location.hash;
|
var hash = window.location.hash;
|
||||||
$(hash).modal('toggle');
|
$(hash).modal('toggle');
|
||||||
|
@ -550,6 +550,10 @@
|
|||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
@if (!$invoice->is_deleted)
|
@if (!$invoice->is_deleted)
|
||||||
|
@if ( ! Auth::user()->account->realtime_preview && Auth::user()->account->live_preview)
|
||||||
|
{!! Button::normal('PDF')->withAttributes(['id' => 'refreshPdfButton', 'onclick' => 'refreshPDF(true,true)'])->appendIcon(Icon::create('refresh')) !!}
|
||||||
|
@endif
|
||||||
|
|
||||||
@if ($invoice->isSent())
|
@if ($invoice->isSent())
|
||||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||||
@else
|
@else
|
||||||
@ -577,7 +581,7 @@
|
|||||||
|
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
@include('invoices.pdf', ['account' => Auth::user()->account, 'hide_pdf' => ! Auth::user()->account->live_preview])
|
@include('invoices.pdf', ['account' => Auth::user()->account, 'hide_pdf' => ! Auth::user()->account->live_preview, 'realtime_preview' => Auth::user()->account->realtime_preview])
|
||||||
|
|
||||||
@if (!Auth::user()->account->isPro())
|
@if (!Auth::user()->account->isPro())
|
||||||
<div style="font-size:larger">
|
<div style="font-size:larger">
|
||||||
@ -1026,11 +1030,11 @@
|
|||||||
$('.client-input').val(getClientDisplayName(selected));
|
$('.client-input').val(getClientDisplayName(selected));
|
||||||
// if there's an invoice number pattern we'll apply it now
|
// if there's an invoice number pattern we'll apply it now
|
||||||
setInvoiceNumber(selected);
|
setInvoiceNumber(selected);
|
||||||
refreshPDF(true);
|
refreshPDF(true, true);
|
||||||
} else if (oldId) {
|
} else if (oldId) {
|
||||||
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
||||||
model.invoice().client().country = false;
|
model.invoice().client().country = false;
|
||||||
refreshPDF(true);
|
refreshPDF(true, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1092,7 +1096,7 @@
|
|||||||
@if ($invoice->client->id)
|
@if ($invoice->client->id)
|
||||||
$input.trigger('change');
|
$input.trigger('change');
|
||||||
@else
|
@else
|
||||||
refreshPDF(true);
|
refreshPDF(true, true);
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
var client = model.invoice().client();
|
var client = model.invoice().client();
|
||||||
|
@ -112,7 +112,12 @@
|
|||||||
var isRefreshing = false;
|
var isRefreshing = false;
|
||||||
var needsRefresh = false;
|
var needsRefresh = false;
|
||||||
|
|
||||||
function refreshPDF(force) {
|
function refreshPDF(force, manual) {
|
||||||
|
@if (isset($realtime_preview) && ! $realtime_preview)
|
||||||
|
if (manual !== true) return;
|
||||||
|
$('#refreshPdfButton').attr('disabled', true);
|
||||||
|
@endif
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getPDFString(refreshPDFCB, force);
|
return getPDFString(refreshPDFCB, force);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
@ -179,6 +184,9 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@if (isset($realtime_preview) && ! $realtime_preview)
|
||||||
|
$('#refreshPdfButton').attr('disabled', false);
|
||||||
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMoreDesigns() {
|
function showMoreDesigns() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user