--wip-- [skip ci]
This commit is contained in:
parent
f2c54363f2
commit
381a7f9023
|
@ -104,6 +104,8 @@ services:
|
|||
|
||||
meilisearch:
|
||||
image: getmeili/meilisearch:v1.6
|
||||
ports:
|
||||
- "7700:7700"
|
||||
volumes:
|
||||
- ./data/meilisearch:/meili_data
|
||||
env_file:
|
||||
|
|
|
@ -2,14 +2,107 @@
|
|||
|
||||
namespace Modules\Contribution\Components;
|
||||
|
||||
use App\Contribution\ContributionFactory;
|
||||
use App\Country;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Member\Member;
|
||||
use Livewire\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();
|
||||
}
|
||||
|
||||
/** @todo implement compilation of document */
|
||||
public function submit(): 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()
|
||||
{
|
||||
return <<<'HTML'
|
||||
<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>
|
||||
HTML;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue