Added Search function for items and fixed javascript controller
This commit is contained in:
@@ -9,7 +9,17 @@ class CategoriesController < ApplicationController
|
|||||||
# GET /categories/1 or /categories/1.json
|
# GET /categories/1 or /categories/1.json
|
||||||
def show
|
def show
|
||||||
@category = Category.find(params[:id])
|
@category = Category.find(params[:id])
|
||||||
@items = @category.items.includes(:user, :room).order(:name)
|
|
||||||
|
# Basis-Abfrage: Alle Items dieser Kategorie laden
|
||||||
|
@items = @category.items.includes(:user, :room).order(created_at: :desc)
|
||||||
|
|
||||||
|
if params[:query].present?
|
||||||
|
query_str = "%#{params[:query]}%"
|
||||||
|
@items = @items.where(
|
||||||
|
"items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q",
|
||||||
|
q: query_str
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /categories/new
|
# GET /categories/new
|
||||||
|
|||||||
@@ -5,6 +5,15 @@ class ItemsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@items = Item.all.includes(:category, :user, :room).order(created_at: :desc)
|
@items = Item.all.includes(:category, :user, :room).order(created_at: :desc)
|
||||||
|
|
||||||
|
if params[:query].present?
|
||||||
|
query_str = "%#{params[:query]}%"
|
||||||
|
# Durchsucht Name, SKU, Seriennummer und deine Sticker-ID gleichzeitig
|
||||||
|
@items = @items.where(
|
||||||
|
"items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q",
|
||||||
|
q: query_str
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # Rendert ganz normal deine Bestandsliste im Browser
|
format.html # Rendert ganz normal deine Bestandsliste im Browser
|
||||||
format.csv do
|
format.csv do
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
import { Controller } from "@hotwire/stimulus"
|
// Wird der controller überhaupt gebraucht? Funktioniert auch ohne.. ;)
|
||||||
|
|
||||||
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = [ "userSection", "roomSection" ]
|
static targets = ["userSection", "roomSection"];
|
||||||
|
|
||||||
toggle(event) {
|
toggle(event) {
|
||||||
const value = event.target.value
|
const value = event.target.value;
|
||||||
const userDropdown = this.userSectionTarget.querySelector('select')
|
const userDropdown = this.userSectionTarget.querySelector("select");
|
||||||
const roomDropdown = this.roomSectionTarget.querySelector('select')
|
const roomDropdown = this.roomSectionTarget.querySelector("select");
|
||||||
|
|
||||||
if (value === "user") {
|
if (value === "user") {
|
||||||
this.userSectionTarget.classList.remove("hidden")
|
this.userSectionTarget.classList.remove("hidden");
|
||||||
this.roomSectionTarget.classList.add("hidden")
|
this.roomSectionTarget.classList.add("hidden");
|
||||||
roomDropdown.value = "" // Raum-ID löschen, da ein Artikel nur einen Inhaber haben kann
|
roomDropdown.value = ""; // Raum-ID löschen, da ein Artikel nur einen Inhaber haben kann
|
||||||
} else if (value === "room") {
|
} else if (value === "room") {
|
||||||
this.roomSectionTarget.classList.remove("hidden")
|
this.roomSectionTarget.classList.remove("hidden");
|
||||||
this.userSectionTarget.classList.add("hidden")
|
this.userSectionTarget.classList.add("hidden");
|
||||||
userDropdown.value = "" // User-ID löschen
|
userDropdown.value = ""; // User-ID löschen
|
||||||
} else {
|
} else {
|
||||||
// Hauptlager ausgewählt -> Beide ausblenden und Werte in der DB nullen
|
// Hauptlager ausgewählt -> Beide ausblenden und Werte in der DB nullen
|
||||||
this.userSectionTarget.classList.add("hidden")
|
this.userSectionTarget.classList.add("hidden");
|
||||||
this.roomSectionTarget.classList.add("hidden")
|
this.roomSectionTarget.classList.add("hidden");
|
||||||
userDropdown.value = ""
|
userDropdown.value = "";
|
||||||
roomDropdown.value = ""
|
roomDropdown.value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,58 @@
|
|||||||
import { Controller } from "@hotwire/stimulus"
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = [ "input", "preview", "modal" ]
|
static targets = ["input", "preview", "modal"];
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
this.html5QrCode = null
|
this.html5QrCode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Öffnet das Modal und startet den Kamera-Stream
|
// Öffnet das Modal und startet den Kamera-Stream
|
||||||
startCamera(event) {
|
startCamera(event) {
|
||||||
event.preventDefault()
|
event.preventDefault();
|
||||||
|
|
||||||
// Modal anzeigen
|
// Modal anzeigen
|
||||||
this.modalTarget.classList.remove("hidden")
|
this.modalTarget.classList.remove("hidden");
|
||||||
|
|
||||||
// Neue Instanz auf dem Preview-Div mit der ID des Elements erzeugen
|
// Neue Instanz auf dem Preview-Div mit der ID des Elements erzeugen
|
||||||
this.html5QrCode = new Html5Qrcode(this.previewTarget.id)
|
this.html5QrCode = new Html5Qrcode(this.previewTarget.id);
|
||||||
|
|
||||||
// FPS-Rate und Scan-Rahmen (250x250px) festlegen
|
// FPS-Rate und Scan-Rahmen (250x250px) festlegen
|
||||||
const config = { fps: 10, qrbox: { width: 250, height: 250 } }
|
const config = { fps: 10, qrbox: { width: 250, height: 250 } };
|
||||||
|
|
||||||
this.html5QrCode.start(
|
this.html5QrCode
|
||||||
{ facingMode: "environment" }, // Erzwingt die rückseitige Hauptkamera bei Handys
|
.start(
|
||||||
config,
|
{ facingMode: "environment" }, // Erzwingt die rückseitige Hauptkamera bei Handys
|
||||||
(decodedText, decodedResult) => {
|
config,
|
||||||
// SUCCESS: Code erkannt!
|
(decodedText, decodedResult) => {
|
||||||
this.inputTarget.value = decodedText // Trägt die ID (z.B. 10024) ins Textfeld ein
|
// SUCCESS: Code erkannt!
|
||||||
this.stopCamera() // Stoppt die Kamera und schließt das Fenster
|
this.inputTarget.value = decodedText; // Trägt die ID (z.B. 10024) ins Textfeld ein
|
||||||
},
|
|
||||||
(errorMessage) => {
|
// NEU: Simuliert das Tippen, damit dein search-form Controller die Live-Suche sofort startet!
|
||||||
// Kontinuierlicher Scan-Loop (Fehler ignorieren, wenn kein QR-Code im Bild ist)
|
this.inputTarget.dispatchEvent(new Event("input", { bubbles: true }));
|
||||||
}
|
|
||||||
).catch((err) => {
|
this.stopCamera(); // Stoppt die Kamera und schließt das Fenster
|
||||||
console.error("Kamera-Zugriff verweigert oder blockiert:", err)
|
},
|
||||||
})
|
(errorMessage) => {
|
||||||
|
// Kontinuierlicher Scan-Loop (Fehler ignorieren, wenn kein QR-Code im Bild ist)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Kamera-Zugriff verweigert oder blockiert:", err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schließt das Modal und beendet den Stream sauber
|
// Schließt das Modal und beendet den Stream sauber
|
||||||
stopCamera() {
|
stopCamera() {
|
||||||
if (this.html5QrCode && this.html5QrCode.isScanning) {
|
if (this.html5QrCode && this.html5QrCode.isScanning) {
|
||||||
this.html5QrCode.stop().then(() => {
|
this.html5QrCode
|
||||||
this.modalTarget.classList.add("hidden")
|
.stop()
|
||||||
}).catch((err) => console.error("Fehler beim Beenden des Streams:", err))
|
.then(() => {
|
||||||
|
this.modalTarget.classList.add("hidden");
|
||||||
|
})
|
||||||
|
.catch((err) => console.error("Fehler beim Beenden des Streams:", err));
|
||||||
} else {
|
} else {
|
||||||
this.modalTarget.classList.add("hidden")
|
this.modalTarget.classList.add("hidden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
app/javascript/controllers/search_form_controller.js
Normal file
11
app/javascript/controllers/search_form_controller.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
submit() {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
// Wartet 200ms nach dem letzten Tastendruck, bevor gesucht wird
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
this.element.requestSubmit();
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,28 +8,25 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="w-full space-y-6">
|
<div class="w-full space-y-6">
|
||||||
<!-- Beschreibungskarte -->
|
<!-- Beschreibungskarte der Kategorie -->
|
||||||
<div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
|
<div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
|
||||||
<h2 class="text-sm font-bold text-gray-400 uppercase tracking-wider">Beschreibung</h2>
|
<h2 class="text-sm font-bold text-gray-400 uppercase tracking-wider">Beschreibung</h2>
|
||||||
<p class="text-sm text-gray-600 mt-1 leading-relaxed"><%= @category.description.presence || "Keine Beschreibung hinterlegt." %></p>
|
<p class="text-sm text-gray-600 mt-1 leading-relaxed"><%= @category.description.presence || "Keine Beschreibung hinterlegt." %></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<!-- 1. Gleiche Suchleiste laden (CSV-Export bleibt hier deaktiviert!) -->
|
<!-- 1. Suchleiste steht außerhalb des Frames (CSV-Export hier auf 'false') -->
|
||||||
<%= render "items/search_bar", show_csv: false %>
|
<%= render "items/search_bar", show_csv: false %>
|
||||||
|
|
||||||
<!-- 2. Artikelliste laden -->
|
<!-- 2. NUR DAS LIST-PARTIAL WIRD IN DEN FRAME GEPAKT -->
|
||||||
<% if @items.any? %>
|
<%= turbo_frame_tag "items_list_frame" do %>
|
||||||
<%= render "items/list", items: @items %>
|
<% if @items.any? %>
|
||||||
<% else %>
|
<%= render "items/list", items: @items %>
|
||||||
<div class="text-center py-16 text-gray-400 bg-white border border-gray-200 rounded-xl shadow-sm">
|
<% else %>
|
||||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
<div class="text-center py-12 text-gray-400 bg-white border border-gray-200 rounded-xl shadow-sm">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l5.25 3.03M12 12.75v9" />
|
<p class="text-sm">Keine passenden Artikel in dieser Kategorie gefunden.</p>
|
||||||
</svg>
|
</div>
|
||||||
<p class="text-sm mt-3 font-medium">Bisher sind keine Inventargegenstände erfasst.</p>
|
<% end %>
|
||||||
<p class="text-xs text-gray-400 mt-1">Klicke oben rechts auf "Artikel hinzufügen", um das erste Gerät einzubuchen.</p>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
||||||
|
|
||||||
<!-- ========================================================================= -->
|
<!-- ========================================================================= -->
|
||||||
<!-- 1. HANDY-ANSICHT: OPTIMIERTE INVENTAR-CARDS (md:hidden) -->
|
<!-- 1. HANDY-ANSICHT: OPTIMIERTE INVENTAR-CARDS (md:hidden) -->
|
||||||
<!-- ========================================================================= -->
|
<!-- ========================================================================= -->
|
||||||
<div class="block md:hidden divide-y divide-gray-200 bg-white">
|
<div class="block md:hidden divide-y divide-gray-200 bg-white">
|
||||||
<% items.each do |item| %>
|
<% items.each do |item| %>
|
||||||
<div class="p-4 space-y-3 hover:bg-gray-50/50 transition">
|
<div class="p-4 space-y-3 hover:bg-gray-50/50 transition">
|
||||||
|
|
||||||
<!-- Zeile 1: Name, Kategorie & die markante Sticker-ID Plakette -->
|
<!-- Zeile 1: Name, Kategorie & die markante Sticker-ID Plakette -->
|
||||||
<div class="flex justify-between items-start gap-3">
|
<div class="flex justify-between items-start gap-3">
|
||||||
<div class="min-w-0">
|
<div class="min-w-0">
|
||||||
<h4 class="font-bold text-gray-900 text-sm leading-snug truncate"><%= item.name %></h4>
|
<h4 class="font-bold text-gray-900 text-sm leading-snug truncate"><%= item.name %></h4>
|
||||||
<p class="text-xs text-gray-500 font-medium mt-0.5"><%= item.category.name %></p>
|
<p class="text-xs text-gray-500 font-medium mt-0.5"><%= item.category.name %></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Rechte Box für ID und den optimal platzierten Preis direkt darunter -->
|
<!-- Rechte Box für ID und den optimal platzierten Preis direkt darunter -->
|
||||||
<div class="flex flex-col items-end gap-1.5 shrink-0">
|
<div class="flex flex-col items-end gap-1.5 shrink-0">
|
||||||
<span class="inline-flex items-center font-mono font-black text-xs text-white bg-blue-600 px-2.5 py-1 rounded-md shadow-sm tracking-wider">
|
<span class="inline-flex items-center font-mono font-black text-xs text-white bg-blue-600 px-2.5 py-1 rounded-md shadow-sm tracking-wider">
|
||||||
@@ -58,10 +58,17 @@
|
|||||||
|
|
||||||
<!-- Aktions-Icons -->
|
<!-- Aktions-Icons -->
|
||||||
<div class="flex items-center gap-1 shrink-0">
|
<div class="flex items-center gap-1 shrink-0">
|
||||||
<%= link_to item_path(item), class: "p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-lg border border-gray-200 bg-white shadow-sm" do %>
|
<!-- DETAILS BUTTON mit _top Ausbruch -->
|
||||||
|
<%= link_to item_path(item),
|
||||||
|
data: { turbo_frame: "_top" },
|
||||||
|
class: "p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-lg border border-gray-200 bg-white shadow-sm" do %>
|
||||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to edit_item_path(item), class: "p-2 text-gray-500 hover:text-amber-600 hover:bg-amber-50 rounded-lg border border-gray-200 bg-white shadow-sm" do %>
|
|
||||||
|
<!-- BEARBEITEN BUTTON mit _top Ausbruch -->
|
||||||
|
<%= link_to edit_item_path(item),
|
||||||
|
data: { turbo_frame: "_top" },
|
||||||
|
class: "p-2 text-gray-500 hover:text-amber-600 hover:bg-amber-50 rounded-lg border border-gray-200 bg-white shadow-sm" do %>
|
||||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /></svg>
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /></svg>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -103,23 +110,33 @@
|
|||||||
<span class="inline-flex items-center py-0.5 px-2 rounded-full text-xs font-medium bg-amber-50 text-amber-800 border border-amber-200">📦 Im Hauptlager</span>
|
<span class="inline-flex items-center py-0.5 px-2 rounded-full text-xs font-medium bg-amber-50 text-amber-800 border border-amber-200">📦 Im Hauptlager</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- STICKER-ID ALS BADGE (Jetzt auch in der Desktop-Tabelle markant) -->
|
<!-- STICKER-ID ALS BADGE (Jetzt auch in der Desktop-Tabelle markant) -->
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
<span class="inline-flex items-center font-mono font-bold text-xs text-white bg-blue-600 px-2 py-0.5 rounded shadow-sm tracking-wider">
|
<span class="inline-flex items-center font-mono font-bold text-xs text-white bg-blue-600 px-2 py-0.5 rounded shadow-sm tracking-wider">
|
||||||
#<%= item.sticker_id %>
|
#<%= item.sticker_id %>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-gray-900">
|
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-gray-900">
|
||||||
<%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
|
<%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
|
||||||
</td>
|
</td>
|
||||||
|
<!-- In der Schleife der Desktop-Tabelle (_list.html.erb) -->
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-xs">
|
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-xs">
|
||||||
<div class="flex items-center justify-end gap-2">
|
<div class="flex items-center justify-end gap-2">
|
||||||
<%= link_to item_path(item), class: "p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-colors border border-transparent hover:border-blue-100", title: "Details anzeigen" do %>
|
<!-- DETAILS ICON mit _top Ausbruch -->
|
||||||
|
<%= link_to item_path(item),
|
||||||
|
data: { turbo_frame: "_top" },
|
||||||
|
class: "p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-colors border border-transparent hover:border-blue-100",
|
||||||
|
title: "Details anzeigen" do %>
|
||||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to edit_item_path(item), class: "p-1.5 text-gray-500 hover:text-amber-600 hover:bg-amber-50 rounded-lg transition-colors border border-transparent hover:border-amber-100", title: "Artikel bearbeiten" do %>
|
|
||||||
|
<!-- BEARBEITEN ICON mit _top Ausbruch -->
|
||||||
|
<%= link_to edit_item_path(item),
|
||||||
|
data: { turbo_frame: "_top" },
|
||||||
|
class: "p-1.5 text-gray-500 hover:text-amber-600 hover:bg-amber-50 rounded-lg transition-colors border border-transparent hover:border-amber-100",
|
||||||
|
title: "Artikel bearbeiten" do %>
|
||||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /></svg>
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /></svg>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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">
|
<%# Wenn dem Partial keine feste URL übergeben wurde, nutzt es automatisch die aktuelle Browser-URL %>
|
||||||
|
<% form_url = local_assigns[:url] || request.fullpath %>
|
||||||
<!-- Das universelle Suchfeld -->
|
|
||||||
<div class="relative w-full sm:max-w-xs">
|
<%= form_with(url: form_url, method: :get,
|
||||||
<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">
|
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">
|
<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">
|
||||||
<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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -19,7 +56,7 @@
|
|||||||
<span>CSV</span>
|
<span>CSV</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- Universeller Filter-Button -->
|
<!-- 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">
|
<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 -->
|
<!-- Heroicon: funnel -->
|
||||||
@@ -28,4 +65,4 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
<% end %>
|
||||||
|
|||||||
@@ -1,35 +1,6 @@
|
|||||||
<!-- <%# content_for :title, "Items" %>
|
|
||||||
|
|
||||||
<div class="w-full">
|
|
||||||
<% if notice.present? %>
|
|
||||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%= notice %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<h1 class="font-bold text-4xl">Items</h1>
|
|
||||||
<%= link_to "New item", new_item_path, class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white block font-medium" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="items" class="min-w-full divide-y divide-gray-200 space-y-5">
|
|
||||||
<% if @items.any? %>
|
|
||||||
<% @items.each do |item| %>
|
|
||||||
<div class="flex flex-col sm:flex-row justify-between items-center pb-5 sm:pb-0">
|
|
||||||
<%#= render item %>
|
|
||||||
<div class="w-full sm:w-auto flex flex-col sm:flex-row space-x-2 space-y-2">
|
|
||||||
<%= link_to "Show", item, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
|
|
||||||
<%= link_to "Edit", edit_item_path(item), class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
|
|
||||||
<%= button_to "Destroy", item, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<p class="text-center my-10">No items found.</p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>-->
|
|
||||||
|
|
||||||
<% content_for :title, "Gesamtbestand" %>
|
<% content_for :title, "Gesamtbestand" %>
|
||||||
|
|
||||||
|
<!-- OBERE AKTIONSLISTE -->
|
||||||
<% content_for :top_bar_actions do %>
|
<% content_for :top_bar_actions do %>
|
||||||
<%= link_to new_item_path, class: "py-2 px-4 text-sm font-semibold rounded-lg bg-blue-600 text-white hover:bg-blue-700 flex items-center gap-1.5 shadow-sm transition" do %>
|
<%= link_to new_item_path, class: "py-2 px-4 text-sm font-semibold rounded-lg bg-blue-600 text-white hover:bg-blue-700 flex items-center gap-1.5 shadow-sm transition" do %>
|
||||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
|
||||||
@@ -38,23 +9,17 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="w-full space-y-4">
|
<div class="w-full space-y-4">
|
||||||
<!-- 1. Suchleiste laden (mit aktiviertem CSV-Export) -->
|
<!-- 1. Die Suchleiste steht AUSSERHALB des Frames. Sie wird beim Tippen nicht neu geladen! -->
|
||||||
<%= render "items/search_bar", show_csv: true %>
|
<%= render "items/search_bar", show_csv: true %>
|
||||||
|
|
||||||
<!-- 2. Artikelliste laden -->
|
<!-- 2. NUR DIE LISTE WIRD IN DEN TURBO-FRAME GEPAKT -->
|
||||||
<% if @items.any? %>
|
<%= turbo_frame_tag "items_list_frame" do %>
|
||||||
<%= render "items/list", items: @items %>
|
<% if @items.any? %>
|
||||||
<% else %>
|
<%= render "items/list", items: @items %>
|
||||||
<div class="text-center py-16 text-gray-400 bg-white border border-gray-200 rounded-xl shadow-sm">
|
<% else %>
|
||||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
<div class="text-center py-16 text-gray-400 bg-white border border-gray-200 rounded-xl shadow-sm">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l5.25 3.03M12 12.75v9" />
|
<p class="text-sm font-medium">Keine passenden Inventargegenstände gefunden.</p>
|
||||||
</svg>
|
</div>
|
||||||
<p class="text-sm mt-3 font-medium">Bisher sind keine Inventargegenstände erfasst.</p>
|
<% end %>
|
||||||
<p class="text-xs text-gray-400 mt-1">Klicke oben rechts auf "Artikel hinzufügen", um das erste Gerät einzubuchen.</p>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user