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