From feff4cb11575ccc89135f9a6d9564ea65a1adc60 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Tue, 25 Feb 2025 21:59:40 +0100 Subject: [PATCH] hide food select when selecting aftershow ticket --- assets/controllers/hide_food_controller.js | 23 ++++++++++++ templates/ticket/_partials/_form.html.twig | 43 ++++++++++++++-------- 2 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 assets/controllers/hide_food_controller.js diff --git a/assets/controllers/hide_food_controller.js b/assets/controllers/hide_food_controller.js new file mode 100644 index 0000000..d905cda --- /dev/null +++ b/assets/controllers/hide_food_controller.js @@ -0,0 +1,23 @@ +import {Controller} from "@hotwired/stimulus"; + + +export default class extends Controller { + static targets = ['foodSelect', 'ticketSelect']; + + prevValue; + + connect() { + this.hide(); + } + + hide() { + if (this.ticketSelectTarget.value === '2') { + this.foodSelectTarget.disabled = true; + this.prevValue = this.foodSelectTarget.value; + this.foodSelectTarget.value = '0'; + } else { + this.foodSelectTarget.disabled = false; + this.foodSelectTarget.value = this.prevValue ?? ''; + } + } +} \ No newline at end of file diff --git a/templates/ticket/_partials/_form.html.twig b/templates/ticket/_partials/_form.html.twig index 199089f..90ac8c4 100644 --- a/templates/ticket/_partials/_form.html.twig +++ b/templates/ticket/_partials/_form.html.twig @@ -1,13 +1,17 @@
-
+
Ticket-Typ
- - + class="w-full pl-11 pr-10 py-3.5 rounded-xl appearance-none bg-white border border-gray-200 text-gray-800 font-medium text-[15px] focus:border-orange-500 focus:ring-2 focus:ring-orange-200 transition-all hover:border-orange-300" + data-action="hide-food#hide" + data-hide-food-target="ticketSelect" + > @@ -15,7 +19,8 @@
- +
@@ -23,18 +28,23 @@
Ernährung
- - + class="w-full pl-11 pr-10 py-3.5 rounded-xl appearance-none bg-white border border-gray-200 text-gray-800 font-medium text-[15px] focus:border-orange-500 focus:ring-2 focus:ring-orange-200 transition-all hover:border-orange-300 disabled:opacity-70 disabled:bg-gray-100 disabled:cursor-not-allowed disabled:border-gray-200 disabled:text-gray-500 disabled:hover:border-gray-200" + data-hide-food-target="foodSelect" + > +
- +
@@ -42,22 +52,23 @@
Anmerkungen
- - + + class="w-full pl-11 pr-4 py-3.5 rounded-xl border border-gray-200 text-gray-800 text-[15px] placeholder-gray-400 focus:border-orange-500 focus:ring-2 focus:ring-orange-200 transition-all hover:border-orange-300"/>
-- 2.47.2