-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Queue export with dependencies (#1362)
* Queue export with dependencies * Add test * Pint
- Loading branch information
1 parent
a6eaba9
commit 01151f6
Showing
10 changed files
with
140 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace PowerComponents\LivewirePowerGrid\Tests\Concerns\Components; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use PowerComponents\LivewirePowerGrid\Tests\Concerns\Models\Dish; | ||
use PowerComponents\LivewirePowerGrid\{ | ||
Column, | ||
Exportable, | ||
Footer, | ||
Header, | ||
PowerGrid, | ||
PowerGridComponent, | ||
PowerGridFields, | ||
Traits\WithExport | ||
}; | ||
|
||
class BatchExportTable extends PowerGridComponent | ||
{ | ||
use WithExport; | ||
|
||
public int $filterDataSourceId; | ||
|
||
public ?int $idFromBatch = null; | ||
|
||
public function setUp(): array | ||
{ | ||
return [ | ||
Exportable::make('export') | ||
->striped() | ||
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV) | ||
->queues(6), | ||
|
||
Header::make() | ||
->showSearchInput(), | ||
|
||
Footer::make() | ||
->showPerPage() | ||
->showRecordCount(), | ||
]; | ||
} | ||
|
||
public function datasource(array $parameters): Builder | ||
{ | ||
return Dish::with('category')->where('id', $parameters['filterDataSourceId'] ?? 1); | ||
} | ||
|
||
public function fields(): PowerGridFields | ||
{ | ||
return PowerGrid::fields() | ||
->add('id') | ||
->add('name'); | ||
} | ||
|
||
public function columns(): array | ||
{ | ||
return [ | ||
Column::add() | ||
->title(__('ID')) | ||
->field('id') | ||
->searchable() | ||
->sortable(), | ||
|
||
Column::add() | ||
->title('Dish') | ||
->field('name') | ||
->searchable() | ||
->sortable(), | ||
]; | ||
} | ||
|
||
public function bootstrap() | ||
{ | ||
config(['livewire-powergrid.theme' => 'bootstrap']); | ||
} | ||
|
||
public function tailwind() | ||
{ | ||
config(['livewire-powergrid.theme' => 'tailwind']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Bus\PendingBatch; | ||
use Illuminate\Support\Facades\Bus; | ||
use Livewire\Features\SupportTesting\Testable; | ||
|
||
use function Livewire\invade; | ||
|
||
use PowerComponents\LivewirePowerGrid\Tests\Concerns\Components\BatchExportTable; | ||
|
||
use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire; | ||
|
||
it('can pass class parameters in batch export.', function () { | ||
Bus::fake(); | ||
|
||
/** @var Testable $component */ | ||
$component = livewire(BatchExportTable::class, [ | ||
'filterDataSourceId' => 77, | ||
]) | ||
->call('exportToXLS', false); | ||
|
||
$getPublicPropertiesDefinedInComponent = $component->instance()->getPublicPropertiesDefinedInComponent(); | ||
|
||
Bus::assertBatched(function (PendingBatch $batch) use ($getPublicPropertiesDefinedInComponent) { | ||
$jobs = $batch->jobs[0]; | ||
|
||
$properties = invade($jobs[0])->properties; | ||
|
||
return $getPublicPropertiesDefinedInComponent['filterDataSourceId'] === | ||
$properties['filterDataSourceId']; | ||
}); | ||
})->requiresOpenSpout(); |