Skip to content

Commit

Permalink
updated export action
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Becker committed Nov 20, 2024
1 parent 46e56be commit 5192a83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"require": {
"php" : "^8.0",
"spatie/laravel-package-tools": "^1.0|^1.13",
"maatwebsite/excel": "^3.1"
"maatwebsite/excel": "^3.1",
"filament/filament": "^3.2"
}
}
28 changes: 14 additions & 14 deletions src/Actions/ReportExportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ protected function setUp(): void

$query = $exporter::modifyQuery($query);

$options = array_merge(
$action->getOptions(),
Arr::except($data, ['columnMap']),
);

if ($this->modifyQueryUsing) {
$query = $this->evaluate($this->modifyQueryUsing, [
'query' => $query,
'options' => $options,
]) ?? $query;
}

Expand All @@ -69,11 +75,6 @@ protected function setUp(): void

$user = auth()->user();

$options = array_merge(
$action->getOptions(),
Arr::except($data, ['columnMap']),
);

if ($action->hasColumnMapping()) {
$columnMap = collect($data['columnMap'])
->dot()
Expand Down Expand Up @@ -132,14 +133,14 @@ protected function setUp(): void
]);

Bus::chain([
Bus::batch([new $job(
$export,
query: $serializedQuery,
columnMap: $columnMap,
options: $options,
chunkSize: $action->getChunkSize(),
records: $action instanceof ExportTableBulkAction ? $action->getRecords()->all() : null,
)])
Bus::batch([app($job, [
'export' => $export,
'query' => $serializedQuery,
'columnMap' => $columnMap,
'options' => $options,
'chunkSize' => $action->getChunkSize(),
'records' => $action instanceof ExportTableBulkAction ? $action->getRecords()->all() : null,
])])
->when(
filled($jobQueue),
fn (PendingBatch $batch) => $batch->onQueue($jobQueue),
Expand Down Expand Up @@ -177,7 +178,6 @@ protected function setUp(): void
->body(trans_choice('filament-actions::export.notifications.started.body', $export->total_rows, [
'count' => Number::format($export->total_rows),
]))
->duration(2000)
->success()
->send();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/ReportResource/Pages/ViewReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\Str;
use Wjbecker\FilamentReportBuilder\Actions\ReportExportAction;
use Wjbecker\FilamentReportBuilder\Exports\Jobs\PrepareCsvExport;
use Wjbecker\FilamentReportBuilder\Exports\ReportExporter;
use Wjbecker\FilamentReportBuilder\Resources\ReportResource;
use Wjbecker\FilamentReportBuilder\Models\Report;
Expand Down Expand Up @@ -40,6 +39,7 @@ protected function getHeaderActions(): array
return [
ReportExportAction::make()->label('Export')
->exporter(ReportExporter::class)
->chunkSize(1000)
->record($this->record)
->columnMapping(false)
->fileName(function() {
Expand Down

0 comments on commit 5192a83

Please sign in to comment.