Add setting page
This commit is contained in:
parent
8967eeb7ea
commit
564640b60b
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Setting;
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Settings;
|
||||||
|
|
||||||
|
class BillSettings extends Settings
|
||||||
|
{
|
||||||
|
public string $from_long;
|
||||||
|
|
||||||
|
public string $from;
|
||||||
|
|
||||||
|
public string $mobile;
|
||||||
|
|
||||||
|
public string $email;
|
||||||
|
|
||||||
|
public string $website;
|
||||||
|
|
||||||
|
public string $address;
|
||||||
|
|
||||||
|
public string $place;
|
||||||
|
|
||||||
|
public string $zip;
|
||||||
|
|
||||||
|
public static function group(): string
|
||||||
|
{
|
||||||
|
return 'bill';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Setting;
|
||||||
|
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Inertia\Response;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class SettingIndexAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function handle(BillSettings $settings): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'bill_from_long' => $settings->from_long,
|
||||||
|
'bill_from' => $settings->from,
|
||||||
|
'bill_mobile' => $settings->mobile,
|
||||||
|
'bill_email' => $settings->email,
|
||||||
|
'bill_website' => $settings->website,
|
||||||
|
'bill_address' => $settings->address,
|
||||||
|
'bill_place' => $settings->place,
|
||||||
|
'bill_zip' => $settings->zip,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(BillSettings $settings): Response
|
||||||
|
{
|
||||||
|
session()->put('menu', 'setting');
|
||||||
|
session()->put('title', 'Einstellungen');
|
||||||
|
|
||||||
|
return Inertia::render('setting/Index', [
|
||||||
|
'data' => $this->handle($settings),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Setting;
|
||||||
|
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class SettingSaveAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle(array $input): void
|
||||||
|
{
|
||||||
|
$settings = app(BillSettings::class);
|
||||||
|
|
||||||
|
$settings->from_long = $input['bill_from_long'] ?? '';
|
||||||
|
$settings->from = $input['bill_from'] ?? '';
|
||||||
|
$settings->mobile = $input['bill_mobile'] ?? '';
|
||||||
|
$settings->email = $input['bill_email'] ?? '';
|
||||||
|
$settings->website = $input['bill_website'] ?? '';
|
||||||
|
$settings->address = $input['bill_address'] ?? '';
|
||||||
|
$settings->place = $input['bill_place'] ?? '';
|
||||||
|
$settings->zip = $input['bill_zip'] ?? '';
|
||||||
|
$settings->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(ActionRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->handle($request->all());
|
||||||
|
|
||||||
|
return redirect()->back()->success('Einstellungen gespeichert');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
class BillSettings extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('bill.from_long', '');
|
||||||
|
$this->migrator->add('bill.from', '');
|
||||||
|
$this->migrator->add('bill.mobile', '');
|
||||||
|
$this->migrator->add('bill.email', '');
|
||||||
|
$this->migrator->add('bill.website', '');
|
||||||
|
$this->migrator->add('bill.address', '');
|
||||||
|
$this->migrator->add('bill.place', '');
|
||||||
|
$this->migrator->add('bill.zip', '');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m22.683 9.394-1.88-.239c-.155-.477-.346-.937-.569-1.374l1.161-1.495c.47-.605.415-1.459-.122-1.979l-1.575-1.575c-.525-.542-1.379-.596-1.985-.127l-1.493 1.161c-.437-.223-.897-.414-1.375-.569l-.239-1.877c-.09-.753-.729-1.32-1.486-1.32h-2.24c-.757 0-1.396.567-1.486 1.317l-.239 1.88c-.478.155-.938.345-1.375.569l-1.494-1.161c-.604-.469-1.458-.415-1.979.122l-1.575 1.574c-.542.526-.597 1.38-.127 1.986l1.161 1.494c-.224.437-.414.897-.569 1.374l-1.877.239c-.753.09-1.32.729-1.32 1.486v2.24c0 .757.567 1.396 1.317 1.486l1.88.239c.155.477.346.937.569 1.374l-1.161 1.495c-.47.605-.415 1.459.122 1.979l1.575 1.575c.526.541 1.379.595 1.985.126l1.494-1.161c.437.224.897.415 1.374.569l.239 1.876c.09.755.729 1.322 1.486 1.322h2.24c.757 0 1.396-.567 1.486-1.317l.239-1.88c.477-.155.937-.346 1.374-.569l1.495 1.161c.605.47 1.459.415 1.979-.122l1.575-1.575c.542-.526.597-1.379.127-1.985l-1.161-1.494c.224-.437.415-.897.569-1.374l1.876-.239c.753-.09 1.32-.729 1.32-1.486v-2.24c.001-.757-.566-1.396-1.316-1.486zm-10.683 7.606c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"/></svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,31 @@
|
||||||
|
<template>
|
||||||
|
<div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
|
||||||
|
<div class="grid gap-1">
|
||||||
|
<a
|
||||||
|
v-for="(item, index) in entries"
|
||||||
|
:key="index"
|
||||||
|
href="#"
|
||||||
|
:data-cy="`menu-${item.id}`"
|
||||||
|
@click.prevent="openMenu(index)"
|
||||||
|
class="rounded py-1 px-3 text-gray-400"
|
||||||
|
:class="index == value ? `bg-gray-600` : ''"
|
||||||
|
v-text="item.title"
|
||||||
|
></a>
|
||||||
|
</div>
|
||||||
|
<slot name="bottom"></slot>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: {},
|
||||||
|
entries: {},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openMenu(index) {
|
||||||
|
this.$emit('input', index);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -15,6 +15,7 @@
|
||||||
<v-link href="/contribution" menu="contribution" icon="contribution">Zuschüsse</v-link>
|
<v-link href="/contribution" menu="contribution" icon="contribution">Zuschüsse</v-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid gap-2">
|
<div class="grid gap-2">
|
||||||
|
<v-link href="/setting" menu="setting" icon="setting">Einstellungen</v-link>
|
||||||
<v-link @click.prevent="$inertia.post('/logout')" icon="logout" href="/logout">Abmelden</v-link>
|
<v-link @click.prevent="$inertia.post('/logout')" icon="logout" href="/logout">Abmelden</v-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,20 +17,8 @@
|
||||||
</popup>
|
</popup>
|
||||||
|
|
||||||
<!-- ****************************** menu links ******************************* -->
|
<!-- ****************************** menu links ******************************* -->
|
||||||
<div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
|
<v-tabs v-model="active" :entries="menu">
|
||||||
<div class="grid gap-1">
|
<div slot="bottom">
|
||||||
<a
|
|
||||||
v-for="(item, index) in menu"
|
|
||||||
:key="index"
|
|
||||||
href="#"
|
|
||||||
:data-cy="`menu-${item.id}`"
|
|
||||||
@click.prevent="openMenu(index)"
|
|
||||||
class="rounded py-1 px-3 text-gray-400"
|
|
||||||
:class="index == active ? `bg-gray-600` : ''"
|
|
||||||
v-text="item.title"
|
|
||||||
></a>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
v-show="mode !== 'create'"
|
v-show="mode !== 'create'"
|
||||||
|
@ -41,7 +29,7 @@
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button>
|
<button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</v-tabs>
|
||||||
|
|
||||||
<!-- ***************************** Hauptbereich ****************************** -->
|
<!-- ***************************** Hauptbereich ****************************** -->
|
||||||
<div class="grow">
|
<div class="grow">
|
||||||
|
@ -277,9 +265,6 @@ export default {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.$inertia.post(`/member/${this.inner.id}/confirm`);
|
this.$inertia.post(`/member/${this.inner.id}/confirm`);
|
||||||
},
|
},
|
||||||
openMenu(index) {
|
|
||||||
this.active = index;
|
|
||||||
},
|
|
||||||
submit() {
|
submit() {
|
||||||
this.mode === 'create'
|
this.mode === 'create'
|
||||||
? this.$inertia.post(`/member`, this.inner)
|
? this.$inertia.post(`/member`, this.inner)
|
||||||
|
@ -292,7 +277,8 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
popup: () => import('../../components/Popup.vue'),
|
'popup': () => import('../../components/Popup.vue'),
|
||||||
|
'v-tabs': () => import('../../components/VTabs.vue'),
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<template>
|
||||||
|
<form class="flex grow relative" @submit.prevent="submit">
|
||||||
|
<!-- ********************************* Tabs ********************************** -->
|
||||||
|
<v-tabs v-model="active" :entries="menu">
|
||||||
|
<div slot="bottom">
|
||||||
|
<button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button>
|
||||||
|
</div>
|
||||||
|
</v-tabs>
|
||||||
|
<div class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" v-show="menuTitle === 'Rechnung'">
|
||||||
|
<f-text
|
||||||
|
label="Absender"
|
||||||
|
hint="Absender-Name, i.d.R. der kurze Stammesname"
|
||||||
|
name="bill_from"
|
||||||
|
id="bill_from"
|
||||||
|
v-model="inner.bill_from"
|
||||||
|
></f-text>
|
||||||
|
<f-text
|
||||||
|
label="Absender (lang)"
|
||||||
|
v-model="inner.bill_from_long"
|
||||||
|
name="bill_from_long"
|
||||||
|
id="bill_from_long"
|
||||||
|
hint="Absender-Name in Kurzform, i.d.R. der Stammesname"
|
||||||
|
></f-text>
|
||||||
|
<h2 class="text-lg font-semibold text-gray-300 col-span-2 mt-5">Kontaktdaten</h2>
|
||||||
|
<div class="col-span-2 text-gray-300 text-sm">
|
||||||
|
Diese Kontaktdaten stehen im Absender-Bereich auf der Rechnung.
|
||||||
|
</div>
|
||||||
|
<f-text label="Straße" v-model="inner.bill_address" name="bill_address" id="bill_address"></f-text>
|
||||||
|
<f-text label="PLZ" v-model="inner.bill_zip" name="bill_zip" id="bill_zip"></f-text>
|
||||||
|
<f-text label="Ort" v-model="inner.bill_place" name="bill_place" id="bill_place"></f-text>
|
||||||
|
<f-text label="E-Mail-Adresse" v-model="inner.bill_email" name="bill_email" id="bill_email"></f-text>
|
||||||
|
<f-text label="Telefonnummer" v-model="inner.bill_mobile" name="bill_mobile" id="bill_mobile"></f-text>
|
||||||
|
<f-text label="Webseite" v-model="inner.bill_website" name="bill_website" id="bill_website"></f-text>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
inner: {},
|
||||||
|
active: 0,
|
||||||
|
menu: [{id: 'bill', title: 'Rechnung'}],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
data: {},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submit() {
|
||||||
|
this.$inertia.post('/setting', this.inner);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'v-tabs': () => import('../../components/VTabs.vue'),
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
menuTitle() {
|
||||||
|
return this.menu[this.active].title;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.inner = this.data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -15,7 +15,8 @@ use App\Payment\SendpaymentController;
|
||||||
use App\Payment\SubscriptionController;
|
use App\Payment\SubscriptionController;
|
||||||
use App\Pdf\MemberEfzController;
|
use App\Pdf\MemberEfzController;
|
||||||
use App\Pdf\MemberPdfController;
|
use App\Pdf\MemberPdfController;
|
||||||
use App\Setting\Controllers\SettingController;
|
use App\Setting\SettingIndexAction;
|
||||||
|
use App\Setting\SettingSaveAction;
|
||||||
|
|
||||||
Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void {
|
Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void {
|
||||||
Auth::routes(['register' => false]);
|
Auth::routes(['register' => false]);
|
||||||
|
@ -35,7 +36,8 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create');
|
Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create');
|
||||||
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
||||||
Route::apiResource('member.membership', MembershipController::class);
|
Route::apiResource('member.membership', MembershipController::class);
|
||||||
Route::resource('setting', SettingController::class);
|
Route::get('setting', SettingIndexAction::class);
|
||||||
|
Route::post('setting', SettingSaveAction::class);
|
||||||
Route::resource('member.course', CourseController::class);
|
Route::resource('member.course', CourseController::class);
|
||||||
Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz');
|
Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz');
|
||||||
Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync');
|
Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync');
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Setting;
|
||||||
|
|
||||||
|
use App\Setting\BillSettings;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SettingTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function testSettingIndex(): void
|
||||||
|
{
|
||||||
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
BillSettings::fake([
|
||||||
|
'from_long' => 'DPSG Stamm Muster',
|
||||||
|
'from' => 'Stamm Muster',
|
||||||
|
'mobile' => '+49 176 55555',
|
||||||
|
'email' => 'max@muster.de',
|
||||||
|
'website' => 'https://example.com',
|
||||||
|
'address' => 'Musterstr 4',
|
||||||
|
'place' => 'Solingen',
|
||||||
|
'zip' => '12345',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->get('/setting');
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
$this->assertInertiaHas([
|
||||||
|
'bill_from_long' => 'DPSG Stamm Muster',
|
||||||
|
'bill_from' => 'Stamm Muster',
|
||||||
|
'bill_mobile' => '+49 176 55555',
|
||||||
|
'bill_email' => 'max@muster.de',
|
||||||
|
'bill_website' => 'https://example.com',
|
||||||
|
'bill_address' => 'Musterstr 4',
|
||||||
|
'bill_place' => 'Solingen',
|
||||||
|
'bill_zip' => '12345',
|
||||||
|
], $response, 'data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItCanChangeSettings(): void
|
||||||
|
{
|
||||||
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
|
||||||
|
$response = $this->from('/setting')->post('/setting', [
|
||||||
|
'bill_from_long' => 'DPSG Stamm Muster',
|
||||||
|
'bill_from' => 'Stamm Muster',
|
||||||
|
'bill_mobile' => '+49 176 55555',
|
||||||
|
'bill_email' => 'max@muster.de',
|
||||||
|
'bill_website' => 'https://example.com',
|
||||||
|
'bill_address' => 'Musterstr 4',
|
||||||
|
'bill_place' => 'Solingen',
|
||||||
|
'bill_zip' => '12345',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect('/setting');
|
||||||
|
$settings = app(BillSettings::class);
|
||||||
|
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue