Store maildispatcher

This commit is contained in:
philipp lang 2023-06-14 23:20:37 +02:00
parent 4057f9fc8d
commit c2016af587
3 changed files with 25 additions and 12 deletions

View File

@ -2,14 +2,11 @@
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;
class MaildispatcherResource extends JsonResource
@ -46,10 +43,7 @@ class MaildispatcherResource extends JsonResource
'gateway_id' => null,
'filter' => FilterScope::from([])->toArray(),
],
'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

@ -140,6 +140,7 @@ class MemberResource extends JsonResource
'genders' => Gender::pluck('name', 'id'),
'billKinds' => BillKind::forSelect(),
'nationalities' => Nationality::pluck('name', 'id'),
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
'links' => [
'index' => route('member.index'),
'create' => route('member.create'),

View File

@ -11,12 +11,12 @@
<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">
<ui-box heading="Filterregeln" v-if="members !== null">
<div class="grid gap-4 sm:grid-cols-2">
<f-multipleselect
id="activity_ids"
name="activity_ids"
:options="meta.activities"
:options="members.meta.filterActivities"
v-model="model.filter.activity_ids"
@input="reload(1)"
label="Tätigkeit"
@ -25,7 +25,7 @@
<f-multipleselect
id="subactivity_ids"
name="subactivity_ids"
:options="meta.subactivities"
:options="members.meta.filterSubactivities"
v-model="model.filter.subactivity_ids"
@input="reload(1)"
label="Unterttätigkeit"
@ -34,13 +34,21 @@
<f-multipleselect
id="additional"
name="additional"
:options="meta.members"
:options="members.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>
<f-multipleselect
id="groupIds"
name="groupIds"
:options="members.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">
@ -69,9 +77,10 @@
<script>
import indexHelpers from '../../mixins/indexHelpers.js';
import hasFlash from '../../mixins/hasFlash.js';
export default {
mixins: [indexHelpers],
mixins: [indexHelpers, hasFlash],
data: function () {
return {
@ -95,6 +104,15 @@ export default {
})
).data;
},
async submit() {
try {
await this.axios.post('/maildispatcher', this.model);
this.$inertia.visit(this.meta.links.index);
} catch (e) {
this.errorsFromException(e);
}
},
},
async created() {