mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Proposals
This commit is contained in:
parent
ff53cd62e6
commit
91e8426e86
@ -4,6 +4,7 @@ namespace App\Http\ViewComposers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use App\Models\ProposalSnippet;
|
||||
use App\Models\Document;
|
||||
|
||||
/**
|
||||
* ClientPortalHeaderComposer.php.
|
||||
@ -27,5 +28,21 @@ class ProposalComposer
|
||||
->get();
|
||||
|
||||
$view->with('snippets', $snippets);
|
||||
|
||||
|
||||
$documents = Document::scope()
|
||||
->whereNull('invoice_id')
|
||||
->whereNull('expense_id')
|
||||
->get();
|
||||
|
||||
$data = [];
|
||||
foreach ($documents as $document) {
|
||||
$data[] = [
|
||||
'src' => $document->getUrl(),
|
||||
'public_id' => $document->public_id,
|
||||
];
|
||||
}
|
||||
|
||||
$view->with('documents', $data);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class ProposalTemplatesSeeder extends Seeder
|
||||
$htmlFileName = $baseFileName . '.html';
|
||||
$cssFileName = $baseFileName . '.css';
|
||||
if (file_exists($htmlFileName) && file_exists($cssFileName)) {
|
||||
$template = ProposalTemplate::whereName($design)->whereAccountId(0)->first();
|
||||
$template = ProposalTemplate::whereName($design)->whereNull('account_id')->first();
|
||||
|
||||
if (! $template) {
|
||||
$template = new ProposalTemplate();
|
||||
|
@ -2738,6 +2738,12 @@ $LANG = array(
|
||||
'proposal_message' => 'To view your proposal for :amount, click the link below.',
|
||||
'emailed_proposal' => 'Successfully emailed proposal',
|
||||
'load_template' => 'Load Template',
|
||||
'no_assets' => 'No images, drag to upload',
|
||||
'add_image' => 'Add Image',
|
||||
'select_image' => 'Select Image',
|
||||
'upgrade_to_upload_images' => 'Upgrade to the enterprise plan to upload images',
|
||||
'delete_image' => 'Delete Image',
|
||||
'delete_image_help' => 'Warning: deleting the image will remove it from all proposals.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -109,7 +109,7 @@
|
||||
}
|
||||
|
||||
// http://t4t5.github.io/sweetalert/
|
||||
function sweetConfirm(success, text, title) {
|
||||
function sweetConfirm(successCallback, text, title, cancelCallback) {
|
||||
title = title || "{!! trans("texts.are_you_sure") !!}";
|
||||
swal({
|
||||
//type: "warning",
|
||||
@ -122,8 +122,12 @@
|
||||
closeOnConfirm: false,
|
||||
allowOutsideClick: true,
|
||||
}).then(function() {
|
||||
success();
|
||||
successCallback();
|
||||
swal.close();
|
||||
}).catch(function() {
|
||||
if (cancelCallback) {
|
||||
cancelCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,17 @@ $(function() {
|
||||
type: 'none'
|
||||
},
|
||||
assetManager: {
|
||||
assets: [],
|
||||
noAssets: 'no assets TODO',
|
||||
assets: {!! json_encode($documents) !!},
|
||||
noAssets: "{{ trans('texts.no_assets') }}",
|
||||
addBtnText: "{{ trans('texts.add_image') }}",
|
||||
modalTitle: "{{ trans('texts.select_image') }}",
|
||||
@if (Utils::isSelfHost() || $account->isEnterprise())
|
||||
upload: {!! json_encode(url('/documents')) !!},
|
||||
uploadText: "{{ trans('texts.dropzone_default_message') }}",
|
||||
@else
|
||||
upload: false,
|
||||
uploadText: "{{ trans('texts.upgrade_to_upload_images') }}",
|
||||
@endif
|
||||
uploadName: 'files',
|
||||
params: {
|
||||
'_token': '{{ Session::getToken() }}',
|
||||
@ -56,6 +64,21 @@ $(function() {
|
||||
NINJA.formIsChanged = true;
|
||||
});
|
||||
|
||||
grapesjsEditor.on('asset:remove', function(asset) {
|
||||
sweetConfirm(function() {
|
||||
$.ajax({
|
||||
url: "{{ url('/documents') }}/" + asset.attributes.public_id,
|
||||
type: 'DELETE',
|
||||
success: function(result) {
|
||||
console.log('result: %s', result);
|
||||
}
|
||||
});
|
||||
}, "{{ trans('texts.delete_image_help') }}", "{{ trans('texts.delete_image') }}", function() {
|
||||
var assetManager = grapesjsEditor.AssetManager;
|
||||
assetManager.add([asset.attributes]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user