--wip-- [skip ci]
This commit is contained in:
parent
7c656afce8
commit
65a6614831
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Member;
|
namespace App\Member;
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
use App\Confession;
|
use App\Confession;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Course\Models\CourseMember;
|
use App\Course\Models\CourseMember;
|
||||||
|
@ -13,6 +14,7 @@ use App\Nami\HasNamiField;
|
||||||
use App\Nationality;
|
use App\Nationality;
|
||||||
use App\Payment\Subscription;
|
use App\Payment\Subscription;
|
||||||
use App\Pdf\Sender;
|
use App\Pdf\Sender;
|
||||||
|
use App\Prevention\Contracts\YearlyPreventable;
|
||||||
use App\Region;
|
use App\Region;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -40,7 +42,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
* @property string $subscription_name
|
* @property string $subscription_name
|
||||||
* @property int $pending_payment
|
* @property int $pending_payment
|
||||||
*/
|
*/
|
||||||
class Member extends Model implements Geolocatable
|
class Member extends Model implements Geolocatable, YearlyPreventable
|
||||||
{
|
{
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
@ -570,4 +572,21 @@ class Member extends Model implements Geolocatable
|
||||||
->map(fn($membership) => [...$membership->only('activity_id', 'subactivity_id'), 'both' => $membership->activity_id . '|' . $membership->subactivity_id, 'with_group' => $membership->group_id . '|' . $membership->activity_id . '|' . $membership->subactivity_id]),
|
->map(fn($membership) => [...$membership->only('activity_id', 'subactivity_id'), 'both' => $membership->activity_id . '|' . $membership->subactivity_id, 'with_group' => $membership->group_id . '|' . $membership->activity_id . '|' . $membership->subactivity_id]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------- Prevention ---------------------------------
|
||||||
|
// *****************************************************************************
|
||||||
|
public function preventableSubject(): string
|
||||||
|
{
|
||||||
|
return 'Nachweise erforderlich';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preventableLayout(): string
|
||||||
|
{
|
||||||
|
return 'mail.prevention.prevention-remember-participant';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMailRecipient(): stdClass
|
||||||
|
{
|
||||||
|
return (object) ['name' => $this->fullname, 'email' => $this->email];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'formmail' => 'array',
|
'formmail' => 'array',
|
||||||
|
'yearlymail' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
$settings = app(PreventionSettings::class);
|
$settings = app(PreventionSettings::class);
|
||||||
$settings->formmail = EditorData::from($request->formmail);
|
$settings->formmail = EditorData::from($request->formmail);
|
||||||
|
$settings->yearlymail = EditorData::from($request->yearlymail);
|
||||||
$settings->save();
|
$settings->save();
|
||||||
|
|
||||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Contracts;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
|
interface YearlyPreventable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function preventableLayout(): string;
|
||||||
|
public function preventableSubject(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, Prevention>
|
||||||
|
*/
|
||||||
|
public function preventions(): array;
|
||||||
|
|
||||||
|
public function getMailRecipient(): stdClass;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Mails;
|
||||||
|
|
||||||
|
use App\Invoice\InvoiceSettings;
|
||||||
|
use App\Lib\Editor\EditorData;
|
||||||
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Contracts\YearlyPreventable;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Attachment;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class YearlyMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public InvoiceSettings $settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct(public YearlyPreventable $preventable, public EditorData $bodyText)
|
||||||
|
{
|
||||||
|
$this->settings = app(InvoiceSettings::class);
|
||||||
|
$this->bodyText = $this->bodyText
|
||||||
|
->replaceWithList('wanted', collect($preventable->preventions())->map(fn($prevention) => $prevention->text())->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope
|
||||||
|
*/
|
||||||
|
public function envelope()
|
||||||
|
{
|
||||||
|
return (new Envelope(
|
||||||
|
subject: $this->preventable->preventableSubject(),
|
||||||
|
))->to($this->preventable->getMailRecipient()->email, $this->preventable->getMailRecipient()->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Content
|
||||||
|
*/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
markdown: $this->preventable->preventableLayout(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditorData $formmail;
|
public EditorData $formmail;
|
||||||
|
public EditorData $yearlymail;
|
||||||
|
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
return new class extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('prevention.yearlymail', ['time' => 1, 'blocks' => [], 'version' => '1.0']);
|
||||||
|
}
|
||||||
|
};
|
|
@ -91,6 +91,8 @@ services:
|
||||||
- ./data/db:/var/lib/mysql
|
- ./data/db:/var/lib/mysql
|
||||||
|
|
||||||
socketi:
|
socketi:
|
||||||
|
ports:
|
||||||
|
- '6001:6001'
|
||||||
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
|
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
|
||||||
environment:
|
environment:
|
||||||
SOKETI_DEFAULT_APP_ID: adremaid
|
SOKETI_DEFAULT_APP_ID: adremaid
|
||||||
|
@ -103,6 +105,8 @@ services:
|
||||||
- ./data/redis:/data
|
- ./data/redis:/data
|
||||||
|
|
||||||
meilisearch:
|
meilisearch:
|
||||||
|
ports:
|
||||||
|
- '7700:7700'
|
||||||
image: getmeili/meilisearch:v1.6
|
image: getmeili/meilisearch:v1.6
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/meilisearch:/meili_data
|
- ./data/meilisearch:/meili_data
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex-none w-maxc flex flex-col justify-between border-b-2 group-[.is-popup]:border-zinc-500 mb-3">
|
<div class="flex-none w-maxc flex flex-col justify-between border-b-2 border-gray-500 group-[.is-popup]:border-zinc-500 mb-3">
|
||||||
<div class="flex space-x-1 px-2">
|
<div class="flex space-x-1 px-2">
|
||||||
<a v-for="(item, index) in entries" :key="index" href="#" class="rounded-t-lg py-1 px-3 text-zinc-300"
|
<a
|
||||||
:class="index === modelValue ? `group-[.is-popup]:bg-zinc-600` : ''" @click.prevent="openMenu(index)"
|
v-for="(item, index) in entries"
|
||||||
v-text="item.title"></a>
|
:key="index"
|
||||||
|
href="#"
|
||||||
|
class="rounded-t-lg py-1 px-3 text-zinc-300"
|
||||||
|
:class="index === modelValue ? `bg-gray-700 group-[.is-popup]:bg-zinc-600` : ''"
|
||||||
|
@click.prevent="openMenu(index)"
|
||||||
|
v-text="item.title"
|
||||||
|
></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,24 +3,31 @@
|
||||||
<template #right>
|
<template #right>
|
||||||
<f-save-button form="preventionform"></f-save-button>
|
<f-save-button form="preventionform"></f-save-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<setting-layout v-if="loaded">
|
<setting-layout v-if="loaded">
|
||||||
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
|
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
|
||||||
<div class="col-span-full text-gray-100 mb-3">
|
<div class="col-span-full text-gray-100 mb-3">
|
||||||
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
|
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid gap-4 mt-2">
|
<ui-tabs v-model="active" class="mt-2" :entries="tabs"></ui-tabs>
|
||||||
<f-editor id="frommail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
<f-editor v-if="active === 0" id="formmail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
||||||
</div>
|
<f-editor v-if="active === 1" id="yearlymail" v-model="data.yearlymail" label="Jährliche Präventions-Erinnerung"></f-editor>
|
||||||
</form>
|
</form>
|
||||||
</setting-layout>
|
</setting-layout>
|
||||||
</page-layout>
|
</page-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js" setup>
|
<script lang="js" setup>
|
||||||
import { ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useApiIndex } from '../../composables/useApiIndex.js';
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
||||||
import SettingLayout from '../setting/Layout.vue';
|
import SettingLayout from '../setting/Layout.vue';
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{ title: 'für Veranstaltungen' },
|
||||||
|
{ title: 'Jährlich' },
|
||||||
|
];
|
||||||
|
const active = ref(0);
|
||||||
|
|
||||||
const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
|
const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use App\Lib\Editor\Condition;
|
||||||
use App\Prevention\Mails\PreventionRememberMail;
|
use App\Prevention\Mails\PreventionRememberMail;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
|
use App\Prevention\Mails\YearlyMail;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
@ -43,6 +44,11 @@ function createParticipant(Form $form): Participant
|
||||||
])->for(Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling')))->create();
|
])->for(Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling')))->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createMember(array $attributes): Member
|
||||||
|
{
|
||||||
|
return Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling'))->create($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
dataset('attributes', fn() => [
|
dataset('attributes', fn() => [
|
||||||
[
|
[
|
||||||
['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
||||||
|
@ -280,3 +286,9 @@ it('testItDisplaysBodyTextInMail', function () {
|
||||||
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData());
|
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData());
|
||||||
$mail->assertSeeInText('ggtt');
|
$mail->assertSeeInText('ggtt');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('displays text in yearly mail', function () {
|
||||||
|
$member = createMember([]);
|
||||||
|
$mail = new YearlyMail($member, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData());
|
||||||
|
$mail->assertSeeInText('ggtt');
|
||||||
|
});
|
||||||
|
|
|
@ -5,36 +5,33 @@ namespace Tests\Feature\Prevention;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class SettingTest extends TestCase
|
uses(DatabaseTransactions::class);
|
||||||
{
|
|
||||||
|
|
||||||
use DatabaseTransactions;
|
it('testItOpensSettingsPage', function () {
|
||||||
|
test()->login()->loginNami();
|
||||||
|
|
||||||
public function testItOpensSettingsPage(): void
|
test()->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
||||||
{
|
});
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
it('receives settings', function () {
|
||||||
}
|
test()->login()->loginNami();
|
||||||
|
|
||||||
public function testItReceivesSettings(): void
|
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
||||||
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
$yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->toData();
|
||||||
|
app(PreventionSettings::class)->fill(['formmail' => $text, 'yearlymail' => $yearlyMail])->save();
|
||||||
|
|
||||||
$this->get('/api/prevention')
|
test()->get('/api/prevention')
|
||||||
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
|
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
|
||||||
}
|
->assertJsonPath('data.yearlymail.blocks.0.data.text', 'lala dd');
|
||||||
|
});
|
||||||
|
|
||||||
public function testItStoresSettings(): void
|
it('testItStoresSettings', function () {
|
||||||
{
|
test()->login()->loginNami();
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk();
|
$formmail = EditorRequestFactory::new()->text(50, 'new lorem')->create();
|
||||||
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
$yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->create();
|
||||||
}
|
test()->post('/api/prevention', ['formmail' => $formmail, 'yearlymail' => $yearlyMail])->assertOk();
|
||||||
}
|
test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd']));
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue