Added Search function for items and fixed javascript controller
This commit is contained in:
@@ -1,11 +1,48 @@
|
||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-4 bg-gray-200 flex flex-col sm:flex-row gap-3 justify-between items-center mb-6">
|
||||
|
||||
<!-- Das universelle Suchfeld -->
|
||||
<div class="relative w-full sm:max-w-xs">
|
||||
<input type="text" placeholder="Artikel, SKU oder Besitzer..." class="py-2 px-3 pl-9 block w-full border border-gray-300 rounded-lg text-sm bg-white focus:border-blue-500 focus:ring-blue-500">
|
||||
<%# Wenn dem Partial keine feste URL übergeben wurde, nutzt es automatisch die aktuelle Browser-URL %>
|
||||
<% form_url = local_assigns[:url] || request.fullpath %>
|
||||
|
||||
<%= form_with(url: form_url, method: :get,
|
||||
data: { controller: "search-form", turbo_frame: "items_list_frame" },
|
||||
class: "w-full bg-white border border-gray-200 rounded-xl shadow-sm p-4 bg-gray-50 flex flex-col sm:flex-row gap-3 justify-between items-center mb-6") do |form| %>
|
||||
|
||||
<!-- DAS SUCHFELD (Jetzt zusätzlich an den Scanner-Controller gekoppelt) -->
|
||||
<div data-controller="scanner" class="relative w-full sm:flex-1">
|
||||
<%= form.text_field :query,
|
||||
value: params[:query],
|
||||
placeholder: "Artikel, SKU, SN oder ID...",
|
||||
data: { action: "input->search-form#submit", scanner_target: "input" },
|
||||
class: "py-2 px-3 pl-9 pr-10 block w-full border border-gray-300 rounded-lg text-sm bg-white focus:border-blue-500 focus:ring-blue-500" %>
|
||||
|
||||
<!-- Linkes Icon: Lupe -->
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||
<!-- Heroicon: magnifying-glass -->
|
||||
<svg class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.637 10.637z" /></svg>
|
||||
<svg class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.637 10.637z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- RECHTES ICON IM FELD: Der neue QR-Code-Scanner Button -->
|
||||
<button type="button"
|
||||
data-action="click->scanner#startCamera"
|
||||
class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-blue-600 transition-colors"
|
||||
title="QR-Code scannen">
|
||||
<!-- Heroicon: qr-code -->
|
||||
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v2.25c0 .621-.504 1.125-1.125 1.125h-2.25A1.125 1.125 0 0 1 3.75 7.125v-2.25ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v2.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125v-2.25ZM14.625 4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v2.25c0 .621-.504 1.125-1.125 1.125h-2.25c-.621 0-1.125-.504-1.125-1.125v-2.25ZM11.25 3.75a.75.75 0 0 1 .75.75v2.25a.75.75 0 0 1-1.5 0V4.5a.75.75 0 0 1 .75-.75ZM4.5 11.25a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H5.25a.75.75 0 0 1-.75-.75ZM11.25 10.5a.75.75 0 0 1 .75.75v2.25a.75.75 0 0 1-1.5 0v-2.25a.75.75 0 0 1 .75-.75ZM10.5 18.75a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5h-2.25a.75.75 0 0 1-.75-.75ZM18.75 10.5a.75.75 0 0 1 .75.75v2.25a.75.75 0 0 1-1.5 0v-2.25a.75.75 0 0 1 .75-.75ZM14.625 14.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v2.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125v-2.25ZM18.75 4.5a.75.75 0 0 1 .75-.75h.75c.621 0 1.125.504 1.125 1.125V5.25a.75.75 0 0 1-1.5 0V4.5h-.375a.75.75 0 0 1-.75-.75ZM19.5 18.75a.75.75 0 0 1 .75-.75h.375V17.25a.75.75 0 0 1 1.5 0v1.5c0 .621-.504 1.125-1.125 1.125h-1.5a.75.75 0 0 1-.75-.75ZM4.5 19.5v-.375a.75.75 0 0 1 1.5 0v.375h.375a.75.75 0 0 1 0 1.5h-1.5A1.125 1.125 0 0 1 3.75 19.5Z" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- (HINWEIS: Hier im Untergrund muss noch dein HTML-Modal für die Kamera-Vorschau liegen, falls das nicht global eingebunden ist) -->
|
||||
<div data-scanner-target="modal" class="hidden fixed inset-0 bg-gray-900/60 z-50 flex items-center justify-center p-4 backdrop-blur-sm">
|
||||
<div class="bg-white rounded-2xl max-w-md w-full p-6 space-y-4 shadow-xl border border-gray-100">
|
||||
<div class="flex justify-between items-center">
|
||||
<h3 class="text-sm font-bold text-gray-800 uppercase tracking-wide">Inventar-Sticker scannen</h3>
|
||||
<button type="button" data-action="click->scanner#stopCamera" class="p-1 text-gray-400 hover:text-gray-600 rounded-lg">
|
||||
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div id="search-reader" data-scanner-target="preview" class="w-full aspect-square rounded-xl overflow-hidden border border-gray-200 bg-gray-50"></div>
|
||||
<p class="text-xs text-gray-500 text-center">Halte den QR-Code des Geräts ruhig in den Scan-Rahmen.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +56,7 @@
|
||||
<span>CSV</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<!-- Universeller Filter-Button -->
|
||||
<button class="py-2 px-3 border border-gray-300 rounded-lg text-sm font-medium bg-white text-gray-700 hover:bg-gray-50 flex items-center gap-1.5 shadow-sm transition">
|
||||
<!-- Heroicon: funnel -->
|
||||
@@ -28,4 +65,4 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user