diff --git a/app/Form/Actions/FormDestroyAction.php b/app/Form/Actions/FormDestroyAction.php new file mode 100644 index 00000000..31cb1d8d --- /dev/null +++ b/app/Form/Actions/FormDestroyAction.php @@ -0,0 +1,19 @@ +delete(); + + Succeeded::message('Veranstaltung gelöscht.')->dispatch(); + } +} diff --git a/app/Form/Actions/FormIndexAction.php b/app/Form/Actions/FormIndexAction.php index 092cfaf9..57070597 100644 --- a/app/Form/Actions/FormIndexAction.php +++ b/app/Form/Actions/FormIndexAction.php @@ -23,6 +23,9 @@ class FormIndexAction public function asController(): Response { + session()->put('menu', 'form'); + session()->put('title', 'Veranstaltungen'); + return Inertia::render('form/Index', [ 'data' => FormResource::collection($this->handle()), ]); diff --git a/app/Form/Actions/FormStoreAction.php b/app/Form/Actions/FormStoreAction.php index d83b61ab..14d0e284 100644 --- a/app/Form/Actions/FormStoreAction.php +++ b/app/Form/Actions/FormStoreAction.php @@ -21,7 +21,7 @@ class FormStoreAction return [ ...$this->globalRules(), 'description' => 'required|string', - 'excerpt' => 'required|string|max:120', + 'excerpt' => 'required|string|max:130', 'from' => 'required|date', 'to' => 'required|date', 'registration_from' => 'present|nullable|date', @@ -55,7 +55,7 @@ class FormStoreAction { $this->handle($request->validated()); - Succeeded::message('Formular gespeichert.')->dispatch(); + Succeeded::message('Veranstaltung gespeichert.')->dispatch(); return response()->json([]); } } diff --git a/app/Form/Actions/FormUpdateAction.php b/app/Form/Actions/FormUpdateAction.php new file mode 100644 index 00000000..1ab2dabd --- /dev/null +++ b/app/Form/Actions/FormUpdateAction.php @@ -0,0 +1,62 @@ + + */ + public function rules(): array + { + return [ + ...$this->globalRules(), + 'description' => 'required|string', + 'excerpt' => 'required|string|max:130', + 'from' => 'required|date', + 'to' => 'required|date', + 'registration_from' => 'present|nullable|date', + 'registration_until' => 'present|nullable|date', + 'mail_top' => 'nullable|string', + 'mail_bottom' => 'nullable|string', + ]; + } + + /** + * @param array $attributes + */ + public function handle(Form $form, array $attributes): Form + { + $form->update($attributes); + return $form; + } + + /** + * @return array + */ + public function getValidationAttributes(): array + { + return [ + ...$this->globalValidationAttributes(), + 'from' => 'Start', + 'to' => 'Ende', + ]; + } + + public function asController(Form $form, ActionRequest $request): JsonResponse + { + $this->handle($form, $request->validated()); + + Succeeded::message('Veranstaltung aktualisiert.')->dispatch(); + return response()->json([]); + } +} diff --git a/app/Form/Actions/FormtemplateIndexAction.php b/app/Form/Actions/FormtemplateIndexAction.php index 11302620..91560bbf 100644 --- a/app/Form/Actions/FormtemplateIndexAction.php +++ b/app/Form/Actions/FormtemplateIndexAction.php @@ -23,7 +23,7 @@ class FormtemplateIndexAction public function asController(): Response { - session()->put('menu', 'formtemplate'); + session()->put('menu', 'form'); session()->put('title', 'Formular-Vorlagen'); return Inertia::render('formtemplate/Index', [ diff --git a/app/Form/Resources/FormResource.php b/app/Form/Resources/FormResource.php index 79f1a32c..bdd46034 100644 --- a/app/Form/Resources/FormResource.php +++ b/app/Form/Resources/FormResource.php @@ -2,8 +2,10 @@ namespace App\Form\Resources; +use App\Form\Fields\Field; use App\Form\Models\Form; use App\Form\Models\Formtemplate; +use App\Group; use App\Lib\HasMeta; use Illuminate\Http\Resources\Json\JsonResource; @@ -24,6 +26,7 @@ class FormResource extends JsonResource public function toArray($request) { return [ + 'id' => $this->id, 'name' => $this->name, 'from_human' => $this->from?->format('d.m.Y'), 'to_human' => $this->to?->format('d.m.Y'), @@ -36,16 +39,41 @@ class FormResource extends JsonResource 'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'), 'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'), 'config' => $this->config, + 'links' => [ + 'update' => route('form.update', ['form' => $this->getModel()]), + 'destroy' => route('form.destroy', ['form' => $this->getModel()]), + ] ]; } public static function meta(): array { return [ + 'base_url' => url(''), + 'groups' => Group::forSelect(), + 'fields' => Field::asMeta(), 'links' => [ 'store' => route('form.store'), + 'formtemplate_index' => route('formtemplate.index'), ], 'templates' => FormtemplateResource::collection(Formtemplate::get()), + 'default' => [ + 'description' => '', + 'name' => '', + 'excerpt' => '', + 'from' => null, + 'to' => null, + 'registration_from' => null, + 'registration_until' => null, + 'mail_top' => null, + 'mail_bottom' => null, + 'config' => null, + ], + 'section_default' => [ + 'name' => '', + 'intro' => '', + 'fields' => [], + ] ]; } } diff --git a/app/Form/Resources/FormtemplateResource.php b/app/Form/Resources/FormtemplateResource.php index 645b9ae2..ec988b15 100644 --- a/app/Form/Resources/FormtemplateResource.php +++ b/app/Form/Resources/FormtemplateResource.php @@ -44,6 +44,7 @@ class FormtemplateResource extends JsonResource 'fields' => Field::asMeta(), 'links' => [ 'store' => route('formtemplate.store'), + 'form_index' => route('form.index'), ], 'default' => [ 'name' => '', diff --git a/resources/img/svg/event.svg b/resources/img/svg/event.svg new file mode 100644 index 00000000..dbfa9150 --- /dev/null +++ b/resources/img/svg/event.svg @@ -0,0 +1 @@ + diff --git a/resources/js/components/ui/Menulist.vue b/resources/js/components/ui/Menulist.vue new file mode 100644 index 00000000..d4cadd6e --- /dev/null +++ b/resources/js/components/ui/Menulist.vue @@ -0,0 +1,23 @@ + + + diff --git a/resources/js/components/ui/Tabs.vue b/resources/js/components/ui/Tabs.vue index f3c731c9..ed696c37 100644 --- a/resources/js/components/ui/Tabs.vue +++ b/resources/js/components/ui/Tabs.vue @@ -1,17 +1,10 @@ diff --git a/resources/js/layouts/AppLayout.vue b/resources/js/layouts/AppLayout.vue index 616a3c49..3e9dfdab 100644 --- a/resources/js/layouts/AppLayout.vue +++ b/resources/js/layouts/AppLayout.vue @@ -2,13 +2,11 @@ -
+ }">
Dashboard Mitglieder @@ -17,6 +15,7 @@ Zuschüsse Tätigkeiten Gruppierungen + Veranstaltungen Mail-Verteiler
@@ -39,7 +38,7 @@ diff --git a/resources/js/views/formtemplate/Index.vue b/resources/js/views/formtemplate/Index.vue index 53489135..22ebcb11 100644 --- a/resources/js/views/formtemplate/Index.vue +++ b/resources/js/views/formtemplate/Index.vue @@ -2,6 +2,8 @@
- +
diff --git a/routes/web.php b/routes/web.php index 90d61383..cf298b0f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,6 +19,7 @@ use App\Invoice\Actions\InvoiceStoreAction; use App\Course\Actions\CourseUpdateAction; use App\Dashboard\Actions\IndexAction as DashboardIndexAction; use App\Efz\ShowEfzDocumentAction; +use App\Form\Actions\FormDestroyAction; use App\Form\Actions\FormIndexAction; use App\Group\Actions\GroupApiIndexAction; use App\Group\Actions\GroupBulkstoreAction; @@ -27,6 +28,7 @@ use App\Form\Actions\FormStoreAction; use App\Form\Actions\FormtemplateIndexAction; use App\Form\Actions\FormtemplateStoreAction; use App\Form\Actions\FormtemplateUpdateAction; +use App\Form\Actions\FormUpdateAction; use App\Initialize\Actions\InitializeAction; use App\Initialize\Actions\InitializeFormAction; use App\Initialize\Actions\NamiGetSearchLayerAction; @@ -148,6 +150,8 @@ Route::group(['middleware' => 'auth:web'], function (): void { // ------------------------------------ form ----------------------------------- Route::get('/formtemplate', FormtemplateIndexAction::class)->name('formtemplate.index'); Route::get('/form', FormIndexAction::class)->name('form.index'); + Route::patch('/form/{form}', FormUpdateAction::class)->name('form.update'); + Route::delete('/form/{form}', FormDestroyAction::class)->name('form.destroy'); Route::post('/formtemplate', FormtemplateStoreAction::class)->name('formtemplate.store'); Route::patch('/formtemplate/{formtemplate}', FormtemplateUpdateAction::class)->name('formtemplate.update'); Route::post('/form', FormStoreAction::class)->name('form.store'); diff --git a/tests/Feature/Form/FormIndexActionTest.php b/tests/Feature/Form/FormIndexActionTest.php index ec70799e..0dc56a7f 100644 --- a/tests/Feature/Form/FormIndexActionTest.php +++ b/tests/Feature/Form/FormIndexActionTest.php @@ -16,7 +16,7 @@ class FormIndexActionTest extends TestCase { $this->login()->loginNami()->withoutExceptionHandling(); Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')->create()])->create(); - Form::factory() + $form = Form::factory() ->name('lala') ->excerpt('fff') ->description('desc') @@ -33,6 +33,7 @@ class FormIndexActionTest extends TestCase ->assertOk() ->assertInertiaPath('data.data.0.config.sections.0.name', 'sname') ->assertInertiaPath('data.data.0.name', 'lala') + ->assertInertiaPath('data.data.0.id', $form->id) ->assertInertiaPath('data.data.0.excerpt', 'fff') ->assertInertiaPath('data.data.0.description', 'desc') ->assertInertiaPath('data.data.0.mail_top', 'Guten Tag') @@ -44,7 +45,12 @@ class FormIndexActionTest extends TestCase ->assertInertiaPath('data.data.0.registration_from', '2023-05-06 04:00:00') ->assertInertiaPath('data.data.0.registration_until', '2023-04-01 05:00:00') ->assertInertiaPath('data.meta.links.store', route('form.store')) + ->assertInertiaPath('data.meta.links.formtemplate_index', route('formtemplate.index')) ->assertInertiaPath('data.meta.templates.0.name', 'tname') - ->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname'); + ->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname') + ->assertInertiaPath('data.meta.default.name', '') + ->assertInertiaPath('data.meta.default.description', '') + ->assertInertiaPath('data.meta.default.excerpt', '') + ->assertInertiaPath('data.meta.default.config', null); } } diff --git a/tests/Feature/Form/FormtemplateIndexActionTest.php b/tests/Feature/Form/FormtemplateIndexActionTest.php index 2fc96b9c..a358fd0a 100644 --- a/tests/Feature/Form/FormtemplateIndexActionTest.php +++ b/tests/Feature/Form/FormtemplateIndexActionTest.php @@ -71,6 +71,7 @@ class FormtemplateIndexActionTest extends TestCase ] ]) ->assertInertiaPath('data.meta.links.store', route('formtemplate.store')) + ->assertInertiaPath('data.meta.links.form_index', route('form.index')) ->assertInertiaPath('data.meta.section_default', [ 'name' => '', 'intro' => '',