From 22157b5d508b5b47d15cabbaae1b567a1d10c1f1 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 25 Jul 2024 00:17:31 +0200 Subject: [PATCH] Add prevention items frontend --- app/Form/Actions/FormUpdateMetaAction.php | 2 +- app/Form/Models/Form.php | 2 +- app/Form/Resources/ParticipantResource.php | 6 ++- .../js/components/ui/TableToggleButton.vue | 6 ++- resources/js/views/form/Participants.vue | 37 ++++++++++--------- resources/js/views/form/Prevention.vue | 18 +++++++++ 6 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 resources/js/views/form/Prevention.vue diff --git a/app/Form/Actions/FormUpdateMetaAction.php b/app/Form/Actions/FormUpdateMetaAction.php index 4981ecdf..94480502 100644 --- a/app/Form/Actions/FormUpdateMetaAction.php +++ b/app/Form/Actions/FormUpdateMetaAction.php @@ -25,7 +25,7 @@ class FormUpdateMetaAction 'sorting.0' => 'required|string', 'sorting.1' => 'required|string|in:asc,desc', 'active_columns' => 'array', - 'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at'])] + 'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'])] ]; } diff --git a/app/Form/Models/Form.php b/app/Form/Models/Form.php index 1a58a986..6aeb2d6a 100644 --- a/app/Form/Models/Form.php +++ b/app/Form/Models/Form.php @@ -163,7 +163,7 @@ class Form extends Model implements HasMedia if (is_array(data_get($model->meta, 'active_columns'))) { $model->setAttribute('meta', [ ...$model->meta, - 'active_columns' => array_values(array_intersect([...$model->getFields()->pluck('key')->toArray(), 'created_at'], $model->meta['active_columns'])), + 'active_columns' => array_values(array_intersect([...$model->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'], $model->meta['active_columns'])), ]); return; } diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index 5808c878..aaeb6316 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -75,7 +75,11 @@ class ParticipantResource extends JsonResource 'name' => 'Registriert am', 'id' => 'created_at', 'display_attribute' => 'created_at_display' - ]) + ])->push([ + 'name' => 'Prävention', + 'id' => 'prevention', + 'display_attribute' => 'prevention_display' + ]), ]; } } diff --git a/resources/js/components/ui/TableToggleButton.vue b/resources/js/components/ui/TableToggleButton.vue index b3163b51..7a519476 100644 --- a/resources/js/components/ui/TableToggleButton.vue +++ b/resources/js/components/ui/TableToggleButton.vue @@ -9,7 +9,8 @@ > - + + @@ -24,8 +25,9 @@ const levelMap = { const props = defineProps({ text: { - required: true, + required: false, type: String, + default: () => '', }, value: { type: Object, diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index edd35a5a..62be9130 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -79,15 +79,14 @@ - -
+ + + + +
+ + +
@@ -98,15 +97,16 @@