From 5c9e6a34b45f51475316e3490621ff3c050145a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Sat, 30 May 2026 00:02:02 +0200 Subject: [PATCH] Added QR Scanner to more input fields --- app/views/items/_form.html.erb | 75 +++++++++++++++++--------- app/views/items/_search_bar.html.erb | 19 +------ app/views/layouts/_scanner.html.erb | 17 ++++++ app/views/layouts/application.html.erb | 1 + config/application.rb | 3 ++ 5 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 app/views/layouts/_scanner.html.erb diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb index 86b47c3..8b90316 100644 --- a/app/views/items/_form.html.erb +++ b/app/views/items/_form.html.erb @@ -28,18 +28,41 @@ <%= form.label :name, "Artikelname / Modell", class: "block text-sm font-medium mb-1.5 text-gray-700" %> <%= form.text_field :name, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> -
+ +
<%= form.label :sku, "SKU (Artikelnummer)", class: "block text-sm font-medium mb-1.5 text-gray-700" %> - <%= form.text_field :sku, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> +
+ <%= form.text_field :sku, data: { scanner_target: "input" }, class: "py-2 px-3 block w-full border border-gray-300 rounded-l-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> + +
+ + <%= render "layouts/scanner" %>
- <%= form.label :serial_number, "Seriennummer (Hersteller)", class: "block text-sm font-medium mb-1.5 text-gray-700" %> - <%= form.text_field :serial_number, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> + +
+ <%= form.label :serial_number, "Seriennummer (Hersteller)", class: "block text-sm font-medium mb-1.5 text-gray-700" %> +
+ <%= form.text_field :serial_number, data: { scanner_target: "input" }, class: "py-2 px-3 blck w-full border border-gray-300 rounded-l-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> + +
+ + <%= render "layouts/scanner" %> +
+
<%= form.label :price, "Einkaufspreis (€)", class: "block text-sm font-medium mb-1.5 text-gray-700" %> <%= form.text_field :price, placeholder: "0.00", class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %> @@ -53,14 +76,18 @@
-
+
<%= form.label :sticker_id, "Vorgedruckte Sticker-ID / QR-Nummer", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
<%= form.text_field :sticker_id, data: { scanner_target: "input" }, class: "py-2 px-3 block w-full border border-gray-300 rounded-l-lg text-sm bg-gray-50/50 focus:border-blue-500 focus:ring-blue-500" %>
+ + <%= render "layouts/scanner" %>
@@ -91,12 +118,12 @@ <%= turbo_frame_tag "item_assignment_frame" do %> <% current_type = if item.user_id.present? - "user" - elsif item.room_id.present? - "room" - else - "storage" - end + "user" + elsif item.room_id.present? + "room" + else + "storage" + end type = params[:assignment_type] || current_type %> @@ -128,12 +155,12 @@
+ id="item_user_name" + name="item[user_name]" + list="users_datalist" + value="<%= item.user&.name %>" + class="py-2.5 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-white focus:border-blue-500 focus:ring-blue-500" + placeholder="Tippe den Namen ein..."> <% User.all.order(:first_name, :last_name).each do |user| %> @@ -151,12 +178,12 @@
+ id="item_room_name" + name="item[room_name]" + list="rooms_datalist" + value="<%= item.room&.name %>" + class="py-2.5 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-white focus:border-blue-500 focus:ring-blue-500" + placeholder="Tippe die Raumnummer ein..."> <% Room.all.order(:name).each do |room| %> diff --git a/app/views/items/_search_bar.html.erb b/app/views/items/_search_bar.html.erb index 2c4af61..43489d7 100644 --- a/app/views/items/_search_bar.html.erb +++ b/app/views/items/_search_bar.html.erb @@ -30,24 +30,9 @@ + + <%= render "layouts/scanner" %> - -
diff --git a/app/views/layouts/_scanner.html.erb b/app/views/layouts/_scanner.html.erb new file mode 100644 index 0000000..45537b0 --- /dev/null +++ b/app/views/layouts/_scanner.html.erb @@ -0,0 +1,17 @@ + + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 097b358..1bca694 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -137,6 +137,7 @@ <%= yield %>
+
<%= turbo_frame_tag "modal" %> diff --git a/config/application.rb b/config/application.rb index 25a2058..29e65ba 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,6 +22,9 @@ module Vault171 # Erlaubt Rails, auch Unterordner in locales zu durchsuchen config.i18n.available_locales = [ :de, :en ] + # Deaktiviert das umschließende field_with_errors Div bei Validierungsfehlern + config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag.html_safe } + # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files