Add mailgateway form
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Philipp Lang 2023-06-14 17:29:22 +02:00
parent d41aa466b1
commit 0080a54aaf
5 changed files with 62 additions and 25 deletions

View File

@ -3,9 +3,12 @@
namespace App\Maildispatcher\Resources;
use App\Activity;
use App\Group;
use App\Lib\HasMeta;
use App\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Resources\MailgatewayResource;
use App\Member\FilterScope;
use App\Member\Member;
use App\Subactivity;
use Illuminate\Http\Resources\Json\JsonResource;
@ -45,6 +48,9 @@ class MaildispatcherResource extends JsonResource
],
'activities' => Activity::pluck('name', 'id'),
'subactivities' => Subactivity::pluck('name', 'id'),
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
'groups' => Group::pluck('name', 'id'),
'gateways' => Mailgateway::pluck('name', 'id'),
];
}
}

View File

@ -19,6 +19,8 @@ class FilterScope extends Filter
/**
* @param array<int, int> $activityIds
* @param array<int, int> $subactivityIds
* @param array<int, int> $groupIds
* @param array<int, int> $additional
*/
public function __construct(
public bool $ausstand = false,
@ -26,7 +28,8 @@ class FilterScope extends Filter
public array $activityIds = [],
public array $subactivityIds = [],
public string $search = '',
public ?int $groupId = null,
public array $groupIds = [],
public array $additional = [],
) {
}
@ -45,29 +48,35 @@ class FilterScope extends Filter
*/
public function apply(Builder $query): Builder
{
if ($this->ausstand) {
$query->whereAusstand();
}
$query->orWhere(function ($query) {
if ($this->ausstand) {
$query->whereAusstand();
}
if ($this->billKind) {
$query->where('bill_kind', BillKind::fromValue($this->billKind));
}
if ($this->billKind) {
$query->where('bill_kind', BillKind::fromValue($this->billKind));
}
if ($this->groupId) {
$query->where('group_id', $this->groupId);
}
if (count($this->groupIds)) {
$query->whereIn('group_id', $this->groupIds);
}
if (count($this->subactivityIds) + count($this->activityIds) > 0) {
$query->whereHas('memberships', function ($q) {
$q->active();
if (count($this->subactivityIds)) {
$q->whereIn('subactivity_id', $this->subactivityIds);
}
if (count($this->activityIds)) {
$q->whereIn('activity_id', $this->activityIds);
}
});
}
if (count($this->subactivityIds) + count($this->activityIds) > 0) {
$query->whereHas('memberships', function ($q) {
$q->active();
if (count($this->subactivityIds)) {
$q->whereIn('subactivity_id', $this->subactivityIds);
}
if (count($this->activityIds)) {
$q->whereIn('activity_id', $this->activityIds);
}
});
}
})->orWhere(function ($query) {
if (count($this->additional)) {
$query->whereIn('id', $this->additional);
}
});
return $query;
}

View File

@ -10,7 +10,7 @@
class="flex items-center border-gray-600 text-gray-300 leading-none border-solid bg-gray-700 w-full appearance-none outline-none rounded-lg size-sm text-xs px-1 border pr-6"
v-text="`${value.length} Einträge ausgewählt`"
></div>
<div v-show="visible" class="absolute h-[31rem] overflow-auto shadow-lg bg-gray-600 border border-gray-500 rounded-lg p-2 top-7">
<div v-show="visible" class="absolute w-[max-content] z-30 h-[31rem] overflow-auto shadow-lg bg-gray-600 border border-gray-500 rounded-lg p-2 top-7">
<div v-for="(option, index) in parsedOptions" class="flex items-center space-x-2" :key="index">
<f-switch :id="`${id}-${index}`" size="sm" :items="value.includes(option.id)" :value="option.id" @input="trigger(option, $event)"></f-switch>
<div class="text-sm text-gray-200" v-text="option.name"></div>

View File

@ -5,6 +5,12 @@
</template>
<form id="form" class="p-3 grid gap-3" @submit.prevent="submit">
<f-save-button form="form"></f-save-button>
<ui-box heading="Metadatem">
<div class="grid gap-4 sm:grid-cols-2">
<f-text id="name" name="name" v-model="model.name" label="Name" size="sm" required></f-text>
<f-select id="gateway_id" name="gateway_id" :options="meta.gateways" v-model="model.gateway_id" label="Verbindung" size="sm" required></f-select>
</div>
</ui-box>
<ui-box heading="Filterregeln">
<div class="grid gap-4 sm:grid-cols-2">
<f-multipleselect
@ -15,7 +21,6 @@
@input="reload(1)"
label="Tätigkeit"
size="sm"
required
></f-multipleselect>
<f-multipleselect
id="subactivity_ids"
@ -25,8 +30,17 @@
@input="reload(1)"
label="Unterttätigkeit"
size="sm"
required
></f-multipleselect>
<f-multipleselect
id="additional"
name="additional"
:options="meta.members"
v-model="model.filter.additional"
@input="reload(1)"
label="Zusätzliche Mitglieder"
size="sm"
></f-multipleselect>
<f-multipleselect id="groupIds" name="groupIds" :options="meta.groups" v-model="model.filter.group_ids" @input="reload(1)" label="Gruppierungen" size="sm"></f-multipleselect>
</div>
</ui-box>
<ui-box heading="Mitglieder" v-if="members !== null">

View File

@ -22,7 +22,15 @@
<div class="px-6 py-2 flex border-b border-gray-600 items-center space-x-3">
<f-text :value="getFilter('search')" @input="setFilter('search', $event)" id="search" name="search" label="Suchen …" size="sm"></f-text>
<f-switch v-show="hasModule('bill')" id="ausstand" @input="setFilter('ausstand', $event)" :items="getFilter('ausstand')" label="Nur Ausstände" size="sm"></f-switch>
<f-select id="group_id" @input="setFilter('group_id', $event)" :options="data.meta.groups" :value="getFilter('group_id')" label="Gruppierung" size="sm" name="group_id"></f-select>
<f-multipleselect
id="group_ids"
@input="setFilter('group_ids', $event)"
:options="data.meta.groups"
:value="getFilter('group_ids')"
label="Gruppierungen"
size="sm"
name="group_ids"
></f-multipleselect>
<f-select
v-show="hasModule('bill')"
name="billKinds"