mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01: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();
|
||||
|
||||
$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
|
||||
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
|
||||
|
@ -127,6 +127,7 @@ class Account extends Eloquent
|
||||
'enable_client_portal_dashboard',
|
||||
'page_size',
|
||||
'live_preview',
|
||||
'realtime_preview',
|
||||
'invoice_number_padding',
|
||||
'enable_second_tax_rate',
|
||||
'auto_bill_on_due_date',
|
||||
|
@ -352,6 +352,7 @@ class AccountTransformer extends EntityTransformer
|
||||
'enable_client_portal_dashboard' => (bool) $account->enable_client_portal_dashboard,
|
||||
'page_size' => $account->page_size,
|
||||
'live_preview' => (bool) $account->live_preview,
|
||||
'realtime_preview' => (bool) $account->realtime_preview,
|
||||
'invoice_number_padding' => (int) $account->invoice_number_padding,
|
||||
'enable_second_tax_rate' => (bool) $account->enable_second_tax_rate,
|
||||
'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',
|
||||
'updated_credit' => 'Successfully updated 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' => 'Prevent Download',
|
||||
'redirect_url' => 'Redirect URL',
|
||||
|
@ -172,6 +172,7 @@
|
||||
|
||||
{!! Former::open('settings/account_management') !!}
|
||||
{!! 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)) !!}
|
||||
|
||||
<div class="panel panel-default">
|
||||
@ -221,6 +222,11 @@
|
||||
->help(trans('texts.live_preview_help') . '<br/>' . trans('texts.recommend_on'))
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('realtime_preview')
|
||||
->text(trans('texts.enable'))
|
||||
->help(trans('texts.realtime_preview_help'))
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('force_pdfjs')
|
||||
->text(trans('texts.enable'))
|
||||
->value(1)
|
||||
@ -378,6 +384,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
function updateCheckboxes() {
|
||||
var checked = $('#live_preview').is(':checked');
|
||||
$('#realtime_preview').prop('disabled', ! checked);
|
||||
}
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
function updatePlanModal() {
|
||||
var plan = $('#plan').val();
|
||||
@ -407,6 +418,9 @@
|
||||
updatePlanModal();
|
||||
onPlanChange();
|
||||
|
||||
$('#live_preview').change(updateCheckboxes);
|
||||
updateCheckboxes();
|
||||
|
||||
if(window.location.hash) {
|
||||
var hash = window.location.hash;
|
||||
$(hash).modal('toggle');
|
||||
|
@ -550,6 +550,10 @@
|
||||
@endif
|
||||
@else
|
||||
@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())
|
||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
@else
|
||||
@ -577,7 +581,7 @@
|
||||
|
||||
</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())
|
||||
<div style="font-size:larger">
|
||||
@ -1026,11 +1030,11 @@
|
||||
$('.client-input').val(getClientDisplayName(selected));
|
||||
// if there's an invoice number pattern we'll apply it now
|
||||
setInvoiceNumber(selected);
|
||||
refreshPDF(true);
|
||||
refreshPDF(true, true);
|
||||
} else if (oldId) {
|
||||
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
||||
model.invoice().client().country = false;
|
||||
refreshPDF(true);
|
||||
refreshPDF(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1092,7 +1096,7 @@
|
||||
@if ($invoice->client->id)
|
||||
$input.trigger('change');
|
||||
@else
|
||||
refreshPDF(true);
|
||||
refreshPDF(true, true);
|
||||
@endif
|
||||
|
||||
var client = model.invoice().client();
|
||||
|
@ -112,7 +112,12 @@
|
||||
var isRefreshing = 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 {
|
||||
return getPDFString(refreshPDFCB, force);
|
||||
} catch (exception) {
|
||||
@ -179,6 +184,9 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
@if (isset($realtime_preview) && ! $realtime_preview)
|
||||
$('#refreshPdfButton').attr('disabled', false);
|
||||
@endif
|
||||
}
|
||||
|
||||
function showMoreDesigns() {
|
||||
|
Loading…
Reference in New Issue
Block a user