--wip-- [skip ci]
This commit is contained in:
parent
6bcea543fb
commit
29d4752749
|
@ -32,8 +32,8 @@ class ContributionFactory
|
||||||
public function compilerSelect(): Collection
|
public function compilerSelect(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->documents)->map(fn ($document) => [
|
return collect($this->documents)->map(fn ($document) => [
|
||||||
'title' => $document::buttonName(),
|
'name' => $document::buttonName(),
|
||||||
'class' => $document,
|
'id' => $document,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,16 @@ class Text extends Component
|
||||||
|
|
||||||
use HasFormDimensions;
|
use HasFormDimensions;
|
||||||
|
|
||||||
public string $id;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $name,
|
public string $name,
|
||||||
public string $size = 'default',
|
public string $size = 'default',
|
||||||
public ?string $hint = null,
|
public ?string $hint = null,
|
||||||
public bool $required = false,
|
public bool $required = false,
|
||||||
public string $label = '',
|
public string $label = '',
|
||||||
public string $type = 'text'
|
public string $type = 'text',
|
||||||
|
public string $id = ''
|
||||||
) {
|
) {
|
||||||
$this->id = str()->uuid()->toString();
|
$this->id = $this->id ? $this->id : $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Button extends Component
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return <<<'HTML'
|
return <<<'HTML'
|
||||||
<button type="{{$type}}" class="px-3 py-2 uppercase no-underline text-sm items-center justify-center bg-primary-700 rounded text-primary-300">
|
<button type="{{$type}}" {{ $attributes->merge(['class' => 'px-3 py-2 uppercase no-underline text-sm items-center justify-center bg-primary-700 rounded text-primary-300']) }}>
|
||||||
{{$slot}}
|
{{$slot}}
|
||||||
</button>
|
</button>
|
||||||
HTML;
|
HTML;
|
||||||
|
|
|
@ -104,6 +104,8 @@ services:
|
||||||
|
|
||||||
meilisearch:
|
meilisearch:
|
||||||
image: getmeili/meilisearch:v1.6
|
image: getmeili/meilisearch:v1.6
|
||||||
|
ports:
|
||||||
|
- "7700:7700"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/meilisearch:/meili_data
|
- ./data/meilisearch:/meili_data
|
||||||
env_file:
|
env_file:
|
||||||
|
|
|
@ -2,14 +2,103 @@
|
||||||
|
|
||||||
namespace Modules\Contribution\Components;
|
namespace Modules\Contribution\Components;
|
||||||
|
|
||||||
|
use App\Contribution\ContributionFactory;
|
||||||
|
use App\Country;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use App\Member\Member;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class FillList extends Component
|
class FillList extends Component
|
||||||
{
|
{
|
||||||
|
public string $eventName = '';
|
||||||
|
public Carbon $dateFrom;
|
||||||
|
public Carbon $dateUntil;
|
||||||
|
public int $country;
|
||||||
|
public $members = [];
|
||||||
|
|
||||||
|
public Collection $countries;
|
||||||
|
public string $search = '';
|
||||||
|
public Collection $compilers;
|
||||||
|
public Collection $memberResults;
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->compilers = app(ContributionFactory::class)->compilerSelect();
|
||||||
|
$this->countries = Country::select('name', 'id')->get()->toBase();
|
||||||
|
$this->clearSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit(string $compiler): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedSearch(): void
|
||||||
|
{
|
||||||
|
$this->memberResults = Member::search($this->search, fn ($engine, $query, $options) => $engine->search($query, [...$options, 'filter' => ['birthday IS NOT NULL', 'address IS NOT EMPTY']]))->get()->toBase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onSubmitFirstMemberResult(): void
|
||||||
|
{
|
||||||
|
if (count ($this->memberResults) === 0) {
|
||||||
|
$this->clearSearch();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->onSubmitMemberResult($this->memberResults[0]->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onSubmitMemberResult(int $memberId): void
|
||||||
|
{
|
||||||
|
if (in_array($memberId, $this->members)) {
|
||||||
|
$this->members = array_values(array_filter($this->members, fn ($m) => $m !== $memberId));
|
||||||
|
} else {
|
||||||
|
$this->members[] = $memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->js('document.querySelector("#search_input").focus()');
|
||||||
|
|
||||||
|
$this->clearSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearSearch(): void
|
||||||
|
{
|
||||||
|
$this->search = '';
|
||||||
|
$this->memberResults = collect([]);
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return <<<'HTML'
|
return <<<'HTML'
|
||||||
<x-page::layout title="Zuschüsse" menu="contribution">
|
<x-page::layout title="Zuschüsse" menu="contribution">
|
||||||
|
<form target="_BLANK" class="max-w-4xl w-full mx-auto gap-6 grid-cols-2 grid p-6">
|
||||||
|
<x-form::text name="event_name" wire:model="eventName" class="col-span-2" label="Veranstaltungs-Name" required></x-form::text>
|
||||||
|
<x-form::text name="date_from" wire:model="dateFrom" type="date" label="Datum von" required></x-form::text>
|
||||||
|
<x-form::text name="date_until" wire:model="dateUntil" type="date" label="Datum bis" required></x-form::text>
|
||||||
|
<x-form::text name="zipLocation" v-model="values.zipLocation" label="PLZ / Ort" required></x-form::text>
|
||||||
|
<x-form::select name="country" wire:model="country" :options="$countries" label="Land" required></x-form::select>
|
||||||
|
<x-form::select name="compiler" wire:model="compiler" :options="$compilers" label="Formular" required></x-form::select>
|
||||||
|
|
||||||
|
<x-ui::box class="col-span-2" title="Mitglieder finden">
|
||||||
|
<x-form::text name="search_text" id="search_input" wire:model.live="search" class="col-span-2" label="Suchen …" size="sm" wire:keydown.enter="onSubmitFirstMemberResult"></x-form::text>
|
||||||
|
<div class="mt-2 grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2 col-span-2">
|
||||||
|
@foreach($memberResults as $member)
|
||||||
|
<x-form::lever
|
||||||
|
id="members-{{$member->id}}"
|
||||||
|
:wire:key="$member->id"
|
||||||
|
wire:model="members"
|
||||||
|
:label="$member->fullname"
|
||||||
|
name="members"
|
||||||
|
:value="$member->id"
|
||||||
|
size="sm"
|
||||||
|
wire:keydown.enter="onSubmitMemberResult({{$member->id}})"
|
||||||
|
></x-form::lever>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</x-ui::box>
|
||||||
|
|
||||||
|
|
||||||
|
<x-ui::button class="col-span-2" type="submit">Formular erstellen</x-ui::button>
|
||||||
|
</form>
|
||||||
</x-page::layout>
|
</x-page::layout>
|
||||||
HTML;
|
HTML;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ContributionRequestFactory extends RequestFactory
|
||||||
{
|
{
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$compilers = collect(app(ContributionFactory::class)->compilerSelect())->pluck('class');
|
$compilers = collect(app(ContributionFactory::class)->compilerSelect())->pluck('id');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'country' => Country::factory()->create()->id,
|
'country' => Country::factory()->create()->id,
|
||||||
|
|
Loading…
Reference in New Issue