Add create action for maildispatcher
This commit is contained in:
parent
8f3cc95300
commit
b87b37a673
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Maildispatcher\Actions;
|
||||
|
||||
use App\Maildispatcher\Resources\MaildispatcherResource;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class CreateAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function asController(): Response
|
||||
{
|
||||
session()->put('menu', 'maildispatcher');
|
||||
session()->put('title', 'Mail-Verteiler erstellen');
|
||||
|
||||
return Inertia::render('maildispatcher/MaildispatcherForm', [
|
||||
'mode' => 'create',
|
||||
'meta' => MaildispatcherResource::meta(),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -2,14 +2,24 @@
|
|||
|
||||
namespace App\Maildispatcher\Actions;
|
||||
|
||||
use App\Maildispatcher\Models\Maildispatcher;
|
||||
use App\Maildispatcher\Resources\MaildispatcherResource;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class IndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle()
|
||||
public function asController(ActionRequest $request): Response
|
||||
{
|
||||
// ...
|
||||
session()->put('menu', 'maildispatcher');
|
||||
session()->put('title', 'Mail-Verteiler');
|
||||
|
||||
return Inertia::render('maildispatcher/MaildispatcherIndex', [
|
||||
'data' => MaildispatcherResource::collection(Maildispatcher::with('gateway')->paginate(10)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Maildispatcher\Resources;
|
||||
|
||||
use App\Activity;
|
||||
use App\Lib\HasMeta;
|
||||
use App\Mailgateway\Resources\MailgatewayResource;
|
||||
use App\Member\FilterScope;
|
||||
use App\Subactivity;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MaildispatcherResource extends JsonResource
|
||||
{
|
||||
use HasMeta;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'gateway' => new MailgatewayResource($this->whenLoaded('gateway')),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function meta(): array
|
||||
{
|
||||
return [
|
||||
'links' => [
|
||||
'create' => route('maildispatcher.create'),
|
||||
'index' => route('maildispatcher.index'),
|
||||
],
|
||||
'default_model' => [
|
||||
'name' => '',
|
||||
'gateway_id' => null,
|
||||
'filter' => FilterScope::from([])->toArray(),
|
||||
],
|
||||
'activities' => Activity::pluck('name', 'id'),
|
||||
'subactivities' => Subactivity::pluck('name', 'id'),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path d="M257,210c-24.814,0-45,20.186-45,45c0,24.814,20.186,45,45,45c24.814,0,45-20.186,45-45C302,230.186,281.814,210,257,210z
|
||||
"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path d="M255,0C114.39,0,0,114.39,0,255s114.39,257,255,257s257-116.39,257-257S395.61,0,255,0z M362,330
|
||||
c-20.273,0-38.152-10.161-49.017-25.596C299.23,319.971,279.354,330,257,330c-41.353,0-75-33.647-75-75c0-41.353,33.647-75,75-75
|
||||
c16.948,0,32.426,5.865,45,15.383V195c0-8.291,6.709-15,15-15c8.291,0,15,6.709,15,15c0,33.36,0,41.625,0,75
|
||||
c0,16.538,13.462,30,30,30c16.538,0,30-13.462,30-30c0-100.391-66.432-150-135-150c-74.443,0-135,60.557-135,135
|
||||
s60.557,135,135,135c30,0,58.374-9.609,82.061-27.803c15.822-12.078,33.94,11.765,18.281,23.789
|
||||
C328.353,408.237,293.665,420,257,420c-90.981,0-165-74.019-165-165S166.019,90,257,90c82.897,0,165,61.135,165,180
|
||||
C422,303.091,395.091,330,362,330z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -16,6 +16,7 @@
|
|||
<v-link href="/subscription" v-show="hasModule('bill')" menu="subscription" icon="money">Beiträge</v-link>
|
||||
<v-link href="/contribution" menu="contribution" icon="contribution">Zuschüsse</v-link>
|
||||
<v-link href="/activity" menu="activity" icon="activity">Tätigkeiten</v-link>
|
||||
<v-link href="/maildispatcher" menu="maildispatcher" icon="at">Mail-Verteiler</v-link>
|
||||
</div>
|
||||
<div class="grid gap-2">
|
||||
<v-link href="/setting" menu="setting" icon="setting">Einstellungen</v-link>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<template #toolbar>
|
||||
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">Zurück</page-toolbar-button>
|
||||
</template>
|
||||
<form id="form" class="p-3 grid gap-3" @submit.prevent="submit">
|
||||
<f-save-button form="form"></f-save-button>
|
||||
<ui-box heading="Filterregeln">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<f-select id="activity_id" name="activity_id" :options="meta.activities" v-model="model.activity_id" @input="reload" label="Tätigkeit" size="sm" required></f-select>
|
||||
<f-select id="subactivity_id" name="subactivity_id" :options="meta.activities" v-model="model.subactivity_id" @input="reload" label="Unterttätigkeit" size="sm" required></f-select>
|
||||
</div>
|
||||
</ui-box>
|
||||
<ui-box heading="Mitglieder">
|
||||
<div class="flex flex-col space-y-4">
|
||||
<div v-for="(pos, index) in model.children" :key="index" class="flex space-x-2 items-end">
|
||||
<f-text :id="`name-${index}`" v-model="pos.name" label="Name" size="sm" required></f-text>
|
||||
<f-text :id="`amount-${index}`" v-model="pos.amount" label="Beitrag" size="sm" mode="area" required></f-text>
|
||||
<a href="#" @click.prevent="model.children.splice(index, 1)" class="btn btn-sm btn-danger icon flex-none">
|
||||
<svg-sprite src="trash" class="w-5 h-5"></svg-sprite>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</ui-box>
|
||||
</form>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
model: this.mode === 'create' ? {...this.meta.default_model} : {...this.data},
|
||||
members: [],
|
||||
};
|
||||
},
|
||||
|
||||
props: {
|
||||
data: {},
|
||||
mode: {},
|
||||
meta: {},
|
||||
},
|
||||
|
||||
methods: {
|
||||
async reload() {
|
||||
this.members = (
|
||||
await this.axios.post('/api/member', {
|
||||
filter: this.model,
|
||||
})
|
||||
).data;
|
||||
},
|
||||
},
|
||||
|
||||
async created() {},
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,38 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<template #toolbar>
|
||||
<page-toolbar-button :href="data.meta.links.create" color="primary" icon="plus">Verteiler erstellen</page-toolbar-button>
|
||||
</template>
|
||||
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Interner Beitrag</th>
|
||||
<th>Nami-Beitrag</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
|
||||
<tr v-for="(dispatcher, index) in data.data" :key="index">
|
||||
<td>
|
||||
<div v-text="dispatcher.name"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-text="dispatcher.amount_human"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-text="dispatcher.fee_name"></div>
|
||||
</td>
|
||||
<td>
|
||||
<i-link :href="`/dispatcher/${dispatcher.id}/edit`" class="inline-flex btn btn-warning btn-sm"><svg-sprite src="pencil"></svg-sprite></i-link>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</page-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
data: {},
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -20,6 +20,8 @@ use App\Initialize\Actions\InitializeFormAction;
|
|||
use App\Initialize\Actions\NamiGetSearchLayerAction;
|
||||
use App\Initialize\Actions\NamiLoginCheckAction;
|
||||
use App\Initialize\Actions\NamiSearchAction;
|
||||
use App\Maildispatcher\Actions\CreateAction;
|
||||
use App\Maildispatcher\Actions\IndexAction;
|
||||
use App\Maildispatcher\Actions\StoreAction as MaildispatcherStoreAction;
|
||||
use App\Mailgateway\Actions\StoreAction;
|
||||
use App\Mailgateway\Actions\UpdateAction;
|
||||
|
@ -85,5 +87,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
|||
// ----------------------------------- mail ------------------------------------
|
||||
Route::post('/api/mailgateway', StoreAction::class)->name('mailgateway.store');
|
||||
Route::patch('/api/mailgateway/{mailgateway}', UpdateAction::class)->name('mailgateway.update');
|
||||
Route::post('/api/maildispatcher', MaildispatcherStoreAction::class)->name('maildispatcher.index');
|
||||
Route::get('/maildispatcher', IndexAction::class)->name('maildispatcher.index');
|
||||
Route::get('/maildispatcher/create', CreateAction::class)->name('maildispatcher.create');
|
||||
Route::post('/maildispatcher', MaildispatcherStoreAction::class)->name('maildispatcher.store');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue