Skip to content

Commit 174b683

Browse files
committed
add toogle event
1 parent 56d2f9a commit 174b683

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Http/Livewire/CsvImporter.php

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class CsvImporter extends Component
2121
/** @var string */
2222
public $model;
2323

24+
/** @var bool */
25+
public bool $open = false;
26+
2427
/** @var object */
2528
public $file;
2629

@@ -45,6 +48,11 @@ class CsvImporter extends Component
4548
'columnLabels', 'requiredColumns',
4649
];
4750

51+
/** @var array */
52+
protected $listeners = [
53+
'toogle',
54+
];
55+
4856
public function mount()
4957
{
5058
// map and coverts the columnsToMap property into an associative array
@@ -77,6 +85,11 @@ public function import()
7785
$this->emitTo('csv-imports', 'imports.refresh');
7886
}
7987

88+
public function toogle()
89+
{
90+
$this->open = ! $this->open;
91+
}
92+
8093
public function render()
8194
{
8295
return view(

tests/CsvImporterTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,16 @@
292292
$this->assertEquals(Customer::count(), 1000);
293293
$this->assertEquals($import->first()->processed_rows, 1000);
294294
});
295+
296+
it('toogles import button', function () {
297+
$this->actingAs(User::factory()->create());
298+
299+
$model = Customer::class;
300+
301+
livewire(CsvImporter::class, [
302+
'model' => $model
303+
])
304+
->emit('toogle')
305+
->assertSet('open', true)
306+
->assertHasNoErrors();
307+
});

0 commit comments

Comments
 (0)