Add form settings
This commit is contained in:
parent
db8d117dcf
commit
291e69e68c
|
@ -35,7 +35,6 @@ class SettingServiceProvider extends ServiceProvider
|
|||
app(SettingFactory::class)->register(ModuleSettings::class);
|
||||
app(SettingFactory::class)->register(InvoiceSettings::class);
|
||||
app(SettingFactory::class)->register(NamiSettings::class);
|
||||
app(SettingFactory::class)->register(FormSettings::class);
|
||||
app(SettingFactory::class)->register(FileshareSettings::class);
|
||||
app(SettingFactory::class)->register(PreventionSettings::class);
|
||||
|
||||
|
|
|
@ -184,6 +184,7 @@ return [
|
|||
Modules\Mailgateway\MailgatewayServiceProvider::class,
|
||||
Modules\Nami\NamiServiceProvider::class,
|
||||
Modules\Auth\AuthServiceProvider::class,
|
||||
Modules\Form\FormServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Form\Components;
|
||||
|
||||
use App\Form\FormSettings;
|
||||
use Livewire\Component;
|
||||
|
||||
class SettingView extends Component
|
||||
{
|
||||
|
||||
public string $clearCacheUrl;
|
||||
public string $registerUrl;
|
||||
public $settingClass = FormSettings::class;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'clearCacheUrl' => '',
|
||||
'registerUrl' => '',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->registerUrl = app(FormSettings::class)->registerUrl;
|
||||
$this->clearCacheUrl = app(FormSettings::class)->clearCacheUrl;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
app(FormSettings::class)->fill($this->validate())->save();
|
||||
$this->dispatch('success', 'Einstellungen gespeichert.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return <<<'HTML'
|
||||
<x-page::setting-layout :active="$settingClass">
|
||||
<x-slot:right>
|
||||
<x-form::save-button form="formsettingform"></x-form::save-button>
|
||||
</x-slot:right>
|
||||
<form id="formsettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start"
|
||||
wire:submit.prevent="save">
|
||||
<x-ui::setting-intro class="col-span-full">
|
||||
Hier kannst du Einstellungen für Anmeldeformulare setzen.
|
||||
</x-ui::setting-intro>
|
||||
<x-form::text name="register_url" wire:model="registerUrl" label="Formular-Link"></x-form::text>
|
||||
<x-form::text name="clear_cache_url" wire:model="clearCacheUrl" label="Frontend-Cache-Url"></x-form::text>
|
||||
</form>
|
||||
</x-page::setting-layout>
|
||||
HTML;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Form\Components;
|
||||
|
||||
use App\Form\FormSettings;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
it('it renders page', function () {
|
||||
test()->withoutExceptionHandling()->login()->loginNami();
|
||||
|
||||
test()->get('/setting/form')->assertSeeLivewire(SettingView::class);
|
||||
});
|
||||
|
||||
it('it displays active modules', function () {
|
||||
test()->withoutExceptionHandling()->login()->loginNami();
|
||||
app(FormSettings::class)->fill(['registerUrl' => 'http://example.com/register', 'clearCacheUrl' => 'http://example.com/clear-cache'])->save();
|
||||
|
||||
Livewire::test(SettingView::class)
|
||||
->assertSee('Einstellungen für Anmeldeformulare')
|
||||
->assertSee('Formular-Link')
|
||||
->assertSet('registerUrl', 'http://example.com/register')
|
||||
->assertSet('clearCacheUrl', 'http://example.com/clear-cache')
|
||||
->assertSeeHtml('data-active');
|
||||
});
|
||||
|
||||
it('it saves settings', function () {
|
||||
test()->withoutExceptionHandling()->login()->loginNami();
|
||||
|
||||
Livewire::test(SettingView::class)
|
||||
->set('clearCacheUrl', 'http://example.com/clear')
|
||||
->set('registerUrl', 'http://example.com/register')
|
||||
->call('save')
|
||||
->assertDispatched('success', 'Einstellungen gespeichert.');
|
||||
|
||||
test()->assertEquals('http://example.com/clear', app(FormSettings::class)->clearCacheUrl);
|
||||
test()->assertEquals('http://example.com/register', app(FormSettings::class)->registerUrl);
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Form;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Form\Components\SettingView;
|
||||
use App\Setting\SettingFactory;
|
||||
use App\Form\FormSettings;
|
||||
|
||||
class FormServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
app(SettingFactory::class)->register(FormSettings::class);
|
||||
|
||||
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
|
||||
$router->get('/setting/form', SettingView::class)->name('setting.form');
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,48 +0,0 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<template #right>
|
||||
<f-save-button form="formsettingsform"></f-save-button>
|
||||
</template>
|
||||
<setting-layout>
|
||||
<form id="formsettingsform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
|
||||
<div class="col-span-full text-gray-100 mb-3">
|
||||
<p class="text-sm">Hier kannst du Einstellungen für Anmeldeformulare setzen.</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<f-text id="register_url" v-model="inner.registerUrl" label="Formular-Link"></f-text>
|
||||
<f-text id="clear_cache_url" v-model="inner.clearCacheUrl" label="Frontend-Cache-Url"></f-text>
|
||||
</div>
|
||||
</form>
|
||||
</setting-layout>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SettingLayout from './Layout.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SettingLayout,
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {};
|
||||
},
|
||||
},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
inner: {...this.data.data},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$inertia.post('/setting/form', this.inner, {
|
||||
onSuccess: () => this.$success('Einstellungen gespeichert.'),
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue