Compare commits
45 Commits
390e8e14e7
...
2e89002641
Author | SHA1 | Date |
---|---|---|
|
2e89002641 | |
|
4698c808f8 | |
|
ea2eb08052 | |
|
09f401055a | |
|
2c786b62ce | |
|
4cd18e9b3c | |
|
9d41cdb010 | |
|
e429d7de76 | |
|
52a6491488 | |
|
9628ba34d2 | |
|
5361c3930f | |
|
e97d39abd7 | |
|
419b4227eb | |
|
63b57f3da7 | |
|
0ea3f4adce | |
|
363c4360b8 | |
|
3182dc7edd | |
|
7346c2da47 | |
|
95a466ff22 | |
|
e047b9a4f2 | |
|
0311787eec | |
|
fba42fa1d8 | |
|
fe50cf129f | |
|
27f805700e | |
|
f33a23ecc3 | |
|
103e13966f | |
|
b2117cdecf | |
|
177b661d50 | |
|
1c0a2361d6 | |
|
4ed6375202 | |
|
f9c4e32ba2 | |
|
1780e3bce8 | |
|
bf4cfdf7fd | |
|
057002b8e8 | |
|
99731fd08f | |
|
919041d2cf | |
|
47b5abc0f1 | |
|
ea79290435 | |
|
4f21dfceee | |
|
196b81a82d | |
|
83d721c1ca | |
|
027a159a1c | |
|
da8dd12dad | |
|
a482e16739 | |
|
010ad80793 |
|
@ -6,6 +6,7 @@ use App\Actions\DbMaintainAction;
|
||||||
use App\Form\Actions\PreventionRememberAction;
|
use App\Form\Actions\PreventionRememberAction;
|
||||||
use App\Initialize\InitializeMembers;
|
use App\Initialize\InitializeMembers;
|
||||||
use App\Invoice\Actions\InvoiceSendAction;
|
use App\Invoice\Actions\InvoiceSendAction;
|
||||||
|
use App\Prevention\Actions\YearlyRememberAction;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
|
||||||
InitializeMembers::class,
|
InitializeMembers::class,
|
||||||
DbMaintainAction::class,
|
DbMaintainAction::class,
|
||||||
PreventionRememberAction::class,
|
PreventionRememberAction::class,
|
||||||
|
YearlyRememberAction::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +36,7 @@ class Kernel extends ConsoleKernel
|
||||||
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
||||||
$schedule->command(PreventionRememberAction::class)->dailyAt('11:00');
|
$schedule->command(PreventionRememberAction::class)->dailyAt('11:00');
|
||||||
$schedule->command(InvoiceSendAction::class)->dailyAt('10:00');
|
$schedule->command(InvoiceSendAction::class)->dailyAt('10:00');
|
||||||
|
$schedule->command(YearlyRememberAction::class)->dailyAt('09:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PreventionRememberAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public string $commandSignature = 'prevention:remember';
|
public string $commandSignature = 'prevention:remember-forms';
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ class PreventionRememberAction
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($participant->getFields()->getMailRecipient() === null || count($participant->preventions()) === 0) {
|
if ($participant->getFields()->getMailRecipient() === null || $participant->preventions()->count() === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class PreventionRememberAction
|
||||||
->placeholder('formname', $participant->form->name)
|
->placeholder('formname', $participant->form->name)
|
||||||
->append($participant->form->prevention_text);
|
->append($participant->form->prevention_text);
|
||||||
|
|
||||||
Mail::send(new PreventionRememberMail($participant, $body));
|
Mail::send(new PreventionRememberMail($participant, $body, $participant->preventions()));
|
||||||
|
|
||||||
$participant->update(['last_remembered_at' => now()]);
|
$participant->update(['last_remembered_at' => now()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Laravel\Scout\Searchable;
|
use Laravel\Scout\Searchable;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
@ -81,20 +82,15 @@ class Participant extends Model implements Preventable
|
||||||
Mail::to($this->getMailRecipient())->queue(new ConfirmRegistrationMail($this));
|
Mail::to($this->getMailRecipient())->queue(new ConfirmRegistrationMail($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preventableLayout(): string
|
|
||||||
{
|
|
||||||
return 'mail.prevention.prevention-remember-participant';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function preventions(): array
|
public function preventions(): Collection
|
||||||
{
|
{
|
||||||
return $this->member?->preventions($this->form->from) ?: [];
|
return $this->member?->preventions($this->form->from) ?: collect([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMailRecipient(): stdClass
|
public function getMailRecipient(): ?stdClass
|
||||||
{
|
{
|
||||||
return $this->getFields()->getMailRecipient();
|
return $this->getFields()->getMailRecipient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@ class EditorData extends Data implements Editorable
|
||||||
public string $version,
|
public string $version,
|
||||||
public array $blocks,
|
public array $blocks,
|
||||||
public int $time
|
public int $time
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
public function placeholder(string $search, string $replacement): self
|
public function placeholder(string $search, string $replacement): self
|
||||||
{
|
{
|
||||||
|
@ -30,7 +29,12 @@ class EditorData extends Data implements Editorable
|
||||||
*/
|
*/
|
||||||
public function hasAll(array $wanted): bool
|
public function hasAll(array $wanted): bool
|
||||||
{
|
{
|
||||||
return collect($wanted)->first(fn ($search) => !str(json_encode($this->blocks))->contains($search)) === null;
|
return collect($wanted)->doesntContain(fn($search) => !str(json_encode($this->blocks))->contains($search));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasNot(string $should): bool
|
||||||
|
{
|
||||||
|
return !str(json_encode($this->blocks))->contains($should);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function default(): self
|
public static function default(): self
|
||||||
|
|
|
@ -20,12 +20,15 @@ class MemberShowAction
|
||||||
return [
|
return [
|
||||||
'data' => new MemberResource(
|
'data' => new MemberResource(
|
||||||
$member
|
$member
|
||||||
->load('memberships')
|
->load([
|
||||||
->load('invoicePositions.invoice')
|
'memberships.activity',
|
||||||
->load('nationality')
|
'memberships.subactivity',
|
||||||
->load('region')
|
'invoicePositions.invoice',
|
||||||
->load('subscription')
|
'nationality',
|
||||||
->load('courses.course')
|
'region',
|
||||||
|
'subscription',
|
||||||
|
'courses.course'
|
||||||
|
])
|
||||||
),
|
),
|
||||||
'meta' => MemberResource::meta(),
|
'meta' => MemberResource::meta(),
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Member\Data;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||||
|
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||||
|
|
||||||
|
#[MapInputName(SnakeCaseMapper::class)]
|
||||||
|
#[MapOutputName(SnakeCaseMapper::class)]
|
||||||
|
class ActivityData extends Data {
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $id,
|
||||||
|
public string $name,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Member\Data;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||||
|
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||||
|
|
||||||
|
#[MapInputName(SnakeCaseMapper::class)]
|
||||||
|
#[MapOutputName(SnakeCaseMapper::class)]
|
||||||
|
class GroupData extends Data {
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $id,
|
||||||
|
public string $name,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Member\Data;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||||
|
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Member\Membership;
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Activity;
|
||||||
|
|
||||||
|
#[MapInputName(SnakeCaseMapper::class)]
|
||||||
|
#[MapOutputName(SnakeCaseMapper::class)]
|
||||||
|
class MembershipData extends Data
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $id,
|
||||||
|
public ActivityData $activity,
|
||||||
|
public SubactivityData $subactivity,
|
||||||
|
public GroupData $group,
|
||||||
|
public Carbon $from,
|
||||||
|
public ?Carbon $promisedAt,
|
||||||
|
public bool $isActive,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public static function fromModel(Membership $membership)
|
||||||
|
{
|
||||||
|
return static::factory()->withoutMagicalCreation()->from([
|
||||||
|
'id' => $membership->id,
|
||||||
|
'activity' => $membership->activity,
|
||||||
|
'subactivity' => $membership->subactivity,
|
||||||
|
'is_active' => $membership->isActive(),
|
||||||
|
'from' => $membership->from,
|
||||||
|
'group' => $membership->group,
|
||||||
|
'promised_at' => $membership->promised_at,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function with(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'human_date' => $this->from->format('d.m.Y'),
|
||||||
|
'promised_at_human' => $this->promisedAt?->format('d.m.Y'),
|
||||||
|
'promised_at' => $this->promisedAt?->format('Y-m-d'),
|
||||||
|
'links' => [
|
||||||
|
'update' => route('membership.update', ['membership' => $this->id]),
|
||||||
|
'destroy' => route('membership.destroy', ['membership' => $this->id]),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function memberMeta(Member $member): array
|
||||||
|
{
|
||||||
|
$activities = Activity::with('subactivities')->get();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'links' => [
|
||||||
|
'store' => route('member.membership.store', ['member' => $member]),
|
||||||
|
],
|
||||||
|
'groups' => NestedGroup::cacheForSelect(),
|
||||||
|
'activities' => $activities->map(fn($activity) => ['id' => $activity->id, 'name' => $activity->name]),
|
||||||
|
'subactivities' => $activities->mapWithKeys(fn($activity) => [$activity->id => $activity->subactivities->map(fn($subactivity) => ['id' => $subactivity->id, 'name' => $subactivity->name, 'is_age_group' => $subactivity->is_age_group])]),
|
||||||
|
'default' => [
|
||||||
|
'group_id' => $member->group_id,
|
||||||
|
'activity_id' => null,
|
||||||
|
'subactivity_id' => null,
|
||||||
|
'promised_at' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Member\Data;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||||
|
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||||
|
|
||||||
|
#[MapInputName(SnakeCaseMapper::class)]
|
||||||
|
#[MapOutputName(SnakeCaseMapper::class)]
|
||||||
|
class SubactivityData extends Data {
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $id,
|
||||||
|
public string $name,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
}
|
|
@ -48,8 +48,7 @@ class FilterScope extends ScoutFilter
|
||||||
public ?bool $hasBirthday = null,
|
public ?bool $hasBirthday = null,
|
||||||
public ?bool $hasSvk = null,
|
public ?bool $hasSvk = null,
|
||||||
public ?bool $hasVk = null,
|
public ?bool $hasVk = null,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $options
|
* @param array<string, mixed> $options
|
||||||
|
|
|
@ -13,6 +13,8 @@ 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\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
use App\Region;
|
use App\Region;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -35,12 +37,14 @@ use Zoomyboy\Phone\HasPhoneNumbers;
|
||||||
use App\Prevention\Enums\Prevention;
|
use App\Prevention\Enums\Prevention;
|
||||||
use Database\Factories\Member\MemberFactory;
|
use Database\Factories\Member\MemberFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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, Preventable
|
||||||
{
|
{
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
@ -194,6 +198,24 @@ class Member extends Model implements Geolocatable
|
||||||
return (int) $this->invoicePositions()->whereHas('invoice', fn($query) => $query->whereNeedsPayment())->sum('price');
|
return (int) $this->invoicePositions()->whereHas('invoice', fn($query) => $query->whereNeedsPayment())->sum('price');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMailRecipient(): ?stdClass
|
||||||
|
{
|
||||||
|
if (!$this->fullname) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->email) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) ['name' => $this->fullname, 'email' => $this->email];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preventableSubject(): string
|
||||||
|
{
|
||||||
|
return 'Nachweise erforderlich';
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------- Relations ----------------------------------
|
// ---------------------------------- Relations ----------------------------------
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Country, $this>
|
* @return BelongsTo<Country, $this>
|
||||||
|
@ -364,32 +386,47 @@ class Member extends Model implements Geolocatable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, Prevention>
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function preventions(?Carbon $date = null): array
|
public function preventions(?Carbon $date = null): Collection
|
||||||
{
|
{
|
||||||
$date = $date ?: now();
|
$date = $date ?: now();
|
||||||
|
|
||||||
/** @var array<int, Prevention> */
|
/** @var Collection<int, PreventionData> */
|
||||||
$preventions = [];
|
$preventions = collect([]);
|
||||||
|
|
||||||
if ($this->efz === null || $this->efz->diffInYears($date) >= 5) {
|
if ($this->efz === null || $this->efz->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::EFZ;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::EFZ,
|
||||||
|
'expires' => $this->efz === null ? now() : $this->efz->addYears(5)
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->has_vk) {
|
if (!$this->has_vk) {
|
||||||
$preventions[] = Prevention::VK;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::VK,
|
||||||
|
'expires' => now(),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->more_ps_at === null) {
|
if ($this->more_ps_at === null) {
|
||||||
if ($this->ps_at === null) {
|
if ($this->ps_at === null) {
|
||||||
$preventions[] = Prevention::PS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::PS,
|
||||||
|
'expires' => now(),
|
||||||
|
]));
|
||||||
} else if ($this->ps_at->diffInYears($date) >= 5) {
|
} else if ($this->ps_at->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::MOREPS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::MOREPS,
|
||||||
|
'expires' => $this->ps_at->addYears(5),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->more_ps_at === null || $this->more_ps_at->diffInYears($date) >= 5) {
|
if ($this->more_ps_at === null || $this->more_ps_at->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::MOREPS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::MOREPS,
|
||||||
|
'expires' => $this->more_ps_at->addYears(5),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use App\Member\Data\NestedGroup;
|
||||||
use App\Member\Resources\BankAccountResource;
|
use App\Member\Resources\BankAccountResource;
|
||||||
use App\Member\Resources\NationalityResource;
|
use App\Member\Resources\NationalityResource;
|
||||||
use App\Member\Resources\RegionResource;
|
use App\Member\Resources\RegionResource;
|
||||||
use App\Membership\MembershipResource;
|
use App\Member\Data\MembershipData;
|
||||||
use App\Nationality;
|
use App\Nationality;
|
||||||
use App\Payment\Subscription;
|
use App\Payment\Subscription;
|
||||||
use App\Payment\SubscriptionResource;
|
use App\Payment\SubscriptionResource;
|
||||||
|
@ -75,7 +75,7 @@ class MemberResource extends JsonResource
|
||||||
'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.') . ' €' : null,
|
'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.') . ' €' : null,
|
||||||
'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug,
|
'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug,
|
||||||
'courses' => CourseMemberResource::collection($this->whenLoaded('courses')),
|
'courses' => CourseMemberResource::collection($this->whenLoaded('courses')),
|
||||||
'memberships' => MembershipResource::collection($this->whenLoaded('memberships')),
|
'memberships' => $this->relationLoaded('memberships') ? MembershipData::collect($this->memberships) : null,
|
||||||
'invoicePositions' => InvoicePositionResource::collection($this->whenLoaded('invoicePositions')),
|
'invoicePositions' => InvoicePositionResource::collection($this->whenLoaded('invoicePositions')),
|
||||||
'nationality' => new NationalityResource($this->whenLoaded('nationality')),
|
'nationality' => new NationalityResource($this->whenLoaded('nationality')),
|
||||||
'region' => new RegionResource($this->whenLoaded('region')),
|
'region' => new RegionResource($this->whenLoaded('region')),
|
||||||
|
@ -136,8 +136,8 @@ class MemberResource extends JsonResource
|
||||||
$createActivities = Activity::remote()->with(['subactivities' => fn($q) => $q->remote()])->get();
|
$createActivities = Activity::remote()->with(['subactivities' => fn($q) => $q->remote()])->get();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'filterActivities' => Activity::where('is_filterable', true)->pluck('name', 'id'),
|
'filterActivities' => Activity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'filterSubactivities' => Subactivity::where('is_filterable', true)->pluck('name', 'id'),
|
'filterSubactivities' => Subactivity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'formActivities' => $activities->pluck('name', 'id'),
|
'formActivities' => $activities->pluck('name', 'id'),
|
||||||
'formSubactivities' => $activities->map(function (Activity $activity) {
|
'formSubactivities' => $activities->map(function (Activity $activity) {
|
||||||
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
||||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Membership\Actions;
|
||||||
|
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Membership\MembershipResource;
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
use App\Member\Data\MembershipData;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class IndexAction
|
class IndexAction
|
||||||
{
|
{
|
||||||
|
@ -21,11 +21,11 @@ class IndexAction
|
||||||
return $member->memberships;
|
return $member->memberships;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(Member $member): AnonymousResourceCollection
|
public function asController(Member $member): JsonResponse
|
||||||
{
|
{
|
||||||
return MembershipResource::collection($this->handle($member))
|
return response()->json([
|
||||||
->additional([
|
'data' => MembershipData::collect($this->handle($member)),
|
||||||
'meta' => MembershipResource::memberMeta($member)
|
'meta' => MembershipData::memberMeta($member),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Membership;
|
|
||||||
|
|
||||||
use App\Activity;
|
|
||||||
use App\Lib\HasMeta;
|
|
||||||
use App\Member\Data\NestedGroup;
|
|
||||||
use App\Member\Member;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mixin \App\Member\Membership
|
|
||||||
*/
|
|
||||||
class MembershipResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'group_id' => $this->group_id,
|
|
||||||
'activity_id' => $this->activity_id,
|
|
||||||
'activity_name' => $this->activity->name,
|
|
||||||
'subactivity_id' => $this->subactivity_id,
|
|
||||||
'subactivity_name' => $this->subactivity?->name,
|
|
||||||
'human_date' => $this->from->format('d.m.Y'),
|
|
||||||
'promised_at' => $this->promised_at?->format('Y-m-d'),
|
|
||||||
'is_active' => $this->isActive(),
|
|
||||||
'links' => [
|
|
||||||
'update' => route('membership.update', ['membership' => $this->getModel()]),
|
|
||||||
'destroy' => route('membership.destroy', ['membership' => $this->getModel()]),
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public static function memberMeta(Member $member): array
|
|
||||||
{
|
|
||||||
$activities = Activity::with('subactivities')->get();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'links' => [
|
|
||||||
'store' => route('member.membership.store', ['member' => $member]),
|
|
||||||
],
|
|
||||||
'groups' => NestedGroup::cacheForSelect(),
|
|
||||||
'activities' => $activities->map(fn ($activity) => ['id' => $activity->id, 'name' => $activity->name]),
|
|
||||||
'subactivities' => $activities->mapWithKeys(fn ($activity) => [$activity->id => $activity->subactivities->map(fn ($subactivity) => ['id' => $subactivity->id, 'name' => $subactivity->name, 'is_age_group' => $subactivity->is_age_group])]),
|
|
||||||
'default' => [
|
|
||||||
'group_id' => $member->group_id,
|
|
||||||
'activity_id' => null,
|
|
||||||
'subactivity_id' => null,
|
|
||||||
'promised_at' => null,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Prevention\Actions;
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -13,7 +14,10 @@ class SettingApiAction
|
||||||
public function handle(): JsonResponse
|
public function handle(): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => app(PreventionSettings::class)->toArray(),
|
'data' => app(PreventionSettings::class)->toFrontend(),
|
||||||
|
'meta' => [
|
||||||
|
'preventAgainsts' => Prevention::values(),
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Prevention\Actions;
|
||||||
|
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
use App\Lib\Events\Succeeded;
|
use App\Lib\Events\Succeeded;
|
||||||
|
use App\Member\FilterScope;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -19,6 +20,10 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'formmail' => 'array',
|
'formmail' => 'array',
|
||||||
|
'yearlymail' => 'array',
|
||||||
|
'weeks' => 'required|numeric|gte:0',
|
||||||
|
'freshRememberInterval' => 'required|numeric|gte:0',
|
||||||
|
'active' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +31,12 @@ 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->weeks = $request->weeks;
|
||||||
|
$settings->freshRememberInterval = $request->freshRememberInterval;
|
||||||
|
$settings->active = $request->active;
|
||||||
|
$settings->yearlyMemberFilter = FilterScope::from($request->yearlyMemberFilter);
|
||||||
|
$settings->preventAgainst = $request->preventAgainst;
|
||||||
$settings->save();
|
$settings->save();
|
||||||
|
|
||||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
|
use App\Prevention\Mails\YearlyMail;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class YearlyRememberAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public string $commandSignature = 'prevention:remember-yearly';
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$settings = app(PreventionSettings::class);
|
||||||
|
$expireDate = now()->addWeeks($settings->weeks);
|
||||||
|
|
||||||
|
if (!$settings->active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
|
// @todo add this check to FilterScope
|
||||||
|
if ($member->getMailRecipient() === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$noticePreventions = $member->preventions($expireDate)
|
||||||
|
->filter(fn($prevention) => $prevention->expiresAt($expireDate))
|
||||||
|
->filter(fn($p) => $p->appliesToSettings($settings));
|
||||||
|
|
||||||
|
if ($noticePreventions->count() === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mail::send($this->createMail($member, $noticePreventions));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
|
// @todo add this check to FilterScope
|
||||||
|
if ($member->getMailRecipient() === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$preventions = $member->preventions()
|
||||||
|
->filter(fn($prevention) => $prevention->expiresAt(now()))
|
||||||
|
->filter(fn($p) => $p->appliesToSettings($settings));
|
||||||
|
|
||||||
|
if ($preventions->count() === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache::remember(
|
||||||
|
'prevention-' . $member->id,
|
||||||
|
(int) now()->diffInSeconds(now()->addWeeks($settings->freshRememberInterval)),
|
||||||
|
function () use ($member, $preventions) {
|
||||||
|
Mail::send($this->createMail($member, $preventions));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
|
*/
|
||||||
|
protected function createMail(Member $member, Collection $preventions): YearlyMail
|
||||||
|
{
|
||||||
|
$body = app(PreventionSettings::class)->refresh()->yearlymail;
|
||||||
|
return new YearlyMail($member, $body, $preventions);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
namespace App\Prevention\Contracts;
|
namespace App\Prevention\Contracts;
|
||||||
|
|
||||||
use App\Prevention\Enums\Prevention;
|
use App\Prevention\Data\PreventionData;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
interface Preventable
|
interface Preventable
|
||||||
{
|
{
|
||||||
|
|
||||||
public function preventableLayout(): string;
|
|
||||||
public function preventableSubject(): string;
|
public function preventableSubject(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, Prevention>
|
* @return Collection<int, PreventionData>
|
||||||
*/
|
*/
|
||||||
public function preventions(): array;
|
public function preventions(): Collection;
|
||||||
|
|
||||||
public function getMailRecipient(): stdClass;
|
public function getMailRecipient(): ?stdClass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Data;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
|
class PreventionData extends Data
|
||||||
|
{
|
||||||
|
public function __construct(public Prevention $type, public Carbon $expires) {}
|
||||||
|
|
||||||
|
public function expiresAt(Carbon $date): bool
|
||||||
|
{
|
||||||
|
return $this->expires->isSameDay($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function text(): string
|
||||||
|
{
|
||||||
|
return str($this->type->text())->when(
|
||||||
|
!$this->expiresAt(now()),
|
||||||
|
fn($str) => $str->append(' (fällig am ' . $this->expires->format('d.m.Y') . ')')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function appliesToSettings(PreventionSettings $settings): bool
|
||||||
|
{
|
||||||
|
return in_array($this->type->name, $settings->preventAgainst);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
namespace App\Prevention\Enums;
|
namespace App\Prevention\Enums;
|
||||||
|
|
||||||
use App\Member\Member;
|
use App\Prevention\Data\PreventionData;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
enum Prevention
|
enum Prevention
|
||||||
|
@ -39,15 +38,26 @@ enum Prevention
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, self> $preventions
|
* @param Collection<int, PreventionData> $preventions
|
||||||
* @return Collection<int, array{letter: string, value: bool, tooltip: string}>
|
* @return Collection<int, array{letter: string, value: bool, tooltip: string}>
|
||||||
*/
|
*/
|
||||||
public static function items(array $preventions): Collection
|
public static function items(Collection $preventions): Collection
|
||||||
{
|
{
|
||||||
return collect(static::cases())->map(fn($case) => [
|
return collect(static::cases())->map(fn($case) => [
|
||||||
'letter' => $case->letter(),
|
'letter' => $case->letter(),
|
||||||
'value' => !in_array($case, $preventions),
|
'value' => $preventions->pluck('type')->doesntContain($case),
|
||||||
'tooltip' => $case->tooltip(!in_array($case, $preventions)),
|
'tooltip' => $case->tooltip($preventions->pluck('type')->doesntContain($case)),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return collect(static::cases())->map(fn($case) => [
|
||||||
|
'id' => $case->name,
|
||||||
|
'name' => $case->text(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ namespace App\Prevention\Mails;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
use App\Prevention\Contracts\Preventable;
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Attachment;
|
use Illuminate\Mail\Attachment;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Mail\Mailables\Content;
|
use Illuminate\Mail\Mailables\Content;
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class PreventionRememberMail extends Mailable
|
class PreventionRememberMail extends Mailable
|
||||||
{
|
{
|
||||||
|
@ -20,12 +22,13 @@ class PreventionRememberMail extends Mailable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
*/
|
*/
|
||||||
public function __construct(public Preventable $preventable, public EditorData $bodyText)
|
public function __construct(public Preventable $preventable, public EditorData $bodyText, public Collection $preventions)
|
||||||
{
|
{
|
||||||
$this->settings = app(InvoiceSettings::class);
|
$this->settings = app(InvoiceSettings::class);
|
||||||
$this->bodyText = $this->bodyText
|
$this->bodyText = $this->bodyText
|
||||||
->replaceWithList('wanted', collect($preventable->preventions())->map(fn ($prevention) => $prevention->text())->toArray());
|
->replaceWithList('wanted', $preventions->map(fn($prevention) => $prevention->text())->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +51,7 @@ class PreventionRememberMail extends Mailable
|
||||||
public function content()
|
public function content()
|
||||||
{
|
{
|
||||||
return new Content(
|
return new Content(
|
||||||
markdown: $this->preventable->preventableLayout(),
|
markdown: 'mail.prevention.prevention-remember-participant',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Mails;
|
||||||
|
|
||||||
|
use App\Invoice\InvoiceSettings;
|
||||||
|
use App\Lib\Editor\EditorData;
|
||||||
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
|
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;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class YearlyMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public InvoiceSettings $settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
|
*/
|
||||||
|
public function __construct(public Preventable $preventable, public EditorData $bodyText, public Collection $preventions)
|
||||||
|
{
|
||||||
|
$this->settings = app(InvoiceSettings::class);
|
||||||
|
$this->bodyText = $this->bodyText
|
||||||
|
->replaceWithList('wanted', $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: 'mail.prevention.prevention-remember-participant',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,12 +3,23 @@
|
||||||
namespace App\Prevention;
|
namespace App\Prevention;
|
||||||
|
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
|
use App\Member\FilterScope;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class PreventionSettings extends LocalSettings
|
class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditorData $formmail;
|
public EditorData $formmail;
|
||||||
|
public EditorData $yearlymail;
|
||||||
|
public int $weeks;
|
||||||
|
public int $freshRememberInterval;
|
||||||
|
public bool $active;
|
||||||
|
public FilterScope $yearlyMemberFilter;
|
||||||
|
/**
|
||||||
|
* @var array<int, string>
|
||||||
|
* @todo Create collection cast to Collection of enums
|
||||||
|
*/
|
||||||
|
public array $preventAgainst;
|
||||||
|
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
|
@ -27,4 +38,17 @@ class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo return int value here and handle this in vue with a number field that only expects integers
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toFrontend(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
...$this->toArray(),
|
||||||
|
'weeks' => (string) $this->weeks,
|
||||||
|
'freshRememberInterval' => (string) $this->freshRememberInterval,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,5 @@ sudo mysql adrema < db.tmp
|
||||||
rm db.tmp
|
rm db.tmp
|
||||||
|
|
||||||
echo 'app(\App\Form\FormSettings::class)->fill(["registerUrl" => "http://stammsilva.test/anmeldung/{slug}/register", "clearCacheUrl" => "http://stammsilva.test/adrema/clear-cache"])->save();' | php artisan tinker
|
echo 'app(\App\Form\FormSettings::class)->fill(["registerUrl" => "http://stammsilva.test/anmeldung/{slug}/register", "clearCacheUrl" => "http://stammsilva.test/adrema/clear-cache"])->save();' | php artisan tinker
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Member\FilterScope;
|
||||||
|
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']);
|
||||||
|
$this->migrator->add('prevention.weeks', 8);
|
||||||
|
$this->migrator->add('prevention.freshRememberInterval', 12);
|
||||||
|
$this->migrator->add('prevention.active', false);
|
||||||
|
$this->migrator->add('prevention.yearlyMemberFilter', FilterScope::from([])->toArray());
|
||||||
|
$this->migrator->add('prevention.preventAgainst', []);
|
||||||
|
}
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"postcss": "^8.4.33",
|
"postcss": "^8.4.33",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
|
"unplugin-vue-components": "^28.7.0",
|
||||||
"vue-axios": "^3.5.2"
|
"vue-axios": "^3.5.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import VueAxios from 'vue-axios';
|
||||||
import { Plugin as FloatingVue, options as FloatingVueOptions } from './lib/floatingVue.js';
|
import { Plugin as FloatingVue, options as FloatingVueOptions } from './lib/floatingVue.js';
|
||||||
import { createPinia, PiniaVuePlugin } from 'pinia';
|
import { createPinia, PiniaVuePlugin } from 'pinia';
|
||||||
import Echo from './lib/echo.js';
|
import Echo from './lib/echo.js';
|
||||||
import requireModules from './lib/requireModules.js';
|
|
||||||
|
|
||||||
import AppLayout from './layouts/AppLayout.vue';
|
import AppLayout from './layouts/AppLayout.vue';
|
||||||
import hasModule from './mixins/hasModule.js';
|
import hasModule from './mixins/hasModule.js';
|
||||||
|
@ -47,9 +46,6 @@ createInertiaApp({
|
||||||
.mixin(hasModule)
|
.mixin(hasModule)
|
||||||
.mixin(hasFlash);
|
.mixin(hasFlash);
|
||||||
|
|
||||||
requireModules(import.meta.glob('./components/form/*.vue'), app, 'f');
|
|
||||||
requireModules(import.meta.glob('./components/ui/*.vue'), app, 'ui');
|
|
||||||
requireModules(import.meta.glob('./components/page/*.vue', {eager: true}), app, 'page');
|
|
||||||
app.component(
|
app.component(
|
||||||
'FSinglefile',
|
'FSinglefile',
|
||||||
defineAsyncComponent(() => import('!/medialibrary-helper/assets/components/SingleFile.vue'))
|
defineAsyncComponent(() => import('!/medialibrary-helper/assets/components/SingleFile.vue'))
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by unplugin-vue-components
|
||||||
|
// Read more: https://github.com/vuejs/core/pull/3399
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
export {}
|
||||||
|
|
||||||
|
/* prettier-ignore */
|
||||||
|
declare module 'vue' {
|
||||||
|
export interface GlobalComponents {
|
||||||
|
FCheckboxesLabel: typeof import('@/components/form/CheckboxesLabel.vue')['default']
|
||||||
|
FEditor: typeof import('@/components/form/Editor.vue')['default']
|
||||||
|
FHint: typeof import('@/components/form/Hint.vue')['default']
|
||||||
|
FLabel: typeof import('@/components/form/Label.vue')['default']
|
||||||
|
FMemberFilter: typeof import('@/components/form/MemberFilter.vue')['default']
|
||||||
|
FMultipleselect: typeof import('@/components/form/Multipleselect.vue')['default']
|
||||||
|
FSaveButton: typeof import('@/components/form/SaveButton.vue')['default']
|
||||||
|
FSelect: typeof import('@/components/form/Select.vue')['default']
|
||||||
|
FSwitch: typeof import('@/components/form/Switch.vue')['default']
|
||||||
|
FText: typeof import('@/components/form/Text.vue')['default']
|
||||||
|
FTextarea: typeof import('@/components/form/Textarea.vue')['default']
|
||||||
|
PageFilter: typeof import('@/components/page/Filter.vue')['default']
|
||||||
|
PageFullHeading: typeof import('@/components/page/FullHeading.vue')['default']
|
||||||
|
PageFullHeadingBanner: typeof import('@/components/page/FullHeadingBanner.vue')['default']
|
||||||
|
PageFullLayout: typeof import('@/components/page/FullLayout.vue')['default']
|
||||||
|
PageHeader: typeof import('@/components/page/Header.vue')['default']
|
||||||
|
PageLayout: typeof import('@/components/page/Layout.vue')['default']
|
||||||
|
PageSearchModal: typeof import('@/components/page/SearchModal.vue')['default']
|
||||||
|
PageTitle: typeof import('@/components/page/Title.vue')['default']
|
||||||
|
PageToolbarButton: typeof import('@/components/page/ToolbarButton.vue')['default']
|
||||||
|
UiActionButton: typeof import('@/components/ui/ActionButton.vue')['default']
|
||||||
|
UiAgeGroups: typeof import('@/components/ui/AgeGroups.vue')['default']
|
||||||
|
UiBool: typeof import('@/components/ui/Bool.vue')['default']
|
||||||
|
UiBooleanDisplay: typeof import('@/components/ui/BooleanDisplay.vue')['default']
|
||||||
|
UiBox: typeof import('@/components/ui/Box.vue')['default']
|
||||||
|
UiButton: typeof import('@/components/ui/Button.vue')['default']
|
||||||
|
UiFilterSidebar: typeof import('@/components/ui/FilterSidebar.vue')['default']
|
||||||
|
UiIconButton: typeof import('@/components/ui/IconButton.vue')['default']
|
||||||
|
UiLabel: typeof import('@/components/ui/Label.vue')['default']
|
||||||
|
UiLoading: typeof import('@/components/ui/Loading.vue')['default']
|
||||||
|
UiMenulist: typeof import('@/components/ui/Menulist.vue')['default']
|
||||||
|
UiNote: typeof import('@/components/ui/Note.vue')['default']
|
||||||
|
UiPagination: typeof import('@/components/ui/Pagination.vue')['default']
|
||||||
|
UiPopup: typeof import('@/components/ui/Popup.vue')['default']
|
||||||
|
UiRemoteResource: typeof import('@/components/ui/RemoteResource.vue')['default']
|
||||||
|
UiRemoteSelector: typeof import('@/components/ui/RemoteSelector.vue')['default']
|
||||||
|
UiSearchPagination: typeof import('@/components/ui/SearchPagination.vue')['default']
|
||||||
|
UiSearchResult: typeof import('@/components/ui/SearchResult.vue')['default']
|
||||||
|
UiSidebar: typeof import('@/components/ui/Sidebar.vue')['default']
|
||||||
|
UiSpinner: typeof import('@/components/ui/Spinner.vue')['default']
|
||||||
|
UiSprite: typeof import('@/components/ui/Sprite.vue')['default']
|
||||||
|
UiTableToggleButton: typeof import('@/components/ui/TableToggleButton.vue')['default']
|
||||||
|
UiTabs: typeof import('@/components/ui/Tabs.vue')['default']
|
||||||
|
UiTextDisplay: typeof import('@/components/ui/TextDisplay.vue')['default']
|
||||||
|
UiTh: typeof import('@/components/ui/Th.vue')['default']
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<label class="flex flex-col group" :for="id" :class="sizeClass(size)">
|
||||||
|
<f-label v-if="label" :required="false" :value="label"></f-label>
|
||||||
|
<div class="relative flex-none flex">
|
||||||
|
<ui-icon-button :class="[fieldHeight, fieldAppearance, paddingX]" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||||
|
<f-hint v-if="hint" :value="hint"></f-hint>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<ui-filter-sidebar v-model="visible">
|
||||||
|
<member-filter-fields :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" />
|
||||||
|
</ui-filter-sidebar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {ref} from 'vue';
|
||||||
|
import useFieldSize from '../../composables/useFieldSize';
|
||||||
|
import MemberFilterFields from '../../views/member/MemberFilterFields.vue';
|
||||||
|
|
||||||
|
const {sizeClass, fieldHeight, fieldAppearance, paddingX} = useFieldSize();
|
||||||
|
|
||||||
|
const visible = ref(false);
|
||||||
|
|
||||||
|
defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: String,
|
||||||
|
default: () => 'base',
|
||||||
|
},
|
||||||
|
hint: {
|
||||||
|
type: String,
|
||||||
|
default: () => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,47 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<ui-popup v-if="visible === true" heading="Filtern" @close="visible = false">
|
<ui-filter-sidebar v-model="visible">
|
||||||
<div class="grid gap-3 md:grid-cols-2">
|
|
||||||
<slot name="fields"></slot>
|
<slot name="fields"></slot>
|
||||||
</div>
|
</ui-filter-sidebar>
|
||||||
</ui-popup>
|
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3">
|
||||||
<div class="px-6 py-2 border-b border-gray-600" :class="visibleDesktopBlock">
|
|
||||||
<div class="flex items-end space-x-3">
|
|
||||||
<slot name="buttons"></slot>
|
|
||||||
<ui-icon-button v-if="filterable" icon="filter" @click="filterVisible = !filterVisible">Filtern</ui-icon-button>
|
|
||||||
</div>
|
|
||||||
<ui-box v-if="filterVisible" class="mt-3">
|
|
||||||
<div class="grid grid-cols-4 gap-3 items-end">
|
|
||||||
<slot name="fields"></slot>
|
|
||||||
<ui-icon-button class="col-start-1" icon="close" @click="filterVisible = false">Schließen</ui-icon-button>
|
|
||||||
</div>
|
|
||||||
</ui-box>
|
|
||||||
</div>
|
|
||||||
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleMobile">
|
|
||||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3">
|
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3">
|
||||||
<slot name="buttons"></slot>
|
<slot name="buttons"></slot>
|
||||||
<ui-icon-button v-if="filterable" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
<ui-icon-button v-if="!!$slots.fields" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {defineProps, ref} from 'vue';
|
import {ref} from 'vue';
|
||||||
import useBreakpoints from '../../composables/useBreakpoints.js';
|
|
||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
|
||||||
const filterVisible = ref(false);
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
breakpoint: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
filterable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: () => true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {visibleDesktopBlock, visibleMobile} = useBreakpoints(props);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<template>
|
||||||
|
<ui-sidebar :max="0" v-if="modelValue === true" @close="$emit('update:modelValue', false)">
|
||||||
|
<page-header title="Filter" @close="$emit('update:modelValue', false)"> </page-header>
|
||||||
|
<div class="grid gap-3 p-6">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</ui-sidebar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="fixed shadow-2xl bg-gray-600 right-0 top-0 h-full flex flex-col group is-bright" :class="widths[max]">
|
||||||
class="fixed w-full w-[80vw] max-w-[40rem] shadow-2xl bg-gray-600 right-0 top-0 h-full flex flex-col group is-bright">
|
|
||||||
<suspense>
|
<suspense>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|
||||||
|
@ -18,4 +17,20 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
defineEmits(['close']);
|
defineEmits(['close']);
|
||||||
|
|
||||||
|
const widths = {
|
||||||
|
40: 'w-full w-[80vw] max-w-[40rem]',
|
||||||
|
30: 'w-full w-[80vw] max-w-[30rem]',
|
||||||
|
20: 'w-full w-[80vw] max-w-[20rem]',
|
||||||
|
10: 'w-full w-[80vw] max-w-[10rem]',
|
||||||
|
0: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
max: {
|
||||||
|
default: () => 40,
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
<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 v-for="(item, index) in entries" :key="index" href="#" class="rounded-t-lg py-1 px-3 text-zinc-300"
|
||||||
:class="index === modelValue ? `group-[.is-popup]:bg-zinc-600` : ''" @click.prevent="openMenu(index)"
|
:class="index === modelValue ? `bg-gray-700 group-[.is-popup]:bg-zinc-600` : ''" @click.prevent="openMenu(index)"
|
||||||
v-text="item.title"></a>
|
v-text="item.title"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts" setup>
|
||||||
export default {
|
defineProps<{
|
||||||
props: {
|
modelValue: number,
|
||||||
modelValue: {},
|
entries: {title: string}[]
|
||||||
entries: {},
|
}>();
|
||||||
},
|
|
||||||
methods: {
|
const emits = defineEmits<{
|
||||||
openMenu(index) {
|
'update:modelValue': [number],
|
||||||
this.$emit('update:modelValue', index);
|
}>();
|
||||||
},
|
|
||||||
},
|
function openMenu(index: number) {
|
||||||
};
|
emits('update:modelValue', index);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
import {computed} from 'vue';
|
|
||||||
|
|
||||||
export default function (props) {
|
|
||||||
const visibleMobile = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'flex sm:hidden',
|
|
||||||
md: 'flex md:hidden',
|
|
||||||
lg: 'flex lg:hidden',
|
|
||||||
xl: 'flex xl:hidden',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleDesktop = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'hidden sm:flex',
|
|
||||||
md: 'hidden md:flex',
|
|
||||||
lg: 'hidden lg:flex',
|
|
||||||
xl: 'hidden xl:flex',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleMobileBlock = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'block sm:hidden',
|
|
||||||
md: 'block md:hidden',
|
|
||||||
lg: 'block lg:hidden',
|
|
||||||
xl: 'block xl:hidden',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleDesktopBlock = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'hidden sm:block',
|
|
||||||
md: 'hidden md:block',
|
|
||||||
lg: 'hidden lg:block',
|
|
||||||
xl: 'hidden xl:block',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
visibleMobile,
|
|
||||||
visibleDesktop,
|
|
||||||
visibleDesktopBlock,
|
|
||||||
visibleMobileBlock,
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -56,6 +56,11 @@ export function useIndex(props, siteName) {
|
||||||
reload(true);
|
reload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setFilterObject(o) {
|
||||||
|
inner.filter.value = o;
|
||||||
|
reload(true);
|
||||||
|
}
|
||||||
|
|
||||||
startListener();
|
startListener();
|
||||||
onBeforeUnmount(() => stopListener());
|
onBeforeUnmount(() => stopListener());
|
||||||
|
|
||||||
|
@ -70,6 +75,8 @@ export function useIndex(props, siteName) {
|
||||||
toFilterString,
|
toFilterString,
|
||||||
reloadPage,
|
reloadPage,
|
||||||
axios,
|
axios,
|
||||||
|
filter: inner.filter,
|
||||||
|
setFilterObject,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
import {paramCase} from 'change-case';
|
|
||||||
import {defineAsyncComponent} from 'vue';
|
|
||||||
|
|
||||||
export default function (context, app, prefix) {
|
|
||||||
for (const file in context) {
|
|
||||||
let componentName = paramCase(`${prefix}${file.replace(/^.*\/(.*?)\.vue$/g, '$1')}`);
|
|
||||||
|
|
||||||
app.component(componentName, typeof context[file] === 'function' ? defineAsyncComponent(context[file]) : context[file].default);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -144,7 +144,7 @@
|
||||||
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
|
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
|
|
||||||
<page-filter breakpoint="xl" :filterable="false">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||||
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<page-filter breakpoint="lg">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" v-model="innerFilter.search" name="search" label="Suchen" size="sm"></f-text>
|
<f-text id="search" v-model="innerFilter.search" name="search" label="Suchen" size="sm"></f-text>
|
||||||
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<page-filter breakpoint="xl" :filterable="false">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||||
<f-multipleselect
|
<f-multipleselect
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<f-switch v-show="hasModule('bill')" id="ausstand" name="ausstand" label="Nur Ausstände" size="sm" v-model="filter.ausstand"></f-switch>
|
||||||
|
<f-select id="has_vk" name="has_vk" label="Verhaltenskodex unterschrieben" size="sm" :options="meta.boolean_filter" v-model="filter.has_vk"></f-select>
|
||||||
|
<f-select id="has_svk" name="has_svk" label="SVK unterschrieben" size="sm" :options="meta.boolean_filter" v-model="filter.has_svk"></f-select>
|
||||||
|
<f-multipleselect id="group_ids" :options="meta.groups" label="Gruppierungen" size="sm" v-model="filter.group_ids"></f-multipleselect>
|
||||||
|
<f-select v-show="hasModule('bill')" id="billKinds" name="billKinds" :options="meta.billKinds" label="Rechnung" size="sm" v-model="filter.bill_kind"></f-select>
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<f-checkboxes-label>nach Mitgliedschaften</f-checkboxes-label>
|
||||||
|
<button class="btn btn-primary label mt-2" @click.prevent="filter.memberships = [...filter.memberships, {...meta.default_membership_filter}]">
|
||||||
|
<ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite>
|
||||||
|
<span class="hidden xl:inline">Hinzufügen</span>
|
||||||
|
</button>
|
||||||
|
<template v-for="(filter, index) in filter.memberships" :key="index">
|
||||||
|
<f-multipleselect :id="`group_ids-multiple-${index}`" class="mt-4" v-model="filter.group_ids" :options="meta.groups" label="Gruppierung" size="sm"></f-multipleselect>
|
||||||
|
<f-multipleselect :id="`activity_ids-multiple-${index}`" v-model="filter.activity_ids" :options="meta.filterActivities" label="Tätigkeiten" size="sm"></f-multipleselect>
|
||||||
|
<f-multipleselect :id="`subactivity_ids-multiple-${index}`" v-model="filter.subactivity_ids" :options="meta.filterSubactivities" label="Untertätigkeiten" size="sm"></f-multipleselect>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {inject, ref, watch} from 'vue';
|
||||||
|
|
||||||
|
const axios = inject('axios');
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const metaResponse = await axios.post('/api/member/search', {});
|
||||||
|
const meta = ref(metaResponse.data.meta);
|
||||||
|
|
||||||
|
const filter = ref({...props.modelValue});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
filter,
|
||||||
|
function (newValue) {
|
||||||
|
emit('update:modelValue', newValue);
|
||||||
|
},
|
||||||
|
{deep: true}
|
||||||
|
);
|
||||||
|
</script>
|
|
@ -18,7 +18,14 @@
|
||||||
label="Untertätigkeit"
|
label="Untertätigkeit"
|
||||||
@update:modelValue="setSubactivityId(single, $event)"
|
@update:modelValue="setSubactivityId(single, $event)"
|
||||||
></f-select>
|
></f-select>
|
||||||
<f-switch v-if="displayPromisedAt" id="has_promise" :model-value="single.promised_at !== null" label="Hat Versprechen" @update:modelValue="setPromisedAtSwitch(single, $event)"></f-switch>
|
<f-switch
|
||||||
|
v-if="displayPromisedAt"
|
||||||
|
id="has_promise"
|
||||||
|
name="has_promise"
|
||||||
|
:model-value="single.promised_at !== null"
|
||||||
|
label="Hat Versprechen"
|
||||||
|
@update:modelValue="setPromisedAtSwitch(single, $event)"
|
||||||
|
></f-switch>
|
||||||
<f-text v-show="displayPromisedAt && single.promised_at !== null" id="promised_at" v-model="single.promised_at" type="date" label="Versprechensdatum" size="sm"></f-text>
|
<f-text v-show="displayPromisedAt && single.promised_at !== null" id="promised_at" v-model="single.promised_at" type="date" label="Versprechensdatum" size="sm"></f-text>
|
||||||
<button type="submit" class="btn btn-primary">Absenden</button>
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -4,175 +4,71 @@
|
||||||
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button>
|
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button>
|
||||||
<page-toolbar-button :href="data.links.edit" color="warning" icon="pencil">bearbeiten</page-toolbar-button>
|
<page-toolbar-button :href="data.links.edit" color="warning" icon="pencil">bearbeiten</page-toolbar-button>
|
||||||
</template>
|
</template>
|
||||||
<div class="p-3 grid gap-3 this-grid grow">
|
<div class="p-3 grid gap-3 xl:grid-rows-[max-content_1fr] xl:grid-cols-[max-content_max-content_max-content_1fr] grow">
|
||||||
<ui-box heading="Stammdaten" class="area-stamm hidden xl:block">
|
<section class="mobile hidden xl:contents">
|
||||||
<stamm :inner="inner"></stamm>
|
<ui-box heading="Stammdaten">
|
||||||
|
<stamm :inner="props.data" />
|
||||||
</ui-box>
|
</ui-box>
|
||||||
<ui-box heading="Kontakt" class="area-kontakt hidden xl:block">
|
<ui-box heading="Kontakt">
|
||||||
<kontakt :inner="inner"></kontakt>
|
<kontakt :inner="props.data" />
|
||||||
</ui-box>
|
</ui-box>
|
||||||
<ui-box class="area-stammkontakt block xl:hidden">
|
<ui-box heading="Prävention">
|
||||||
<tabs v-model="tabs.stammkontakt">
|
<prae :inner="props.data" />
|
||||||
<stamm v-show="tabs.stammkontakt.active === 'stamm'" :inner="inner"></stamm>
|
|
||||||
<kontakt v-show="tabs.stammkontakt.active === 'kontakt'" :inner="inner"></kontakt>
|
|
||||||
</tabs>
|
|
||||||
</ui-box>
|
</ui-box>
|
||||||
|
<ui-box heading="System">
|
||||||
|
<system :inner="props.data" />
|
||||||
|
</ui-box>
|
||||||
|
<ui-box class="col-span-full">
|
||||||
|
<ui-tabs v-model="tabs.membershipcourse.active" :entries="tabs.membershipcourse.entries" />
|
||||||
|
<memberships v-show="tabs.membershipcourse.active === 0" :value="props.data.memberships" />
|
||||||
|
<courses v-show="tabs.membershipcourse.active === 1" :value="props.data.courses" />
|
||||||
|
<payments v-show="tabs.membershipcourse.active === 2" :value="props.data.invoicePositions" />
|
||||||
|
<div v-show="tabs.membershipcourse.active === 3" class="h-full flex items-center justify-center text-gray-400 text-center">Keine Karte vorhanden</div>
|
||||||
|
</ui-box>
|
||||||
|
</section>
|
||||||
|
|
||||||
<ui-box container-class="" heading="Prävention" class="area-praev hidden xl:block">
|
<section class="mobile contents xl:hidden">
|
||||||
<prae :inner="inner"></prae>
|
<ui-box heading="Stammdaten"> <stamm :inner="props.data" /> </ui-box>
|
||||||
</ui-box>
|
<ui-box heading="Kontakt"> <kontakt :inner="props.data" /> </ui-box>
|
||||||
<ui-box heading="System" class="area-system hidden xl:block">
|
<ui-box heading="Prävention"> <prae :inner="props.data" /> </ui-box>
|
||||||
<system :inner="inner"></system>
|
<ui-box heading="System"> <system :inner="props.data" /> </ui-box>
|
||||||
</ui-box>
|
<ui-box heading="Mitgliedschaften"> <memberships :value="props.data.memberships" /> </ui-box>
|
||||||
<ui-box class="area-praesystem block xl:hidden">
|
<ui-box heading="Ausbildungen"> <courses :value="props.data.courses" /> </ui-box>
|
||||||
<tabs v-model="tabs.praesystem">
|
<ui-box heading="Zahlungen"> <payments :value="props.data.invoicePositions" /> </ui-box>
|
||||||
<prae v-show="tabs.praesystem.active === 'prae'" :inner="inner"></prae>
|
<ui-box heading="Karte"> <div class="h-full flex items-center justify-center text-gray-400 text-center">Keine Karte vorhanden</div> </ui-box>
|
||||||
<system v-show="tabs.praesystem.active === 'system'" :inner="inner"></system>
|
</section>
|
||||||
</tabs>
|
|
||||||
</ui-box>
|
|
||||||
|
|
||||||
<ui-box class="area-membershipcourse hidden xl:block">
|
|
||||||
<tabs v-model="tabs.membershipcourse">
|
|
||||||
<courses v-show="tabs.membershipcourse.active === 'course'" :value="inner.courses"></courses>
|
|
||||||
<memberships v-show="tabs.membershipcourse.active === 'membership'" :value="inner.memberships"> </memberships>
|
|
||||||
</tabs>
|
|
||||||
</ui-box>
|
|
||||||
<ui-box heading="Ausbildungen" class="area-courses xl:hidden">
|
|
||||||
<courses :value="inner.courses"></courses>
|
|
||||||
</ui-box>
|
|
||||||
<ui-box heading="Mitgliedschaften" class="area-memberships xl:hidden">
|
|
||||||
<memberships :value="inner.memberships"></memberships>
|
|
||||||
</ui-box>
|
|
||||||
|
|
||||||
<ui-box heading="Zahlungen" class="area-payments">
|
|
||||||
<payments :value="inner.invoicePositions"></payments>
|
|
||||||
</ui-box>
|
|
||||||
|
|
||||||
<ui-box heading="Karte" container-class="grow" class="area-map hidden xl:flex">
|
|
||||||
<div class="h-full flex items-center justify-center text-gray-400 text-center">Keine Karte vorhanden</div>
|
|
||||||
</ui-box>
|
|
||||||
</div>
|
</div>
|
||||||
</page-layout>
|
</page-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts" setup>
|
||||||
import {defineAsyncComponent} from 'vue';
|
import {defineAsyncComponent, ref} from 'vue';
|
||||||
|
|
||||||
export default {
|
const stamm = defineAsyncComponent(() => import('./boxes/Stamm.vue'));
|
||||||
props: {
|
const kontakt = defineAsyncComponent(() => import('./boxes/Kontakt.vue'));
|
||||||
data: {},
|
const prae = defineAsyncComponent(() => import('./boxes/Prae.vue'));
|
||||||
meta: {},
|
const courses = defineAsyncComponent(() => import('./boxes/Courses.vue'));
|
||||||
},
|
const system = defineAsyncComponent(() => import('./boxes/System.vue'));
|
||||||
data: function () {
|
const payments = defineAsyncComponent(() => import('./boxes/Payments.vue'));
|
||||||
return {
|
const memberships = defineAsyncComponent(() => import('./boxes/Memberships.vue'));
|
||||||
inner: {},
|
|
||||||
tabs: {
|
const tabs = ref({
|
||||||
stammkontakt: {
|
stammkontakt: {
|
||||||
children: {
|
active: 0,
|
||||||
stamm: 'Stammdaten',
|
entries: [{title: 'Stammdaten'}, {title: 'Kontakt'}],
|
||||||
kontakt: 'Kontakt',
|
|
||||||
},
|
|
||||||
active: 'stamm',
|
|
||||||
},
|
},
|
||||||
praesystem: {
|
praesystem: {
|
||||||
children: {
|
active: 0,
|
||||||
system: 'System',
|
entries: [{title: 'System'}, {title: 'Prävention'}],
|
||||||
prae: 'Prävention',
|
|
||||||
},
|
|
||||||
active: 'system',
|
|
||||||
},
|
},
|
||||||
membershipcourse: {
|
membershipcourse: {
|
||||||
children: {
|
active: 0,
|
||||||
membership: 'Mitgliedschaften',
|
entries: [{title: 'Mitgliedschaften'}, {title: 'Ausbildungen'}, {title: 'Zahlungen'}, {title: 'Karte'}],
|
||||||
course: 'Ausbildungen',
|
|
||||||
},
|
|
||||||
active: 'membership',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
});
|
||||||
|
|
||||||
methods: {},
|
const props = defineProps<{
|
||||||
|
data: object,
|
||||||
components: {
|
meta: object,
|
||||||
stamm: defineAsyncComponent(() => import('./boxes/Stamm.vue')),
|
}>();
|
||||||
kontakt: defineAsyncComponent(() => import('./boxes/Kontakt.vue')),
|
|
||||||
prae: defineAsyncComponent(() => import('./boxes/Prae.vue')),
|
|
||||||
courses: defineAsyncComponent(() => import('./boxes/Courses.vue')),
|
|
||||||
system: defineAsyncComponent(() => import('./boxes/System.vue')),
|
|
||||||
payments: defineAsyncComponent(() => import('./boxes/Payments.vue')),
|
|
||||||
memberships: defineAsyncComponent(() => import('./boxes/Memberships.vue')),
|
|
||||||
tabs: defineAsyncComponent(() => import('./Tabs.vue')),
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.inner = this.data;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.this-grid {
|
|
||||||
grid-template-areas:
|
|
||||||
'stammkontakt'
|
|
||||||
'praesystem'
|
|
||||||
'courses'
|
|
||||||
'memberships'
|
|
||||||
'payments';
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (min-width: 1280px) {
|
|
||||||
.this-grid {
|
|
||||||
grid-template-areas:
|
|
||||||
'stamm kontakt praev system'
|
|
||||||
'membershipcourse membershipcourse membershipcourse membershipcourse'
|
|
||||||
'payments payments map map';
|
|
||||||
grid-template-columns: max-content max-content max-content 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-stamm {
|
|
||||||
grid-area: stamm;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-kontakt {
|
|
||||||
grid-area: kontakt;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-praev {
|
|
||||||
grid-area: praev;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-courses {
|
|
||||||
grid-area: courses;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-system {
|
|
||||||
grid-area: system;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-memberships {
|
|
||||||
grid-area: memberships;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-payments {
|
|
||||||
grid-area: payments;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-map {
|
|
||||||
grid-area: map;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-stammkontakt {
|
|
||||||
grid-area: stammkontakt;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-membershipcourse {
|
|
||||||
grid-area: membershipcourse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-praesystem {
|
|
||||||
grid-area: praesystem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
<template>
|
|
||||||
<section>
|
|
||||||
<div class="flex space-x-2 border-b border-teal-200">
|
|
||||||
<a
|
|
||||||
v-for="(v, index) in inner.children"
|
|
||||||
href="#"
|
|
||||||
class="font-semibold hover:text-teal-600 transition-all"
|
|
||||||
:class="{'text-teal-800': inner.active !== index, 'text-teal-600': inner.active === index}"
|
|
||||||
@click.prevent="navigate(index)"
|
|
||||||
>
|
|
||||||
<span v-text="v"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="mt-3">
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
|
|
||||||
props: {
|
|
||||||
modelValue: {},
|
|
||||||
},
|
|
||||||
data: function () {
|
|
||||||
return {
|
|
||||||
inner: {
|
|
||||||
children: {},
|
|
||||||
active: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.inner = this.modelValue;
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
navigate(v) {
|
|
||||||
this.inner.active = v;
|
|
||||||
this.$emit('update:modelValue', this.inner);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
|
@ -17,80 +17,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<ui-popup v-if="membershipFilters !== null" heading="Nach Mitgliedschaften filtern" full @close="membershipFilters = null">
|
<page-filter>
|
||||||
<button class="btn btn-primary label mt-2" @click.prevent="membershipFilters.push({...meta.default_membership_filter})">
|
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite>
|
|
||||||
<span class="hidden xl:inline">Hinzufügen</span>
|
|
||||||
</button>
|
|
||||||
<div v-for="(filter, index) in membershipFilters" :key="index" class="flex space-x-2 mt-2">
|
|
||||||
<f-multipleselect :id="`group_ids-multiple-${index}`" v-model="filter.group_ids" :options="meta.groups" label="Gruppierung" size="sm"></f-multipleselect>
|
|
||||||
<f-multipleselect :id="`activity_ids-multiple-${index}`" v-model="filter.activity_ids" :options="meta.filterActivities" label="Tätigkeiten" size="sm"></f-multipleselect>
|
|
||||||
<f-multipleselect :id="`subactivity_ids-multiple-${index}`" v-model="filter.subactivity_ids" :options="meta.filterSubactivities" label="Untertätigkeiten" size="sm"></f-multipleselect>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
class="btn btn-primary label mt-3"
|
|
||||||
@click.prevent="
|
|
||||||
setFilter('memberships', membershipFilters);
|
|
||||||
membershipFilters = null;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<span class="hidden xl:inline">Anwenden</span>
|
|
||||||
</button>
|
|
||||||
</ui-popup>
|
|
||||||
<page-filter breakpoint="xl">
|
|
||||||
<template #fields>
|
<template #fields>
|
||||||
<f-switch
|
<member-filter-fields :model-value="filter" @update:model-value="setFilterObject($event)" />
|
||||||
v-show="hasModule('bill')"
|
|
||||||
id="ausstand"
|
|
||||||
name="ausstand"
|
|
||||||
:model-value="getFilter('ausstand')"
|
|
||||||
label="Nur Ausstände"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('ausstand', $event)"
|
|
||||||
></f-switch>
|
|
||||||
<f-select
|
|
||||||
id="has_vk"
|
|
||||||
name="has_vk"
|
|
||||||
:model-value="getFilter('has_vk')"
|
|
||||||
label="Verhaltenskodex unterschrieben"
|
|
||||||
size="sm"
|
|
||||||
:options="meta.boolean_filter"
|
|
||||||
@update:model-value="setFilter('has_vk', $event)"
|
|
||||||
></f-select>
|
|
||||||
<f-select
|
|
||||||
id="has_svk"
|
|
||||||
name="has_svk"
|
|
||||||
:model-value="getFilter('has_svk')"
|
|
||||||
label="SVK unterschrieben"
|
|
||||||
size="sm"
|
|
||||||
:options="meta.boolean_filter"
|
|
||||||
@update:model-value="setFilter('has_svk', $event)"
|
|
||||||
></f-select>
|
|
||||||
<f-multipleselect
|
|
||||||
id="group_ids"
|
|
||||||
:options="meta.groups"
|
|
||||||
:model-value="getFilter('group_ids')"
|
|
||||||
label="Gruppierungen"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('group_ids', $event)"
|
|
||||||
></f-multipleselect>
|
|
||||||
<f-select
|
|
||||||
v-show="hasModule('bill')"
|
|
||||||
id="billKinds"
|
|
||||||
name="billKinds"
|
|
||||||
:options="meta.billKinds"
|
|
||||||
:model-value="getFilter('bill_kind')"
|
|
||||||
label="Rechnung"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('bill_kind', $event)"
|
|
||||||
></f-select>
|
|
||||||
<button class="btn btn-primary label mr-2" @click.prevent="membershipFilters = getFilter('memberships')">
|
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite>
|
|
||||||
<span class="hidden xl:inline">Mitgliedschaften</span>
|
|
||||||
</button>
|
|
||||||
</template>
|
</template>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="filter.search" label="Suchen …" size="sm" @update:model-value="setFilterObject({...filter, search: $event})"></f-text>
|
||||||
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
||||||
<span class="hidden xl:inline">Exportieren</span>
|
<span class="hidden xl:inline">Exportieren</span>
|
||||||
|
@ -161,7 +93,7 @@
|
||||||
</page-layout>
|
</page-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js" setup>
|
<script setup>
|
||||||
import MemberInvoicePositions from './MemberInvoicePositions.vue';
|
import MemberInvoicePositions from './MemberInvoicePositions.vue';
|
||||||
import MemberMemberships from './MemberMemberships.vue';
|
import MemberMemberships from './MemberMemberships.vue';
|
||||||
import MemberCourses from './MemberCourses.vue';
|
import MemberCourses from './MemberCourses.vue';
|
||||||
|
@ -169,13 +101,13 @@ import Tags from './Tags.vue';
|
||||||
import Actions from './index/Actions.vue';
|
import Actions from './index/Actions.vue';
|
||||||
import {indexProps, useIndex} from '../../composables/useIndex.js';
|
import {indexProps, useIndex} from '../../composables/useIndex.js';
|
||||||
import {ref, defineProps} from 'vue';
|
import {ref, defineProps} from 'vue';
|
||||||
|
import MemberFilterFields from './MemberFilterFields.vue';
|
||||||
|
|
||||||
const single = ref(null);
|
const single = ref(null);
|
||||||
const deleting = ref(null);
|
const deleting = ref(null);
|
||||||
const membershipFilters = ref(null);
|
|
||||||
|
|
||||||
const props = defineProps(indexProps);
|
const props = defineProps(indexProps);
|
||||||
var { router, data, meta, getFilter, setFilter, filterString, reloadPage } = useIndex(props.data, 'member');
|
var {router, data, meta, filter, setFilterObject, filterString, reloadPage} = useIndex(props.data, 'member');
|
||||||
|
|
||||||
function exportMembers() {
|
function exportMembers() {
|
||||||
window.open(`/member-export?filter=${filterString.value}`);
|
window.open(`/member-export?filter=${filterString.value}`);
|
||||||
|
|
|
@ -3,13 +3,25 @@
|
||||||
<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>
|
<div v-if="active === 0">
|
||||||
|
<f-editor v-if="active === 0" id="formmail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
||||||
|
</div>
|
||||||
|
<div v-if="active === 1" class="grid gap-6">
|
||||||
|
<f-switch id="active" v-model="data.active" name="active" label="Regelmäßig an Präventionsunterlagen erinnern"></f-switch>
|
||||||
|
<div class="flex gap-6">
|
||||||
|
<f-text id="weeks" v-model="data.weeks" label="Vor Ablauf X Wochen vorher erinnern" type="number" />
|
||||||
|
<f-text id="fresh_remember_interval" v-model="data.freshRememberInterval" label="Bei Ablauf alle X Wochen erinnern" type="number" />
|
||||||
|
</div>
|
||||||
|
<f-editor v-if="active === 1" id="yearlymail" v-model="data.yearlymail" label="Jährliche Präventions-Erinnerung"></f-editor>
|
||||||
|
<f-member-filter id="yearly_member_filter" v-model="data.yearlyMemberFilter" label="nur für folgende Mitglieder erlauben" />
|
||||||
|
<f-multipleselect id="prevent_against" v-model="data.preventAgainst" :options="meta.preventAgainsts" label="An diese Dokumente erinnern" size="sm"></f-multipleselect>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</setting-layout>
|
</setting-layout>
|
||||||
|
@ -21,7 +33,13 @@ import { 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 { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
|
const tabs = [
|
||||||
|
{ title: 'für Veranstaltungen' },
|
||||||
|
{ title: 'Jährlich' },
|
||||||
|
];
|
||||||
|
const active = ref(0);
|
||||||
|
|
||||||
|
const { axios, data, meta, reload } = useApiIndex('/api/prevention', 'prevention');
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@component('mail::message')
|
@component('mail::message')
|
||||||
# Hallo {{ $preventable->member->fullname }},
|
# Hallo {{ $preventable->getMailRecipient()->name }},
|
||||||
|
|
||||||
<x-mail-view::editor :content="$bodyText->toArray()['blocks']"></x-mail-view::editor>
|
<x-mail-view::editor :content="$bodyText->toArray()['blocks']"></x-mail-view::editor>
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,8 @@ class IndexTest extends EndToEndTestCase
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->get('/member')
|
$this->get('/member')
|
||||||
->assertInertiaPath("data.meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
|
->assertInertiaPath("data.meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
|
||||||
->assertInertiaPath("data.meta.filterSubactivities.{$subactivity->id}", 'Biber')
|
->assertInertiaPath("data.meta.filterSubactivities.0.name", 'Biber')
|
||||||
|
->assertInertiaPath("data.meta.filterSubactivities.0.id", $activity->id)
|
||||||
->assertInertiaPath("data.meta.formActivities.{$activity->id}", '€ Mitglied');
|
->assertInertiaPath("data.meta.formActivities.{$activity->id}", '€ Mitglied');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,445 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\EndToEnd\Member;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
|
use App\Form\Actions\PreventionRememberAction;
|
||||||
|
use App\Form\Enums\NamiType;
|
||||||
|
use App\Form\Enums\SpecialType;
|
||||||
|
use App\Form\Models\Form;
|
||||||
|
use App\Form\Models\Participant;
|
||||||
|
use App\Invoice\InvoiceSettings;
|
||||||
|
use App\Lib\Editor\Condition;
|
||||||
|
use App\Member\FilterScope;
|
||||||
|
use App\Prevention\Mails\PreventionRememberMail;
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Member\Membership;
|
||||||
|
use App\Prevention\Actions\YearlyRememberAction;
|
||||||
|
use App\Prevention\Mails\YearlyMail;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Tests\EndToEndTestCase;
|
||||||
|
use Tests\Lib\CreatesFormFields;
|
||||||
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
|
|
||||||
|
uses(DatabaseTransactions::class);
|
||||||
|
uses(CreatesFormFields::class);
|
||||||
|
uses(EndToEndTestCase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
app(PreventionSettings::class)->fill(['preventAgainst' => array_column(Prevention::values(), 'id'), 'active' => true])->save();
|
||||||
|
});
|
||||||
|
|
||||||
|
function createForm(): Form
|
||||||
|
{
|
||||||
|
return Form::factory()->fields([
|
||||||
|
test()->textField('vorname')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::FIRSTNAME),
|
||||||
|
test()->textField('nachname')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::LASTNAME),
|
||||||
|
test()->textField('email')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::EMAIL),
|
||||||
|
])->create(['needs_prevention' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createParticipant(Form $form): Participant
|
||||||
|
{
|
||||||
|
return Participant::factory()->for($form)->data([
|
||||||
|
'vorname' => 'Max',
|
||||||
|
'nachname' => 'Muster',
|
||||||
|
'email' => 'mail@a.de',
|
||||||
|
])->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() => [
|
||||||
|
[
|
||||||
|
['has_vk' => false, 'efz' => null, 'ps_at' => null],
|
||||||
|
[Prevention::EFZ, Prevention::VK, Prevention::PS]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
||||||
|
[Prevention::EFZ]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => null],
|
||||||
|
[Prevention::PS]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now()->subDay(), 'ps_at' => now()],
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subDay()],
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now()->subYears(5)->subDay(), 'ps_at' => now()],
|
||||||
|
[Prevention::EFZ]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => null],
|
||||||
|
[Prevention::PS]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay()],
|
||||||
|
[Prevention::MOREPS]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay(), 'more_ps_at' => now()],
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(15), 'more_ps_at' => now()->subYears(5)->subDay()],
|
||||||
|
[Prevention::MOREPS],
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => false, 'efz' => now(), 'ps_at' => now()],
|
||||||
|
[Prevention::VK],
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(7)],
|
||||||
|
[Prevention::MOREPS],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('testItRemembersWhenNotRememberedYet', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertEquals(now()->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberPastEvents', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$form->update(['from' => now()->subDay()]);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberWhenConditionDoesntMatch', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$form->update(['prevention_conditions' => Condition::from(['mode' => 'all', 'ifs' => [['field' => 'vorname', 'comparator' => 'isEqual', 'value' => 'Max']]])]);
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->update(['data' => [...$participant->data, 'vorname' => 'Jane']]);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItRemembersWhenRememberIsDue', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = tap(createParticipant($form), fn($p) => $p->update(['last_remembered_at' => now()->subWeeks(3)]));
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertEquals(now()->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberWhenRememberingIsNotDue', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = tap(createParticipant($form), fn($p) => $p->update(['last_remembered_at' => now()->subWeeks(1)]));
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertEquals(now()->subWeeks(1)->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberWhenFormDoesntNeedPrevention', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = tap(createForm(), fn($form) => $form->update(['needs_prevention' => false]));
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberWhenParticipantDoesntHaveMember', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->member->delete();
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt remember non leaders', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->member->memberships->each->delete();
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('remembers event participant', function ($attrs, $preventions) {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->member->update($attrs);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
if (count($preventions)) {
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->preventable->preventions()->pluck('type')->toArray() === $preventions);
|
||||||
|
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
||||||
|
} else {
|
||||||
|
Mail::assertNotSent(PreventionRememberMail::class);
|
||||||
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
|
}
|
||||||
|
})->with('attributes');
|
||||||
|
|
||||||
|
it('sets due date in mail when not now', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$form->update(['from' => now()->addMonths(8)]);
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->member->update(['efz' => now()->subYears(5)->addMonth(), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->preventable->preventions()->first()->expires->isSameDay(now()->addMonth()));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('notices a few weeks before', function ($date, bool $shouldSend) {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['weeks' => 2])->save();
|
||||||
|
createMember(['efz' => $date, 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
$shouldSend
|
||||||
|
? Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()->addWeeks(2)))
|
||||||
|
: Mail::assertNotSent(YearlyMail::class);
|
||||||
|
})->with([
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2), true],
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2)->addDay(), false],
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2)->subDay(), false],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('remembers members yearly', function ($date, $shouldSend) {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => $date, 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
$shouldSend
|
||||||
|
? Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()))
|
||||||
|
: Mail::assertNotSent(YearlyMail::class);
|
||||||
|
})->with([
|
||||||
|
[fn() => now()->subYears(5), true],
|
||||||
|
[fn() => now()->subYears(5)->addDay(), false],
|
||||||
|
[fn() => now()->subYears(5)->subDay(), false],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('remembers yearly only once', function () {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSentCount(1);
|
||||||
|
Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntRememberParticipantThatHasNoMail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->update(['data' => [...$participant->data, 'email' => '']]);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(PreventionRememberMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt remember when prevent against doesnt match', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['preventAgainst' => []])->save();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when member has no mail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true, 'email' => '', 'email_parents' => '']);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when yearly sending is deactivated', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['active' => false])->save();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when member doesnt match', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlyMemberFilter' => FilterScope::from(['search' => 'Lorem Ipsum']),
|
||||||
|
])->save();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true, 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItRendersSetttingMail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'formmail' => EditorRequestFactory::new()->paragraphs(["lorem lala {formname} g", "{wanted}", "bbb"])->toData()
|
||||||
|
])->save();
|
||||||
|
$form = createForm();
|
||||||
|
createParticipant($form);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll([
|
||||||
|
'lorem lala ' . $form->name,
|
||||||
|
'erweitertes'
|
||||||
|
]) && $mail->bodyText->hasNot(now()->format('d.m.Y')));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItAppendsTextOfForm', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'formmail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()
|
||||||
|
])->save();
|
||||||
|
$form = createForm();
|
||||||
|
$form->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['event'])->toData()]);
|
||||||
|
createParticipant($form);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll([
|
||||||
|
'event'
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItDoesntAppendTextTwice', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['frommail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()])->save();
|
||||||
|
tap(createForm(), function ($f) {
|
||||||
|
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['oberhausen'])->toData()]);
|
||||||
|
createParticipant($f);
|
||||||
|
});
|
||||||
|
tap(createForm(), function ($f) {
|
||||||
|
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['siegburg'])->toData()]);
|
||||||
|
createParticipant($f);
|
||||||
|
});
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll(['oberhausen']) && !$mail->bodyText->hasAll(['siegburg']));
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ----------------------------------------- Mail contents ----------------------------------------- */
|
||||||
|
it('displays body text in prevention remember mail', function () {
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
|
||||||
|
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData(), collect([]));
|
||||||
|
$mail->assertSeeInText('ggtt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders prevention mail for events with group name', function () {
|
||||||
|
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
(new PreventionRememberMail($participant, app(PreventionSettings::class)->formmail, collect([])))
|
||||||
|
->assertSeeInText('Max')
|
||||||
|
->assertSeeInText('Muster')
|
||||||
|
->assertSeeInText('Stamm Beispiel');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders yearly mail', function () {
|
||||||
|
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
||||||
|
$member = createMember([]);
|
||||||
|
$mail = new YearlyMail($member, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData(), collect([]));
|
||||||
|
$mail
|
||||||
|
->assertSeeInText('ggtt')
|
||||||
|
->assertSeeInText('Stamm Beispiel');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders setting of yearly mail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlymail' => EditorRequestFactory::new()->paragraphs(["{wanted}", "bbb"])->toData()
|
||||||
|
])->save();
|
||||||
|
$member = createMember((['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]));
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(
|
||||||
|
YearlyMail::class,
|
||||||
|
fn($mail) => $mail->bodyText->hasAll(['erweitertes', 'bbb'])
|
||||||
|
&& $mail->bodyText->hasNot(now()->format('d.m.Y'))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders expires at date for preventions', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlymail' => EditorRequestFactory::new()->paragraphs(["{wanted}"])->toData(),
|
||||||
|
'weeks' => 4,
|
||||||
|
])->save();
|
||||||
|
createMember((['efz' => now()->subYears(5)->addWeeks(4), 'ps_at' => now(), 'has_vk' => true]));
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(YearlyMail::class, fn($mail) => $mail->bodyText->hasAll([
|
||||||
|
'erweitertes',
|
||||||
|
'am ' . now()->addWeeks(4)->format('d.m.Y'),
|
||||||
|
]) && $mail->bodyText->hasNot(now()->format('d.m.Y')));
|
||||||
|
});
|
|
@ -1,306 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature\Member;
|
|
||||||
|
|
||||||
use App\Prevention\Enums\Prevention;
|
|
||||||
use App\Form\Actions\PreventionRememberAction;
|
|
||||||
use App\Form\Enums\NamiType;
|
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use App\Invoice\InvoiceSettings;
|
|
||||||
use App\Lib\Editor\Condition;
|
|
||||||
use App\Prevention\Mails\PreventionRememberMail;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Member\Membership;
|
|
||||||
use App\Prevention\PreventionSettings;
|
|
||||||
use Generator;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
|
||||||
use Tests\Lib\CreatesFormFields;
|
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class PreventionTest extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
use DatabaseTransactions;
|
|
||||||
use CreatesFormFields;
|
|
||||||
|
|
||||||
public function testItRemembersWhenNotRememberedYet(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertEquals(now()->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberPastEvents(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$form->update(['from' => now()->subDay()]);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberWhenConditionDoesntMatch(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$form->update(['prevention_conditions' => Condition::from(['mode' => 'all', 'ifs' => [['field' => 'vorname', 'comparator' => 'isEqual', 'value' => 'Max']]])]);
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$participant->update(['data' => [...$participant->data, 'vorname' => 'Jane']]);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItRemembersWhenRememberIsDue(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = tap($this->createParticipant($form), fn ($p) => $p->update(['last_remembered_at' => now()->subWeeks(3)]));
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertEquals(now()->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberWhenRememberingIsNotDue(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = tap($this->createParticipant($form), fn ($p) => $p->update(['last_remembered_at' => now()->subWeeks(1)]));
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertEquals(now()->subWeeks(1)->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberWhenFormDoesntNeedPrevention(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = tap($this->createForm(), fn ($form) => $form->update(['needs_prevention' => false]));
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberWhenParticipantDoesntHaveMember(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$participant->member->delete();
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItRemembersNonLeaders(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$participant->member->memberships->each->delete();
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function attributes(): Generator
|
|
||||||
{
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
|
||||||
'preventions' => [Prevention::EFZ]
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => null],
|
|
||||||
'preventions' => [Prevention::PS]
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now()->subDay(), 'ps_at' => now()],
|
|
||||||
'preventions' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subDay()],
|
|
||||||
'preventions' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now()->subYears(5)->subDay(), 'ps_at' => now()],
|
|
||||||
'preventions' => [Prevention::EFZ]
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => null],
|
|
||||||
'preventions' => [Prevention::PS]
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay()],
|
|
||||||
'preventions' => [Prevention::MOREPS]
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay(), 'more_ps_at' => now()],
|
|
||||||
'preventions' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(15), 'more_ps_at' => now()->subYears(5)->subDay()],
|
|
||||||
'preventions' => [Prevention::MOREPS],
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => false, 'efz' => now(), 'ps_at' => now()],
|
|
||||||
'preventions' => [Prevention::VK],
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(7)],
|
|
||||||
'preventions' => [Prevention::MOREPS],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<int, Prevention> $preventions
|
|
||||||
* @param array<string, mixed> $memberAttributes
|
|
||||||
*/
|
|
||||||
#[DataProvider('attributes')]
|
|
||||||
public function testItRemembersMember(array $attrs, array $preventions): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$participant->member->update($attrs);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
if (count($preventions)) {
|
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn ($mail) => $mail->preventable->preventions() === $preventions);
|
|
||||||
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
|
||||||
} else {
|
|
||||||
Mail::assertNotSent(PreventionRememberMail::class);
|
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDoesntRememberParticipantThatHasNoMail(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
$participant->update(['data' => [...$participant->data, 'email' => '']]);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
Mail::assertNotSent(PreventionRememberMail::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItRendersMail(): void
|
|
||||||
{
|
|
||||||
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
(new PreventionRememberMail($participant, app(PreventionSettings::class)->formmail))
|
|
||||||
->assertSeeInText($participant->member->firstname)
|
|
||||||
->assertSeeInText($participant->member->lastname)
|
|
||||||
->assertSeeInText('Stamm Beispiel');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItRendersSetttingMail(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
app(PreventionSettings::class)->fill([
|
|
||||||
'formmail' => EditorRequestFactory::new()->paragraphs(["lorem lala {formname} g", "{wanted}", "bbb"])->toData()
|
|
||||||
])->save();
|
|
||||||
$form = $this->createForm();
|
|
||||||
$this->createParticipant($form);
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn ($mail) => $mail->bodyText->hasAll([
|
|
||||||
'lorem lala ' . $form->name,
|
|
||||||
'erweitertes'
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItAppendsTextOfForm(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
app(PreventionSettings::class)->fill([
|
|
||||||
'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 testItDoesntAppendTextTwice(): void
|
|
||||||
{
|
|
||||||
Mail::fake();
|
|
||||||
app(PreventionSettings::class)->fill(['frommail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()])->save();
|
|
||||||
tap($this->createForm(), function ($f) {
|
|
||||||
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['oberhausen'])->toData()]);
|
|
||||||
$this->createParticipant($f);
|
|
||||||
});
|
|
||||||
tap($this->createForm(), function ($f) {
|
|
||||||
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['siegburg'])->toData()]);
|
|
||||||
$this->createParticipant($f);
|
|
||||||
});
|
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
|
||||||
|
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn ($mail) => $mail->bodyText->hasAll(['oberhausen']) && !$mail->bodyText->hasAll(['siegburg']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItDisplaysBodyTextInMail(): void
|
|
||||||
{
|
|
||||||
$form = $this->createForm();
|
|
||||||
$participant = $this->createParticipant($form);
|
|
||||||
|
|
||||||
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData());
|
|
||||||
$mail->assertSeeInText('ggtt');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createForm(): Form
|
|
||||||
{
|
|
||||||
return Form::factory()->fields([
|
|
||||||
$this->textField('vorname')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::FIRSTNAME),
|
|
||||||
$this->textField('nachname')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::LASTNAME),
|
|
||||||
$this->textField('email')->namiType(NamiType::FIRSTNAME)->specialType(SpecialType::EMAIL),
|
|
||||||
])->create(['needs_prevention' => true]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createParticipant(Form $form): Participant
|
|
||||||
{
|
|
||||||
return Participant::factory()->for($form)->data([
|
|
||||||
'vorname' => 'Max',
|
|
||||||
'nachname' => 'Muster',
|
|
||||||
'email' => 'mail@a.de',
|
|
||||||
])->for(Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling')))->create();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -118,12 +118,19 @@ class ShowTest extends TestCase
|
||||||
],
|
],
|
||||||
], $response, 'data');
|
], $response, 'data');
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'activity_name' => '€ LeiterIn',
|
|
||||||
'subactivity_name' => 'Jungpfadfinder',
|
|
||||||
'id' => $member->memberships->first()->id,
|
'id' => $member->memberships->first()->id,
|
||||||
'human_date' => '19.11.2022',
|
'human_date' => '19.11.2022',
|
||||||
'promised_at' => now()->format('Y-m-d'),
|
'promised_at' => now()->format('Y-m-d'),
|
||||||
|
'activity' => [
|
||||||
|
'name' => '€ LeiterIn',
|
||||||
|
'id' => $member->memberships->first()->activity->id,
|
||||||
|
],
|
||||||
|
'subactivity' => [
|
||||||
|
'name' => 'Jungpfadfinder',
|
||||||
|
'id' => $member->memberships->first()->subactivity->id,
|
||||||
|
]
|
||||||
], $response, 'data.memberships.0');
|
], $response, 'data.memberships.0');
|
||||||
|
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'organizer' => 'DPSG',
|
'organizer' => 'DPSG',
|
||||||
'event_name' => 'Wochenende',
|
'event_name' => 'Wochenende',
|
||||||
|
|
|
@ -28,12 +28,12 @@ class IndexTest extends TestCase
|
||||||
$membership = $member->memberships->first();
|
$membership = $member->memberships->first();
|
||||||
|
|
||||||
$this->get("/member/{$member->id}/membership")
|
$this->get("/member/{$member->id}/membership")
|
||||||
->assertJsonPath('data.0.activity_id', $membership->activity_id)
|
->assertJsonPath('data.0.activity.id', $membership->activity_id)
|
||||||
->assertJsonPath('data.0.subactivity_id', $membership->subactivity_id)
|
->assertJsonPath('data.0.subactivity.id', $membership->subactivity_id)
|
||||||
->assertJsonPath('data.0.activity_name', '€ Mitglied')
|
->assertJsonPath('data.0.activity.name', '€ Mitglied')
|
||||||
->assertJsonPath('data.0.subactivity_name', 'Wölfling')
|
->assertJsonPath('data.0.subactivity.name', 'Wölfling')
|
||||||
->assertJsonPath('data.0.human_date', '02.11.2022')
|
->assertJsonPath('data.0.human_date', '02.11.2022')
|
||||||
->assertJsonPath('data.0.group_id', $group->id)
|
->assertJsonPath('data.0.group.id', $group->id)
|
||||||
->assertJsonPath('data.0.id', $membership->id)
|
->assertJsonPath('data.0.id', $membership->id)
|
||||||
->assertJsonPath('data.0.links.update', route('membership.update', ['membership' => $membership]))
|
->assertJsonPath('data.0.links.update', route('membership.update', ['membership' => $membership]))
|
||||||
->assertJsonPath('data.0.links.destroy', route('membership.destroy', ['membership' => $membership]))
|
->assertJsonPath('data.0.links.destroy', route('membership.destroy', ['membership' => $membership]))
|
||||||
|
|
|
@ -2,39 +2,73 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Prevention;
|
namespace Tests\Feature\Prevention;
|
||||||
|
|
||||||
|
use App\Member\FilterScope;
|
||||||
|
use App\Prevention\Enums\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()->withoutExceptionHandling();
|
||||||
|
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,
|
||||||
|
'weeks' => 9,
|
||||||
|
'freshRememberInterval' => 11,
|
||||||
|
'active' => true,
|
||||||
|
'preventAgainst' => [Prevention::MOREPS->name],
|
||||||
|
'yearlyMemberFilter' => FilterScope::from([
|
||||||
|
'memberships' => [['group_ids' => [33]]],
|
||||||
|
'search' => 'searchstring',
|
||||||
|
]),
|
||||||
|
])->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')
|
||||||
|
->assertJsonPath('data.weeks', '9')
|
||||||
|
->assertJsonPath('data.active', true)
|
||||||
|
->assertJsonPath('data.freshRememberInterval', '11')
|
||||||
|
->assertJsonPath('data.yearlyMemberFilter.search', 'searchstring')
|
||||||
|
->assertJsonPath('data.yearlyMemberFilter.memberships.0.group_ids.0', 33)
|
||||||
|
->assertJsonPath('data.preventAgainst', ['MOREPS'])
|
||||||
|
->assertJsonPath('meta.preventAgainsts.0.name', 'erweitertes Führungszeugnis')
|
||||||
|
->assertJsonPath('meta.preventAgainsts.0.id', 'EFZ');
|
||||||
|
});
|
||||||
|
|
||||||
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();
|
test()->post('/api/prevention', [
|
||||||
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
'formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create(),
|
||||||
}
|
'yearlymail' => EditorRequestFactory::new()->text(50, 'lala dd')->create(),
|
||||||
}
|
'weeks' => 9,
|
||||||
|
'freshRememberInterval' => 11,
|
||||||
|
'active' => true,
|
||||||
|
'preventAgainst' => ['EFZ'],
|
||||||
|
'yearlyMemberFilter' => [
|
||||||
|
'memberships' => [['group_ids' => 33]],
|
||||||
|
'search' => 'searchstring',
|
||||||
|
],
|
||||||
|
])->assertOk();
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd']));
|
||||||
|
test()->assertEquals(9, app(PreventionSettings::class)->weeks);
|
||||||
|
test()->assertEquals(11, app(PreventionSettings::class)->freshRememberInterval);
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->active);
|
||||||
|
test()->assertEquals([['group_ids' => 33]], app(PreventionSettings::class)->yearlyMemberFilter->memberships);
|
||||||
|
test()->assertEquals('searchstring', app(PreventionSettings::class)->yearlyMemberFilter->search);
|
||||||
|
test()->assertEquals('EFZ', app(PreventionSettings::class)->preventAgainst[0]);
|
||||||
|
});
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
// See <https://github.com/vuejs/vue-cli/pull/5688>
|
// See <https://github.com/vuejs/vue-cli/pull/5688>
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"types": ["vite/client"]
|
"types": ["vite/client"],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./resources/js/*"]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"include": ["**/*", "resources/js/components/components.d.ts"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,39 @@ import {defineConfig} from 'vite';
|
||||||
import laravel from 'laravel-vite-plugin';
|
import laravel from 'laravel-vite-plugin';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import Components from 'unplugin-vue-components/vite'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
|
Components({
|
||||||
|
globs: [],
|
||||||
|
directives: false,
|
||||||
|
directoryAsNamespace: false,
|
||||||
|
types: [],
|
||||||
|
dts: 'resources/js/components/components.d.ts',
|
||||||
|
resolvers: [
|
||||||
|
(componentName) => {
|
||||||
|
if (componentName === 'FMultiplefiles') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (componentName === 'FSinglefile') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (componentName.startsWith('Ui')) {
|
||||||
|
let singleComponentName = componentName.replace(/^Ui/, '');
|
||||||
|
return { name: 'default', from: `@/components/ui/${singleComponentName}.vue` };
|
||||||
|
}
|
||||||
|
if (componentName.startsWith('F')) {
|
||||||
|
let singleComponentName = componentName.replace(/^F/, '');
|
||||||
|
return { name: 'default', from: `@/components/form/${singleComponentName}.vue` };
|
||||||
|
}
|
||||||
|
if (componentName.startsWith('Page')) {
|
||||||
|
let singleComponentName = componentName.replace(/^Page/, '');
|
||||||
|
return { name: 'default', from: `@/components/page/${singleComponentName}.vue` };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}),
|
||||||
laravel(['resources/js/app.js']),
|
laravel(['resources/js/app.js']),
|
||||||
vue({
|
vue({
|
||||||
template: {
|
template: {
|
||||||
|
|
Loading…
Reference in New Issue