Add prevention settings
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
92997aa78f
commit
ff40b9e805
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PreventionIndexAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
session()->put('menu', 'setting');
|
||||||
|
session()->put('title', 'Prävention');
|
||||||
|
|
||||||
|
return Inertia::render('setting/Prevention');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use App\Lib\Events\Succeeded;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class SettingStoreAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'formmail' => 'array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(ActionRequest $request): void
|
||||||
|
{
|
||||||
|
app(PreventionSettings::class)->fill($request->validated())->save();
|
||||||
|
|
||||||
|
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention;
|
||||||
|
|
||||||
|
use App\Prevention\Actions\PreventionIndexAction;
|
||||||
|
use App\Setting\Contracts\Indexable;
|
||||||
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
|
class PreventionSettings extends LocalSettings implements Indexable
|
||||||
|
{
|
||||||
|
|
||||||
|
public array $formmail;
|
||||||
|
|
||||||
|
public static function group(): string
|
||||||
|
{
|
||||||
|
return 'prevention';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function slug(): string
|
||||||
|
{
|
||||||
|
return 'prevention';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function indexAction(): string
|
||||||
|
{
|
||||||
|
return PreventionIndexAction::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function title(): string
|
||||||
|
{
|
||||||
|
return 'Prävention';
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ use App\Form\FormSettings;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Mailgateway\MailgatewaySettings;
|
use App\Mailgateway\MailgatewaySettings;
|
||||||
use App\Module\ModuleSettings;
|
use App\Module\ModuleSettings;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class SettingServiceProvider extends ServiceProvider
|
class SettingServiceProvider extends ServiceProvider
|
||||||
|
@ -34,5 +35,6 @@ class SettingServiceProvider extends ServiceProvider
|
||||||
app(SettingFactory::class)->register(NamiSettings::class);
|
app(SettingFactory::class)->register(NamiSettings::class);
|
||||||
app(SettingFactory::class)->register(FormSettings::class);
|
app(SettingFactory::class)->register(FormSettings::class);
|
||||||
app(SettingFactory::class)->register(FileshareSettings::class);
|
app(SettingFactory::class)->register(FileshareSettings::class);
|
||||||
|
app(SettingFactory::class)->register(PreventionSettings::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
return new class extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('prevention.formmail', ['time' => 1, 'blocks' => []]);
|
||||||
|
}
|
||||||
|
};
|
|
@ -8,22 +8,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ui-popup
|
<ui-popup v-if="condition !== null" heading="Bedingungen" @close="
|
||||||
v-if="condition !== null"
|
condition.resolve(condition.data);
|
||||||
heading="Bedingungen"
|
condition = null;
|
||||||
@close="
|
">
|
||||||
condition.resolve(condition.data);
|
|
||||||
condition = null;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<slot name="conditions" :data="condition.data" :resolve="condition.resolve" :reject="condition.reject"></slot>
|
<slot name="conditions" :data="condition.data" :resolve="condition.resolve" :reject="condition.reject"></slot>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {debounce} from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import {onMounted, ref} from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import EditorJS from '@editorjs/editorjs';
|
import EditorJS from '@editorjs/editorjs';
|
||||||
import Header from '@editorjs/header';
|
import Header from '@editorjs/header';
|
||||||
import Paragraph from '@editorjs/paragraph';
|
import Paragraph from '@editorjs/paragraph';
|
||||||
|
@ -32,7 +28,7 @@ import Alert from 'editorjs-alert';
|
||||||
import useFieldSize from '../../composables/useFieldSize.js';
|
import useFieldSize from '../../composables/useFieldSize.js';
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
const {fieldAppearance, paddingX, paddingY, sizeClass} = useFieldSize();
|
const { fieldAppearance, paddingX, paddingY, sizeClass } = useFieldSize();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
required: {
|
required: {
|
||||||
|
@ -88,7 +84,7 @@ async function openPopup(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConditionTune {
|
class ConditionTune {
|
||||||
constructor({api, data, config, block}) {
|
constructor({ api, data, config, block }) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.data = data || {
|
this.data = data || {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<template>
|
||||||
|
<page-layout>
|
||||||
|
<template #right>
|
||||||
|
<f-save-button form="preventionform"></f-save-button>
|
||||||
|
</template>
|
||||||
|
<setting-layout v-if="loaded">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="grid gap-4 mt-2">
|
||||||
|
<f-editor id="frommail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</setting-layout>
|
||||||
|
</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>
|
|
@ -3,9 +3,13 @@
|
||||||
use App\Contribution\Actions\GenerateApiAction as ContributionGenerateApiAction;
|
use App\Contribution\Actions\GenerateApiAction as ContributionGenerateApiAction;
|
||||||
use App\Form\Actions\FormApiListAction;
|
use App\Form\Actions\FormApiListAction;
|
||||||
use App\Form\Actions\RegisterAction;
|
use App\Form\Actions\RegisterAction;
|
||||||
|
use App\Prevention\Actions\SettingStoreAction as PreventionStoreAction;
|
||||||
use App\Group\Actions\GroupApiIndexAction;
|
use App\Group\Actions\GroupApiIndexAction;
|
||||||
|
use App\Prevention\Actions\SettingApiAction;
|
||||||
|
|
||||||
Route::post('/contribution-generate', ContributionGenerateApiAction::class)->name('api.contribution.generate')->middleware('client:contribution-generate');
|
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::post('/form/{form}/register', RegisterAction::class)->name('form.register');
|
||||||
Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group');
|
Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group');
|
||||||
Route::get('/form', FormApiListAction::class)->name('api.form.index');
|
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');
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Prevention;
|
||||||
|
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SettingTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function testItOpensSettingsPage(): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami();
|
||||||
|
|
||||||
|
$this->get('/setting/prevention')->assertComponent('prevention/Index')->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItReceivesSettings(): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami();
|
||||||
|
|
||||||
|
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->create();
|
||||||
|
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
||||||
|
|
||||||
|
$this->get('/api/prevention')
|
||||||
|
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItStoresSettings(): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami();
|
||||||
|
|
||||||
|
$text = EditorRequestFactory::new()->text(50, 'new lorem')->create();
|
||||||
|
|
||||||
|
$this->post('/api/prevention', ['formmail' => $text])->assertOk();
|
||||||
|
$this->assertEquals($text, app(PreventionSettings::class)->formmail);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue