Eliminate popup when downloading xml invoices.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex flex-row w-full">
|
||||
<div class="flex flex-row w-full" x-data="invoiceForm">
|
||||
<h2 class="grow font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
||||
{{ __('invoice.Invoice') }} {{ $invoice->number }} ({{ $invoice->localized_state }})
|
||||
</h2>
|
||||
@@ -8,7 +8,7 @@
|
||||
<x-pdf-icon class="text-gray-800 cursor-pointer"
|
||||
onclick="window.open('/invoice/{{ $invoice->id }}/pdf-download', '_blank', 'popup=true')"/>
|
||||
<x-e-icon class="cursor-pointer"
|
||||
onclick="window.open('/invoice/{{ $invoice->id }}/xml-download', '_blank', 'popup=true')"/>
|
||||
x-on:click="prepareXML"/>
|
||||
</p>
|
||||
</div>
|
||||
</x-slot>
|
||||
@@ -215,8 +215,33 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div id="download"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</x-app-layout>
|
||||
|
||||
<script>
|
||||
function invoiceForm() {
|
||||
return {
|
||||
prepareXML() {
|
||||
axios.get('/invoice/' + {{ $invoice->id }} + '/xml-download', {responseType: "blob"})
|
||||
.then(function(response) {
|
||||
let url = window.URL.createObjectURL(response.data);
|
||||
let a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = '{!! __('invoice.Invoice') !!} ' + '{{ $invoice->number }}' + '.xml';
|
||||
let download = document.querySelector('#download');
|
||||
download.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
console.log(response);
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user