Add button to export members
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2023-03-15 00:08:20 +01:00
parent 86590f93a5
commit 8669199b1a
4 changed files with 20 additions and 8 deletions

View File

@ -16,7 +16,7 @@ class ExportAction
use AsAction; use AsAction;
/** /**
* @param Collection<int, Member> * @param Collection<int, Member> $members
*/ */
public function handle(Collection $members): string public function handle(Collection $members): string
{ {
@ -31,9 +31,9 @@ class ExportAction
$member->address, $member->address,
$member->zip, $member->zip,
$member->location, $member->location,
$member->mainPhone, $member->main_phone,
$member->mobilePhone, $member->mobile_phone,
$member->workPhone, $member->work_phone,
]); ]);
} }

View File

@ -7,11 +7,16 @@ export default {
props: { props: {
data: {}, data: {},
}, },
computed: {
filterString() {
return btoa(JSON.stringify(this.inner.meta.filter));
},
},
methods: { methods: {
reload(resetPage = true) { reload(resetPage = true) {
var _self = this; var _self = this;
var data = { var data = {
filter: btoa(JSON.stringify(this.inner.meta.filter)), filter: this.filterString,
page: 1, page: 1,
}; };
@ -50,4 +55,3 @@ export default {
}, },
}, },
}; };

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="pb-6"> <div class="pb-6">
<div class="px-6 py-2 flex border-b border-gray-600 space-x-3"> <div class="px-6 py-2 flex border-b border-gray-600 items-center space-x-3">
<f-switch v-show="hasModule('bill')" id="ausstand" @input="setFilter('ausstand', $event)" :items="getFilter('ausstand')" label="Nur Ausstände" size="sm"></f-switch> <f-switch v-show="hasModule('bill')" id="ausstand" @input="setFilter('ausstand', $event)" :items="getFilter('ausstand')" label="Nur Ausstände" size="sm"></f-switch>
<f-select <f-select
v-show="hasModule('bill')" v-show="hasModule('bill')"
@ -30,6 +30,10 @@
size="sm" size="sm"
name="subactivity_id" name="subactivity_id"
></f-select> ></f-select>
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
<svg-sprite class="w-3 h-3 xl:mr-2" src="save"></svg-sprite>
<span class="hidden xl:inline">Exportieren</span>
</button>
</div> </div>
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table"> <table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table">
@ -132,6 +136,9 @@ export default {
}, },
methods: { methods: {
exportMembers() {
window.open(`/member-export?filter=${this.filterString}`);
},
remove(member) { remove(member) {
if (window.confirm('Mitglied löschen?')) { if (window.confirm('Mitglied löschen?')) {
this.$inertia.delete(`/member/${member.id}`); this.$inertia.delete(`/member/${member.id}`);

View File

@ -19,7 +19,7 @@ class ExportCsvActionTest extends TestCase
Storage::fake('temp'); Storage::fake('temp');
$this->withoutExceptionHandling()->login()->loginNami(); $this->withoutExceptionHandling()->login()->loginNami();
Member::factory()->defaults()->postBillKind()->create(['firstname' => 'Jane']); Member::factory()->defaults()->postBillKind()->create(['firstname' => 'Jane', 'main_phone' => '+49 176 70343221']);
Member::factory()->defaults()->emailBillKind()->create(['firstname' => 'Max']); Member::factory()->defaults()->emailBillKind()->create(['firstname' => 'Max']);
$response = $this->callFilter('member-export', ['bill_kind' => 'Post']); $response = $this->callFilter('member-export', ['bill_kind' => 'Post']);
@ -27,6 +27,7 @@ class ExportCsvActionTest extends TestCase
$response->assertDownload('mitglieder.csv'); $response->assertDownload('mitglieder.csv');
$contents = Storage::disk('temp')->get('mitglieder.csv'); $contents = Storage::disk('temp')->get('mitglieder.csv');
$this->assertTrue(str_contains($contents, 'Jane')); $this->assertTrue(str_contains($contents, 'Jane'));
$this->assertTrue(str_contains($contents, '+49 176 70343221'));
$this->assertFalse(str_contains($contents, 'Max')); $this->assertFalse(str_contains($contents, 'Max'));
} }
} }