Fix: Allow umlauts in Contribution generator
This commit is contained in:
parent
50d98c0335
commit
97668add7e
|
@ -49,6 +49,6 @@ class GenerateAction
|
|||
*/
|
||||
private function payload(ActionRequest $request): array
|
||||
{
|
||||
return json_decode(base64_decode($request->input('payload', '')), true);
|
||||
return json_decode(urldecode(base64_decode($request->input('payload', ''))), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@ class JsonBase64Rule implements Rule
|
|||
return false;
|
||||
}
|
||||
|
||||
if (base64_encode(base64_decode($value, true)) !== $value) {
|
||||
$decoded = urldecode(base64_decode($value, true));
|
||||
|
||||
if (base64_encode(urlencode($decoded)) !== $value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array(json_decode(base64_decode($value), true))) {
|
||||
if (!is_array(json_decode($decoded, true))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +1,31 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<form target="_BLANK" class="max-w-4xl w-full mx-auto gap-6 grid-cols-2 grid p-6">
|
||||
<f-text id="eventName" name="eventName" class="col-span-2" v-model="values.eventName" label="Veranstaltungs-Name" required></f-text>
|
||||
<f-text id="dateFrom" name="dateFrom" type="date" v-model="values.dateFrom" label="Datum von" required></f-text>
|
||||
<f-text id="dateUntil" name="dateUntil" type="date" v-model="values.dateUntil" label="Datum bis" required></f-text>
|
||||
<f-text id="eventName" v-model="values.eventName" name="eventName" class="col-span-2"
|
||||
label="Veranstaltungs-Name" required></f-text>
|
||||
<f-text id="dateFrom" v-model="values.dateFrom" name="dateFrom" type="date" label="Datum von" required></f-text>
|
||||
<f-text id="dateUntil" v-model="values.dateUntil" name="dateUntil" type="date" label="Datum bis"
|
||||
required></f-text>
|
||||
|
||||
<f-text id="zipLocation" name="zipLocation" v-model="values.zipLocation" label="PLZ / Ort" required></f-text>
|
||||
<f-select id="country" :options="countries" name="country" v-model="values.country" label="Land" required></f-select>
|
||||
<f-text id="zipLocation" v-model="values.zipLocation" name="zipLocation" label="PLZ / Ort" required></f-text>
|
||||
<f-select id="country" v-model="values.country" :options="countries" name="country" label="Land"
|
||||
required></f-select>
|
||||
|
||||
<div class="border-gray-200 shadow shadow-primary-700 p-3 shadow-[0_0_4px_gray] col-span-2">
|
||||
<f-text
|
||||
class="col-span-2"
|
||||
id="search_text"
|
||||
name="search_text"
|
||||
v-model="searchText"
|
||||
label="Suchen …"
|
||||
size="sm"
|
||||
ref="search_text_field"
|
||||
@keypress.enter.prevent="onSubmitFirstMemberResult"
|
||||
></f-text>
|
||||
<f-text id="search_text" ref="search_text_field" v-model="searchText" class="col-span-2" name="search_text"
|
||||
label="Suchen …" size="sm" @keypress.enter.prevent="onSubmitFirstMemberResult"></f-text>
|
||||
<div class="mt-2 grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2 col-span-2">
|
||||
<f-switch
|
||||
:id="`members-${member.id}`"
|
||||
:key="member.id"
|
||||
:label="`${member.firstname} ${member.lastname}`"
|
||||
v-for="member in search.results"
|
||||
name="members[]"
|
||||
:value="member.id"
|
||||
v-model="values.members"
|
||||
size="sm"
|
||||
@keypress.enter.prevent="onSubmitMemberResult(member)"
|
||||
inline
|
||||
></f-switch>
|
||||
<f-switch v-for="member in search.results" :id="`members-${member.id}`" :key="member.id"
|
||||
v-model="values.members" :label="`${member.firstname} ${member.lastname}`" name="members[]"
|
||||
:value="member.id" size="sm" inline
|
||||
@keypress.enter.prevent="onSubmitMemberResult(member)"></f-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-for="(compiler, index) in compilers"
|
||||
@click.prevent="
|
||||
values.type = compiler.class;
|
||||
submit();
|
||||
"
|
||||
class="btn btn-primary mt-3 inline-block"
|
||||
v-text="compiler.title"
|
||||
></button>
|
||||
<button v-for="(compiler, index) in compilers" class="btn btn-primary mt-3 inline-block" @click.prevent="
|
||||
values.type = compiler.class;
|
||||
submit();
|
||||
" v-text="compiler.title"></button>
|
||||
</form>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
@ -52,6 +34,11 @@
|
|||
import debounce from 'lodash/debounce';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
data: {},
|
||||
countries: {},
|
||||
compilers: {},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
search: {
|
||||
|
@ -70,11 +57,6 @@ export default {
|
|||
},
|
||||
};
|
||||
},
|
||||
props: {
|
||||
data: {},
|
||||
countries: {},
|
||||
compilers: {},
|
||||
},
|
||||
computed: {
|
||||
searchText: {
|
||||
get() {
|
||||
|
@ -99,7 +81,7 @@ export default {
|
|||
async submit() {
|
||||
try {
|
||||
await this.axios.post('/contribution-validate', this.values);
|
||||
var payload = btoa(JSON.stringify(this.values));
|
||||
var payload = btoa(encodeURIComponent(JSON.stringify(this.values)));
|
||||
window.open(`/contribution-generate?payload=${payload}`);
|
||||
} catch (e) {
|
||||
this.errorsFromException(e);
|
||||
|
|
|
@ -36,20 +36,18 @@ class StoreTest extends TestCase
|
|||
$this->withoutExceptionHandling();
|
||||
Tex::spy();
|
||||
$this->login()->loginNami();
|
||||
$country = Country::factory()->create();
|
||||
$member1 = Member::factory()->defaults()->for(Gender::factory())->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||
$member2 = Member::factory()->defaults()->for(Gender::factory())->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||
|
||||
$response = $this->call('GET', '/contribution-generate', [
|
||||
'payload' => base64_encode(json_encode([
|
||||
'country' => $country->id,
|
||||
'payload' => ContributionRequestFactory::new()->type($type)->state([
|
||||
'dateFrom' => '1991-06-15',
|
||||
'dateUntil' => '1991-06-16',
|
||||
'eventName' => 'Super tolles Lager',
|
||||
'members' => [$member1->id, $member2->id],
|
||||
'type' => $type,
|
||||
'zipLocation' => '42777 SG',
|
||||
])),
|
||||
])->toBase64(),
|
||||
]);
|
||||
|
||||
$response->assertSessionDoesntHaveErrors();
|
||||
|
@ -61,22 +59,10 @@ class StoreTest extends TestCase
|
|||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Tex::spy();
|
||||
$member = Member::factory()->defaults()->for(Gender::factory())->create();
|
||||
|
||||
InvoiceSettings::fake([
|
||||
'from_long' => 'Stamm BiPi',
|
||||
]);
|
||||
InvoiceSettings::fake(['from_long' => 'Stamm BiPi']);
|
||||
|
||||
$this->call('GET', '/contribution-generate', [
|
||||
'payload' => base64_encode(json_encode([
|
||||
'country' => Country::factory()->create()->id,
|
||||
'dateFrom' => '1991-06-15',
|
||||
'dateUntil' => '1991-06-16',
|
||||
'eventName' => 'Super tolles Lager',
|
||||
'members' => [$member->id],
|
||||
'type' => CitySolingenDocument::class,
|
||||
'zipLocation' => '42777 SG',
|
||||
])),
|
||||
'payload' => ContributionRequestFactory::new()->type(CitySolingenDocument::class)->toBase64(),
|
||||
]);
|
||||
|
||||
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Stamm BiPi']));
|
||||
|
|
|
@ -15,11 +15,11 @@ class ContributionRequestFactory extends RequestFactory
|
|||
$compilers = collect(app(ContributionFactory::class)->compilerSelect())->pluck('class');
|
||||
|
||||
return [
|
||||
'country' => $this->faker->randomElement(Country::get())->id,
|
||||
'country' => Country::factory()->create()->id,
|
||||
'dateFrom' => $this->faker->date(),
|
||||
'dateUntil' => $this->faker->date(),
|
||||
'eventName' => $this->faker->words(3, true),
|
||||
'members' => [$this->faker->randomElement(Member::get())->id],
|
||||
'members' => [Member::factory()->defaults()->create()->id],
|
||||
'type' => $this->faker->randomElement($compilers),
|
||||
'zipLocation' => $this->faker->city,
|
||||
];
|
||||
|
@ -27,7 +27,7 @@ class ContributionRequestFactory extends RequestFactory
|
|||
|
||||
public function toBase64(): string
|
||||
{
|
||||
return base64_encode(json_encode($this->create()));
|
||||
return base64_encode(urlencode(json_encode($this->create())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue