Clear settings view
This commit is contained in:
parent
8b3b3de9a8
commit
310f3c9727
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Actions\SettingStoreAction;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class FormSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
|
@ -33,10 +31,6 @@ class FormSettings extends LocalSettings implements Storeable
|
|||
];
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -44,10 +38,8 @@ class FormSettings extends LocalSettings implements Storeable
|
|||
{
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'registerUrl' => $this->registerUrl,
|
||||
'clearCacheUrl' => $this->clearCacheUrl,
|
||||
]
|
||||
'registerUrl' => $this->registerUrl,
|
||||
'clearCacheUrl' => $this->clearCacheUrl,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
@ -77,10 +77,6 @@ class InvoiceSettings extends LocalSettings implements Storeable
|
|||
];
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
{
|
||||
return 'Rechnung';
|
||||
|
|
|
@ -27,10 +27,6 @@ class ModuleSettings extends LocalSettings implements Storeable
|
|||
return in_array($module, $this->modules);
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -49,11 +45,9 @@ class ModuleSettings extends LocalSettings implements Storeable
|
|||
{
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'modules' => $this->modules,
|
||||
],
|
||||
'meta' => ['modules' => Module::forSelect()],
|
||||
]
|
||||
'modules' => $this->modules,
|
||||
],
|
||||
'meta' => ['modules' => Module::forSelect()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Prevention\Actions;
|
||||
|
||||
use App\Prevention\PreventionSettings;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingApiAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => app(PreventionSettings::class)->toArray(),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Prevention\Actions;
|
||||
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use App\Prevention\PreventionSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingStoreAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'formmail' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function handle(ActionRequest $request): void
|
||||
{
|
||||
$settings = app(PreventionSettings::class);
|
||||
$settings->formmail = EditorData::from($request->formmail);
|
||||
$settings->save();
|
||||
|
||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||
}
|
||||
}
|
|
@ -3,9 +3,11 @@
|
|||
namespace App\Prevention;
|
||||
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class PreventionSettings extends LocalSettings
|
||||
class PreventionSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
|
||||
public EditorData $formmail;
|
||||
|
@ -20,11 +22,32 @@ class PreventionSettings extends LocalSettings
|
|||
return 'Prävention';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'formmail' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function saveAttributes(ActionRequest $request): array
|
||||
{
|
||||
return [
|
||||
'formmail' => EditorData::from($request->formmail),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'data' => [
|
||||
'formmail' => $this->formmail,
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Setting\Actions;
|
||||
|
||||
use App\Lib\Events\Succeeded;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use GrahamCampbell\ResultType\Success;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
@ -33,7 +35,9 @@ class StoreAction
|
|||
public function asController(ActionRequest $request, Storeable $settingGroup): RedirectResponse
|
||||
{
|
||||
$settingGroup->beforeSave($request);
|
||||
$this->handle($settingGroup, $request->validated());
|
||||
$this->handle($settingGroup, $settingGroup->saveAttributes($request));
|
||||
|
||||
Succeeded::message('Einstellungen gespeichert')->dispatch();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ class ViewAction
|
|||
|
||||
return Inertia::render('setting/' . ucfirst($settingGroup::group()), [
|
||||
...$settingGroup->viewData(),
|
||||
'setting_menu' => app(SettingFactory::class)->getShare(),
|
||||
'settingMenu' => app(SettingFactory::class)->getShare(),
|
||||
'storeUrl' => $settingGroup->storeUrl(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,4 +24,6 @@ interface Storeable
|
|||
public function rules(): array;
|
||||
|
||||
public function beforeSave(ActionRequest $request): void;
|
||||
|
||||
public function saveAttributes(ActionRequest $request): array;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
|
||||
abstract class LocalSettings extends Settings
|
||||
|
@ -13,8 +14,26 @@ abstract class LocalSettings extends Settings
|
|||
return route('setting.view', ['settingGroup' => $this->group()]);
|
||||
}
|
||||
|
||||
public function storeUrl(): string
|
||||
{
|
||||
return $this->url();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
abstract public function viewData(): array;
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function saveAttributes(ActionRequest $request): array
|
||||
{
|
||||
return $request->validated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class SettingFactory
|
||||
|
|
|
@ -2,9 +2,11 @@ import {ref, inject, computed, onBeforeUnmount} from 'vue';
|
|||
import {router} from '@inertiajs/vue3';
|
||||
import useQueueEvents from './useQueueEvents.js';
|
||||
|
||||
export function useIndex(props, siteName) {
|
||||
export function useIndex(props, siteName = null) {
|
||||
const axios = inject('axios');
|
||||
const {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
|
||||
if (siteName !== null) {
|
||||
var {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
|
||||
}
|
||||
const rawProps = JSON.parse(JSON.stringify(props));
|
||||
const inner = {
|
||||
data: ref(rawProps.data),
|
||||
|
@ -56,8 +58,10 @@ export function useIndex(props, siteName) {
|
|||
reload(true);
|
||||
}
|
||||
|
||||
startListener();
|
||||
onBeforeUnmount(() => stopListener());
|
||||
if (siteName !== null) {
|
||||
startListener();
|
||||
onBeforeUnmount(() => stopListener());
|
||||
}
|
||||
|
||||
return {
|
||||
data: inner.data,
|
||||
|
|
|
@ -5,45 +5,26 @@
|
|||
</template>
|
||||
<setting-layout>
|
||||
<form id="billsettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
|
||||
<f-text id="from" v-model="inner.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></f-text>
|
||||
<f-text id="from_long" v-model="inner.from_long" label="Absender (lang)" hint="Absender-Name in Langform, i.d.R. der Stammesname"></f-text>
|
||||
<f-text id="from" v-model="data.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></f-text>
|
||||
<f-text id="from_long" v-model="data.from_long" label="Absender (lang)" hint="Absender-Name in Langform, 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 id="address" v-model="inner.address" label="Straße"></f-text>
|
||||
<f-text id="zip" v-model="inner.zip" label="PLZ"></f-text>
|
||||
<f-text id="place" v-model="inner.place" label="Ort"></f-text>
|
||||
<f-text id="email" v-model="inner.email" label="E-Mail-Adresse"></f-text>
|
||||
<f-text id="mobile" v-model="inner.mobile" label="Telefonnummer"></f-text>
|
||||
<f-text id="website" v-model="inner.website" label="Webseite"></f-text>
|
||||
<f-text id="iban" v-model="inner.iban" label="IBAN"></f-text>
|
||||
<f-text id="bic" v-model="inner.bic" label="BIC"></f-text>
|
||||
<f-text id="remember_weeks" v-model="inner.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></f-text>
|
||||
<f-text id="address" v-model="data.address" label="Straße"></f-text>
|
||||
<f-text id="zip" v-model="data.zip" label="PLZ"></f-text>
|
||||
<f-text id="place" v-model="data.place" label="Ort"></f-text>
|
||||
<f-text id="email" v-model="data.email" label="E-Mail-Adresse"></f-text>
|
||||
<f-text id="mobile" v-model="data.mobile" label="Telefonnummer"></f-text>
|
||||
<f-text id="website" v-model="data.website" label="Webseite"></f-text>
|
||||
<f-text id="iban" v-model="data.iban" label="IBAN"></f-text>
|
||||
<f-text id="bic" v-model="data.bic" label="BIC"></f-text>
|
||||
<f-text id="remember_weeks" v-model="data.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></f-text>
|
||||
</form>
|
||||
</setting-layout>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SettingLayout from './Layout.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SettingLayout,
|
||||
},
|
||||
props: {
|
||||
data: {},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
inner: {...this.data},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$inertia.post('/setting/bill', this.inner, {
|
||||
onSuccess: () => this.$success('Einstellungen gespeichert.'),
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
<script setup>
|
||||
import {props, useSettings} from './useSettings.js';
|
||||
const innerProps = defineProps(props);
|
||||
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
|
||||
</script>
|
||||
|
|
|
@ -9,40 +9,16 @@
|
|||
<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>
|
||||
<f-text id="register_url" v-model="data.registerUrl" label="Formular-Link"></f-text>
|
||||
<f-text id="clear_cache_url" v-model="data.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 setup>
|
||||
import {props, useSettings} from './useSettings.js';
|
||||
const innerProps = defineProps(props);
|
||||
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div class="flex grow relative">
|
||||
<ui-menulist v-model="active" :entries="$page.props.setting_menu"></ui-menulist>
|
||||
<ui-menulist v-model="active" :entries="$page.props.settingMenu"></ui-menulist>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -9,7 +9,7 @@
|
|||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
innerActive: this.$page.props.setting_menu.findIndex((menu) => menu.is_active),
|
||||
innerActive: this.$page.props.settingMenu.findIndex((menu) => menu.is_active),
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -19,7 +19,7 @@ export default {
|
|||
},
|
||||
set(v) {
|
||||
var _self = this;
|
||||
this.$inertia.visit(this.$page.props.setting_menu[v].url, {
|
||||
this.$inertia.visit(this.$page.props.settingMenu[v].url, {
|
||||
onSuccess() {
|
||||
_self.innerActive = v;
|
||||
},
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<template #right>
|
||||
<f-save-button form="mailmansettingform"></f-save-button>
|
||||
</template>
|
||||
<setting-layout>
|
||||
<form id="mailmansettingform" 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">
|
||||
Scoutrobot kann automatisch Mailinglisten erstellen, wenn es mit einem existierenden
|
||||
<a href="https://docs.mailman3.org/en/latest/">Mailman Server</a> verbunden wird. Mailman ist ein OpenSource-Mailinglisten-System, um E-Mails an mehrere Leute zu senden.
|
||||
</p>
|
||||
<p class="text-sm mt-1">Scoutrobot wird nach der Ersteinrichtung deine Mitglieder zu bestehenden E-Mail-Verteilern hinzufügen.</p>
|
||||
</div>
|
||||
<div>
|
||||
<f-switch id="is_active" v-model="inner.is_active" label="Mailman-Synchronisation aktiv"></f-switch>
|
||||
</div>
|
||||
<div class="flex h-full items-center">
|
||||
<ui-sprite :src="stateDisplay.icon" :class="stateDisplay.text" class="w-5 h-5"></ui-sprite>
|
||||
<span class="ml-3" :class="stateDisplay.text" v-text="stateDisplay.label"></span>
|
||||
</div>
|
||||
<f-text id="base_url" v-model="inner.base_url" label="URL" hint="URL der Mailman Api"></f-text>
|
||||
<f-text id="username" v-model="inner.username" label="Benutzername"></f-text>
|
||||
<f-text id="password" v-model="inner.password" type="password" label="Passwort"></f-text>
|
||||
<f-select id="all_list" v-model="inner.all_list" label="Liste für alle Mitglieder" name="all_list" :options="lists"></f-select>
|
||||
<f-select id="all_parents_list" v-model="inner.all_parents_list" label="Liste für Eltern" name="all_parents_list" :options="lists"></f-select>
|
||||
<f-select id="active_leaders_list" v-model="inner.active_leaders_list" label="Liste für aktive Leiter" name="active_leaders_list" :options="lists"></f-select>
|
||||
<f-select id="passive_leaders_list" v-model="inner.passive_leaders_list" label="Liste für passive Leiter" name="passive_leaders_list" :options="lists"></f-select>
|
||||
<div></div>
|
||||
</form>
|
||||
</setting-layout>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SettingLayout from './Layout.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SettingLayout,
|
||||
},
|
||||
props: {
|
||||
data: {},
|
||||
state: {},
|
||||
lists: {},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
inner: {...this.data},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
stateDisplay() {
|
||||
if (this.state === null) {
|
||||
return {
|
||||
text: 'text-gray-500',
|
||||
icon: 'disabled',
|
||||
label: 'Deaktiviert',
|
||||
};
|
||||
}
|
||||
|
||||
return this.state
|
||||
? {
|
||||
text: 'text-green-500',
|
||||
icon: 'check',
|
||||
label: 'Verbindung erfolgreich.',
|
||||
}
|
||||
: {
|
||||
text: 'text-red-500',
|
||||
icon: 'close',
|
||||
label: 'Verbindung fehlgeschlagen.',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit() {
|
||||
this.$inertia.post('/setting/mailman', this.inner, {
|
||||
onSuccess: (page) => {
|
||||
this.$success('Einstellungen gespeichert.');
|
||||
this.inner = page.props.data;
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -4,48 +4,20 @@
|
|||
<f-save-button form="modulesettingform"></f-save-button>
|
||||
</template>
|
||||
<setting-layout>
|
||||
<form id="modulesettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start"
|
||||
@submit.prevent="submit">
|
||||
<form id="modulesettingform" 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 Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren
|
||||
und so den Funktionsumfang auf deine Bedürfnisse anpassen.</p>
|
||||
<p class="text-sm">Hier kannst du Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren und so den Funktionsumfang auf deine Bedürfnisse anpassen.</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<f-switch v-for="module in meta.modules" :id="module.id" v-model="inner.modules" :value="module.id"
|
||||
size="sm" name="modules" :label="module.name"></f-switch>
|
||||
<f-switch v-for="module in meta.modules" :id="module.id" v-model="data.modules" :value="module.id" size="sm" name="modules" :label="module.name"></f-switch>
|
||||
</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 },
|
||||
meta: { ...this.data.meta },
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$inertia.post('/setting/module', this.inner, {
|
||||
onSuccess: () => this.$success('Einstellungen gespeichert.'),
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
<script setup>
|
||||
import {props, useSettings} from './useSettings.js';
|
||||
const innerProps = defineProps(props);
|
||||
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
|
||||
</script>
|
||||
|
|
|
@ -8,40 +8,16 @@
|
|||
<div class="col-span-full text-gray-100 mb-3">
|
||||
<p class="text-sm">Hier kannst du deine Zugangsdaten zu NaMi anpassen, falls sich z.B. dein Passwort geändert hat.</p>
|
||||
</div>
|
||||
<f-text id="mglnr" v-model="inner.mglnr" label="Mitgliedsnummer"></f-text>
|
||||
<f-text id="default_group_id" v-model="inner.default_group_id" label="Standard-Gruppierung"></f-text>
|
||||
<f-text id="password" v-model="inner.password" label="Passwort" name="password" type="password"></f-text>
|
||||
<f-text id="mglnr" v-model="data.mglnr" label="Mitgliedsnummer"></f-text>
|
||||
<f-text id="default_group_id" v-model="data.default_group_id" label="Standard-Gruppierung"></f-text>
|
||||
<f-text id="password" v-model="data.password" label="Passwort" name="password" type="password"></f-text>
|
||||
</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},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$inertia.post('/setting/nami', this.inner, {
|
||||
onSuccess: () => this.$success('Einstellungen gespeichert.'),
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
<script setup>
|
||||
import {props, useSettings} from './useSettings.js';
|
||||
const innerProps = defineProps(props);
|
||||
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
|
||||
</script>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<template #right>
|
||||
<f-save-button form="preventionform"></f-save-button>
|
||||
</template>
|
||||
<setting-layout v-if="loaded">
|
||||
<setting-layout>
|
||||
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
|
||||
<div class="col-span-full text-gray-100 mb-3">
|
||||
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
|
||||
|
@ -16,22 +16,8 @@
|
|||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script lang="js" setup>
|
||||
import { ref } from 'vue';
|
||||
import { useApiIndex } from '../../composables/useApiIndex.js';
|
||||
import SettingLayout from '../setting/Layout.vue';
|
||||
|
||||
const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
|
||||
const loaded = ref(false);
|
||||
|
||||
async function load() {
|
||||
await reload();
|
||||
loaded.value = true;
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
await axios.post('/api/prevention', { ...data.value });
|
||||
}
|
||||
|
||||
load();
|
||||
<script setup>
|
||||
import {props, useSettings} from './useSettings.js';
|
||||
const innerProps = defineProps(props);
|
||||
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import {useIndex} from '../../composables/useIndex.js';
|
||||
import SettingLayout from './Layout.vue';
|
||||
|
||||
export function useSettings(props) {
|
||||
const {data, meta, router} = useIndex(props);
|
||||
|
||||
function submit() {
|
||||
router.post(props.storeUrl, {...data.value});
|
||||
}
|
||||
|
||||
return {
|
||||
submit,
|
||||
data,
|
||||
meta,
|
||||
props,
|
||||
SettingLayout,
|
||||
};
|
||||
}
|
||||
|
||||
const props = {
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
storeUrl: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
settingMenu: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
meta: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => {
|
||||
return {};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export {props};
|
|
@ -3,13 +3,11 @@
|
|||
use App\Contribution\Actions\GenerateApiAction as ContributionGenerateApiAction;
|
||||
use App\Form\Actions\FormApiListAction;
|
||||
use App\Form\Actions\RegisterAction;
|
||||
use App\Prevention\Actions\SettingStoreAction as PreventionStoreAction;
|
||||
use App\Group\Actions\GroupApiIndexAction;
|
||||
use App\Prevention\Actions\SettingApiAction;
|
||||
use App\User\Actions\IndexAction as UserIndexAction;
|
||||
|
||||
Route::post('/contribution-generate', ContributionGenerateApiAction::class)->name('api.contribution.generate')->middleware('client:contribution-generate');
|
||||
Route::post('/form/{form}/register', RegisterAction::class)->name('form.register');
|
||||
Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group');
|
||||
Route::get('/form', FormApiListAction::class)->name('api.form.index');
|
||||
Route::get('/prevention', SettingApiAction::class)->name('api.prevention.index');
|
||||
Route::post('/prevention', PreventionStoreAction::class)->name('api.prevention.store');
|
||||
Route::get('/user', UserIndexAction::class)->name('api.user.index');
|
||||
|
|
|
@ -16,25 +16,25 @@ class SettingTest extends TestCase
|
|||
{
|
||||
$this->login()->loginNami();
|
||||
|
||||
$this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
||||
}
|
||||
|
||||
public function testItReceivesSettings(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
|
||||
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
||||
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
||||
|
||||
$this->get('/api/prevention')
|
||||
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
|
||||
$this->get(route('setting.view', ['settingGroup' => 'prevention']))
|
||||
->assertOk()
|
||||
->assertComponent('setting/Prevention')
|
||||
->assertInertiaPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
|
||||
->assertInertiaPath('store_url', route('setting.store', ['settingGroup' => 'prevention']));
|
||||
}
|
||||
|
||||
public function testItStoresSettings(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
|
||||
$this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk();
|
||||
$route = route('setting.store', ['settingGroup' => 'prevention']);
|
||||
$this
|
||||
->from($route)
|
||||
->post($route, ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])
|
||||
->assertRedirect($route);
|
||||
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue