Add Excel export for participants
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
5bd6187f4a
commit
9f35111ae5
|
@ -15,22 +15,14 @@ class ExportAction
|
||||||
|
|
||||||
public function handle(Form $form): string
|
public function handle(Form $form): string
|
||||||
{
|
{
|
||||||
$csv = Writer::createFromString();
|
return CreateExcelDocumentAction::run($form, $form->participants);
|
||||||
|
|
||||||
$csv->insertOne($form->getFields()->names());
|
|
||||||
|
|
||||||
foreach ($form->participants as $participant) {
|
|
||||||
$csv->insertOne($participant->getFields()->presentValues());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $csv->toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(Form $form, ActionRequest $request): StreamedResponse
|
public function asController(Form $form, ActionRequest $request): StreamedResponse
|
||||||
{
|
{
|
||||||
$contents = $this->handle($form);
|
$contents = $this->handle($form);
|
||||||
|
|
||||||
$filename = 'tn-' . $form->slug . '.csv';
|
$filename = 'tn-' . $form->slug . '.xlsx';
|
||||||
Storage::disk('temp')->put($filename, $contents);
|
Storage::disk('temp')->put($filename, $contents);
|
||||||
|
|
||||||
return Storage::disk('temp')->download($filename);
|
return Storage::disk('temp')->download($filename);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "drop database scoutrobot;" | sudo mysql
|
echo "drop database scoutrobot;" | sudo mysql
|
||||||
echo "create database scoutrobot;" | sudo mysql
|
echo "create database scoutrobot;" | sudo mysql
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c1d0221dcd2b4200b3ff17747e31f451fcc749f0
|
Subproject commit 8aefd17b06ee3c26d00b472a154a48898b884d15
|
|
@ -175,7 +175,7 @@
|
||||||
<ui-action-button tooltip="Bearbeiten" class="btn-warning" icon="pencil" @click.prevent="edit(form)"></ui-action-button>
|
<ui-action-button tooltip="Bearbeiten" class="btn-warning" icon="pencil" @click.prevent="edit(form)"></ui-action-button>
|
||||||
<ui-action-button tooltip="Teilnehmende anzeigen" class="btn-info" icon="user" @click.prevent="showParticipants(form)"></ui-action-button>
|
<ui-action-button tooltip="Teilnehmende anzeigen" class="btn-info" icon="user" @click.prevent="showParticipants(form)"></ui-action-button>
|
||||||
<ui-action-button :href="form.links.frontend" target="_BLANK" tooltip="zur Anmeldeseite" class="btn-info" icon="eye"></ui-action-button>
|
<ui-action-button :href="form.links.frontend" target="_BLANK" tooltip="zur Anmeldeseite" class="btn-info" icon="eye"></ui-action-button>
|
||||||
<ui-action-button :href="form.links.export" target="_BLANK" tooltip="als CSV exportieren" class="btn-info" icon="document"></ui-action-button>
|
<ui-action-button :href="form.links.export" target="_BLANK" tooltip="als Tabellendokument exportieren" class="btn-info" icon="document"></ui-action-button>
|
||||||
<ui-action-button tooltip="Löschen" class="btn-danger" icon="trash" @click.prevent="deleting = form"></ui-action-button>
|
<ui-action-button tooltip="Löschen" class="btn-danger" icon="trash" @click.prevent="deleting = form"></ui-action-button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -2,12 +2,8 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Form;
|
namespace Tests\Feature\Form;
|
||||||
|
|
||||||
use App\Form\Fields\TextField;
|
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use App\Form\Scopes\ParticipantFilterScope;
|
|
||||||
use App\Group;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
@ -32,12 +28,12 @@ class ParticipantExportActionTest extends FormTestCase
|
||||||
->name('ZEM 2024')
|
->name('ZEM 2024')
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->get(route('form.export', ['form' => $form]))->assertDownload('tn-zem-2024.csv');
|
$this->get(route('form.export', ['form' => $form]))->assertDownload('tn-zem-2024.xlsx');
|
||||||
$contents = Storage::disk('temp')->get('tn-zem-2024.csv');
|
$contents = Storage::disk('temp')->get('tn-zem-2024.xlsx');
|
||||||
$this->assertTrue(str_contains($contents, 'Max'));
|
$this->assertExcelContent('Max', $contents);
|
||||||
$this->assertTrue(str_contains($contents, 'A, B'));
|
$this->assertExcelContent('A, B', $contents);
|
||||||
$this->assertTrue(str_contains($contents, 'Pfadfinder'));
|
$this->assertExcelContent('Pfadfinder', $contents);
|
||||||
$this->assertTrue(str_contains($contents, 'Stufe'));
|
$this->assertExcelContent('Stufe', $contents);
|
||||||
$this->assertTrue(str_contains($contents, 'Abcselect'));
|
$this->assertExcelContent('Abcselect', $contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,14 @@ use PHPUnit\Framework\Assert;
|
||||||
use Tests\Lib\MakesHttpCalls;
|
use Tests\Lib\MakesHttpCalls;
|
||||||
use Tests\Lib\TestsInertia;
|
use Tests\Lib\TestsInertia;
|
||||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||||
|
use Zoomyboy\TableDocument\TestsExcelDocuments;
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
use TestsInertia;
|
use TestsInertia;
|
||||||
use MakesHttpCalls;
|
use MakesHttpCalls;
|
||||||
|
use TestsExcelDocuments;
|
||||||
|
|
||||||
protected User $me;
|
protected User $me;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue