Compare commits
No commits in common. "b2e85211a74087fd6d5bbf9cec31510309576daf" and "c9ccebc8f31c6f25bf41d55d15f0d9f817cbd79e" have entirely different histories.
b2e85211a7
...
c9ccebc8f3
|
@ -36,7 +36,6 @@ class FormStoreAction
|
||||||
'is_private' => 'boolean',
|
'is_private' => 'boolean',
|
||||||
'export' => 'nullable|array',
|
'export' => 'nullable|array',
|
||||||
'needs_prevention' => 'present|boolean',
|
'needs_prevention' => 'present|boolean',
|
||||||
'prevention_text' => 'array',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class FormUpdateAction
|
||||||
'is_private' => 'boolean',
|
'is_private' => 'boolean',
|
||||||
'export' => 'nullable|array',
|
'export' => 'nullable|array',
|
||||||
'needs_prevention' => 'present|boolean',
|
'needs_prevention' => 'present|boolean',
|
||||||
'prevention_text' => 'array',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ class PreventionRememberAction
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = app(PreventionSettings::class)->formmail
|
$body = app(PreventionSettings::class)->formmail
|
||||||
->placeholder('formname', $participant->form->name)
|
->placeholder('formname', $participant->form->name);
|
||||||
->append($participant->form->prevention_text);
|
|
||||||
|
|
||||||
if ($participant->getFields()->getMailRecipient() === null) {
|
if ($participant->getFields()->getMailRecipient() === null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Form\Models;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\Data\FieldCollection;
|
use App\Form\Data\FieldCollection;
|
||||||
use App\Form\Data\FormConfigData;
|
use App\Form\Data\FormConfigData;
|
||||||
use App\Lib\Editor\EditorData;
|
|
||||||
use Cviebrock\EloquentSluggable\Sluggable;
|
use Cviebrock\EloquentSluggable\Sluggable;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
@ -38,7 +37,6 @@ class Form extends Model implements HasMedia
|
||||||
'is_private' => 'boolean',
|
'is_private' => 'boolean',
|
||||||
'export' => ExportData::class,
|
'export' => ExportData::class,
|
||||||
'needs_prevention' => 'boolean',
|
'needs_prevention' => 'boolean',
|
||||||
'prevention_text' => EditorData::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
|
|
|
@ -11,7 +11,6 @@ use App\Form\Scopes\FormFilterScope;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
use App\Form\Models\Formtemplate;
|
use App\Form\Models\Formtemplate;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use App\Lib\Editor\EditorData;
|
|
||||||
use App\Lib\HasMeta;
|
use App\Lib\HasMeta;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
@ -95,7 +94,6 @@ class FormResource extends JsonResource
|
||||||
'config' => null,
|
'config' => null,
|
||||||
'header_image' => null,
|
'header_image' => null,
|
||||||
'mailattachments' => [],
|
'mailattachments' => [],
|
||||||
'prevention_text' => EditorData::default(),
|
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'export' => ExportData::from([]),
|
'export' => ExportData::from([]),
|
||||||
],
|
],
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Lib\Editor;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
/** @todo replace blocks with actual block data classes */
|
/** @todo replace blocks with actual block data classes */
|
||||||
class EditorData extends Data implements Editorable
|
class EditorData extends Data
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -31,22 +31,6 @@ class EditorData extends Data implements Editorable
|
||||||
return collect($wanted)->first(fn ($search) => !str(json_encode($this->blocks))->contains($search)) === null;
|
return collect($wanted)->first(fn ($search) => !str(json_encode($this->blocks))->contains($search)) === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function default(): self
|
|
||||||
{
|
|
||||||
return static::from([
|
|
||||||
'version' => '1.0',
|
|
||||||
'blocks' => [],
|
|
||||||
'time' => 0,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function append(Editorable $editorable): self
|
|
||||||
{
|
|
||||||
$this->blocks = array_merge($this->blocks, $editorable->toEditorData()->blocks);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function replaceWithList(string $blockContent, array $replacements): self
|
public function replaceWithList(string $blockContent, array $replacements): self
|
||||||
{
|
{
|
||||||
$this->blocks = collect($this->blocks)->map(function ($block) use ($blockContent, $replacements) {
|
$this->blocks = collect($this->blocks)->map(function ($block) use ($blockContent, $replacements) {
|
||||||
|
@ -72,11 +56,6 @@ class EditorData extends Data implements Editorable
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toEditorData(): EditorData
|
|
||||||
{
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Lib\Editor;
|
|
||||||
|
|
||||||
interface Editorable
|
|
||||||
{
|
|
||||||
public function toEditorData(): EditorData;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('forms', function (Blueprint $table) {
|
|
||||||
$table->json('prevention_text')->after('description')->default(json_encode(EditorRequestFactory::new()->empty()->create()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('forms', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('prevention_text');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -8,22 +8,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ui-popup
|
<ui-popup v-if="condition !== null" heading="Bedingungen" @close="
|
||||||
v-if="condition !== null"
|
|
||||||
heading="Bedingungen"
|
|
||||||
@close="
|
|
||||||
condition.resolve(condition.data);
|
condition.resolve(condition.data);
|
||||||
condition = null;
|
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',
|
||||||
|
|
|
@ -116,16 +116,6 @@
|
||||||
<f-select id="to_group_field" v-model="single.export.to_group_field" :options="allFields" label="Nach Gruppe schreiben" name="to_group_field"></f-select>
|
<f-select id="to_group_field" v-model="single.export.to_group_field" :options="allFields" label="Nach Gruppe schreiben" name="to_group_field"></f-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="active === 4" class="grid grid-cols-2 gap-3">
|
|
||||||
<f-switch id="needs_prevention" v-model="single.needs_prevention" name="needs_prevention" label="Prävention"></f-switch>
|
|
||||||
<f-editor
|
|
||||||
id="prevention_text"
|
|
||||||
v-model="single.prevention_text"
|
|
||||||
hint="Wird an die Präventions-Email angehangen, die Teilnehmende dieser Veranstaltung erhalten"
|
|
||||||
:rows="6"
|
|
||||||
label="Präventions-Hinweis"
|
|
||||||
></f-editor>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<a href="#" @click.prevent="submit">
|
<a href="#" @click.prevent="submit">
|
||||||
|
@ -202,7 +192,7 @@ const deleting = ref(null);
|
||||||
const showing = ref(null);
|
const showing = ref(null);
|
||||||
const fileSettingPopup = ref(null);
|
const fileSettingPopup = ref(null);
|
||||||
|
|
||||||
const tabs = [{ title: 'Allgemeines' }, { title: 'Formular' }, { title: 'Bestätigungs-E-Mail' }, { title: 'Export' }, { title: 'Prävention' }];
|
const tabs = [{ title: 'Allgemeines' }, { title: 'Formular' }, { title: 'Bestätigungs-E-Mail' }, { title: 'Export' }];
|
||||||
const mailTabs = [{ title: 'vor Daten' }, { title: 'nach Daten' }];
|
const mailTabs = [{ title: 'vor Daten' }, { title: 'nach Daten' }];
|
||||||
|
|
||||||
const allFields = computed(() => {
|
const allFields = computed(() => {
|
||||||
|
|
|
@ -61,7 +61,6 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
||||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname')
|
->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname')
|
||||||
->assertInertiaPath('data.meta.default.name', '')
|
->assertInertiaPath('data.meta.default.name', '')
|
||||||
->assertInertiaPath('data.meta.default.prevention_text.version', '1.0')
|
|
||||||
->assertInertiaPath('data.meta.default.description', [])
|
->assertInertiaPath('data.meta.default.description', [])
|
||||||
->assertInertiaPath('data.meta.default.excerpt', '')
|
->assertInertiaPath('data.meta.default.excerpt', '')
|
||||||
->assertInertiaPath('data.meta.default.is_active', true)
|
->assertInertiaPath('data.meta.default.is_active', true)
|
||||||
|
|
|
@ -50,7 +50,6 @@ class FormRequest extends RequestFactory
|
||||||
'mailattachments' => [],
|
'mailattachments' => [],
|
||||||
'export' => ExportData::from([])->toArray(),
|
'export' => ExportData::from([])->toArray(),
|
||||||
'needs_prevention' => $this->faker->boolean(),
|
'needs_prevention' => $this->faker->boolean(),
|
||||||
'prevention_text' => EditorRequestFactory::new()->create(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ class FormStoreActionTest extends FormTestCase
|
||||||
->name('formname')
|
->name('formname')
|
||||||
->description($description)
|
->description($description)
|
||||||
->excerpt('avff')
|
->excerpt('avff')
|
||||||
->preventionText(EditorRequestFactory::new()->paragraphs(['lorem ipsum']))
|
|
||||||
->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->from('2023-07-07')->to('2023-07-08')
|
->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->from('2023-07-07')->to('2023-07-08')
|
||||||
->mailTop(EditorRequestFactory::new()->text(11, 'lala'))
|
->mailTop(EditorRequestFactory::new()->text(11, 'lala'))
|
||||||
->mailBottom(EditorRequestFactory::new()->text(12, 'lalab'))
|
->mailBottom(EditorRequestFactory::new()->text(12, 'lalab'))
|
||||||
|
@ -39,7 +38,6 @@ class FormStoreActionTest extends FormTestCase
|
||||||
$form = Form::latest()->first();
|
$form = Form::latest()->first();
|
||||||
$this->assertEquals('sname', $form->config->sections->get(0)->name);
|
$this->assertEquals('sname', $form->config->sections->get(0)->name);
|
||||||
$this->assertEquals('formname', $form->name);
|
$this->assertEquals('formname', $form->name);
|
||||||
$this->assertEquals('lorem ipsum', $form->prevention_text->blocks[0]['data']['text']);
|
|
||||||
$this->assertEquals('avff', $form->excerpt);
|
$this->assertEquals('avff', $form->excerpt);
|
||||||
$this->assertEquals($description->paragraphBlock(10, 'Lorem'), $form->description);
|
$this->assertEquals($description->paragraphBlock(10, 'Lorem'), $form->description);
|
||||||
$this->assertEquals(json_decode('{"time":1,"blocks":[{"id":11,"type":"paragraph","data":{"text":"lala"},"tunes":{"condition":{"mode":"all","ifs":[]}}}],"version":"1.0"}', true), $form->mail_top);
|
$this->assertEquals(json_decode('{"time":1,"blocks":[{"id":11,"type":"paragraph","data":{"text":"lala"},"tunes":{"condition":{"mode":"all","ifs":[]}}}],"version":"1.0"}', true), $form->mail_top);
|
||||||
|
@ -90,7 +88,6 @@ class FormStoreActionTest extends FormTestCase
|
||||||
yield [FormRequest::new()->state(['header_image' => null]), ['header_image' => 'Bild ist erforderlich']];
|
yield [FormRequest::new()->state(['header_image' => null]), ['header_image' => 'Bild ist erforderlich']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validationDataProvider
|
* @dataProvider validationDataProvider
|
||||||
* @param array<string, string> $messages
|
* @param array<string, string> $messages
|
||||||
|
|
|
@ -5,9 +5,7 @@ namespace Tests\Feature\Form;
|
||||||
use App\Fileshare\Data\FileshareResourceData;
|
use App\Fileshare\Data\FileshareResourceData;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
use App\Lib\Editor\EditorData;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
|
||||||
|
|
||||||
class FormUpdateActionTest extends FormTestCase
|
class FormUpdateActionTest extends FormTestCase
|
||||||
{
|
{
|
||||||
|
@ -130,13 +128,9 @@ class FormUpdateActionTest extends FormTestCase
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
$form = Form::factory()->create();
|
$form = Form::factory()->create();
|
||||||
$payload = FormRequest::new()
|
$payload = FormRequest::new()->state(['needs_prevention' => true])->create();
|
||||||
->preventionText(EditorRequestFactory::new()->text(10, 'lorem ipsum')->create())
|
|
||||||
->state(['needs_prevention' => true])
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$this->patchJson(route('form.update', ['form' => $form]), $payload);
|
$this->patchJson(route('form.update', ['form' => $form]), $payload);
|
||||||
$this->assertTrue($form->fresh()->needs_prevention);
|
$this->assertTrue($form->fresh()->needs_prevention);
|
||||||
$this->assertEquals('lorem ipsum', $form->fresh()->prevention_text->blocks[0]['data']['text']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,23 +200,6 @@ class PreventionTest extends TestCase
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItAppendsTextOfForm(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
app(PreventionSettings::class)->fake([
|
|
||||||
'formmail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()
|
|
||||||
])->save();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$form->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['event'])->toData()]);
|
|
||||||
$this->createParticipant($form);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn ($mail) => $mail->bodyText->hasAll([
|
|
||||||
'event'
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDisplaysBodyTextInMail(): void
|
public function testItDisplaysBodyTextInMail(): void
|
||||||
{
|
{
|
||||||
$form = $this->createForm();
|
$form = $this->createForm();
|
||||||
|
|
|
@ -21,11 +21,6 @@ class EditorRequestFactory extends RequestFactory
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function empty(): self
|
|
||||||
{
|
|
||||||
return $this->state(['blocks' => []]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $conditions
|
* @param array<string, mixed> $conditions
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue