Merge pull request #6098 from devansh-webkul/datagrid-export
Export Fixed
This commit is contained in:
commit
eff1410800
|
|
@ -1,9 +1,14 @@
|
|||
<script type="text/x-template" id="export-form-template">
|
||||
<script
|
||||
type="text/x-template"
|
||||
id="export-form-template"
|
||||
>
|
||||
<form method="POST" action="{{ route('admin.datagrid.export', ['locale' => core()->getRequestedLocaleCode()]) }}" @submit.prevent="onSubmit">
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<input type="hidden" name="datagridUrl" :value="datagridUrl">
|
||||
|
||||
<input type="hidden" name="gridName" value="{{ get_class($gridName) }}">
|
||||
|
||||
<div class="control-group">
|
||||
|
|
@ -29,16 +34,67 @@
|
|||
Vue.component('export-form', {
|
||||
template: '#export-form-template',
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
id: btoa("{{ url()->current() }}"),
|
||||
datagridUrl: "{{ url()->current() }}"
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
this.datagridUrl = this.getCurrentDatagridInfo() ? this.getCurrentDatagridInfo()?.previousUrl : "{{ url()->current() }}";
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSubmit: function(e) {
|
||||
var self = this;
|
||||
let self = this;
|
||||
|
||||
e.target.submit();
|
||||
|
||||
setTimeout(function() {
|
||||
self.$root.$set(self.$root.modalIds, 'downloadDataGrid', false);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
getDatagridsInfoStorageKey: function() {
|
||||
return 'datagridsInfo';
|
||||
},
|
||||
|
||||
getCurrentDatagridInfo: function() {
|
||||
let datagridsInfo = this.getDatagridsInfo();
|
||||
|
||||
return this.isCurrentDatagridInfoExists() ?
|
||||
datagridsInfo.find(({
|
||||
id
|
||||
}) => id === this.id) :
|
||||
null;
|
||||
},
|
||||
|
||||
getDatagridsInfo: function() {
|
||||
let storageInfo = localStorage.getItem(
|
||||
this.getDatagridsInfoStorageKey()
|
||||
);
|
||||
|
||||
return !this.isValidJsonString(storageInfo) ? [] :
|
||||
JSON.parse(storageInfo) ?? [];
|
||||
},
|
||||
|
||||
isValidJsonString: function(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
isCurrentDatagridInfoExists: function() {
|
||||
let datagridsInfo = this.getDatagridsInfo();
|
||||
|
||||
return !!datagridsInfo.find(({
|
||||
id
|
||||
}) => id === this.id);
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait ProvideQueryStringParser
|
|||
{
|
||||
$route = request()->route() ? request()->route()->getName() : '';
|
||||
|
||||
$queryString = $this->grabQueryStrings($route == 'admin.datagrid.export' ? url()->previous() : url()->full());
|
||||
$queryString = $this->grabQueryStrings($route == 'admin.datagrid.export' ? request()->get('datagridUrl') : url()->full());
|
||||
|
||||
$parsedQueryStrings = $this->parseQueryStrings($queryString);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue