Added item list with mobile view
This commit is contained in:
132
app/views/items/_list.html.erb
Normal file
132
app/views/items/_list.html.erb
Normal file
@@ -0,0 +1,132 @@
|
||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 1. HANDY-ANSICHT: OPTIMIERTE INVENTAR-CARDS (md:hidden) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="block md:hidden divide-y divide-gray-200 bg-white">
|
||||
<% items.each do |item| %>
|
||||
<div class="p-4 space-y-3 hover:bg-gray-50/50 transition">
|
||||
|
||||
<!-- Zeile 1: Name, Kategorie & die markante Sticker-ID Plakette -->
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="min-w-0">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<!-- Rechte Box für ID und den optimal platzierten Preis direkt darunter -->
|
||||
<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">
|
||||
#<%= item.sticker_id %>
|
||||
</span>
|
||||
<span class="text-xs font-bold text-gray-600 font-mono bg-gray-100 px-1.5 py-0.5 rounded">
|
||||
<%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Zeile 2: Technische Gerätedaten (SKU & Seriennummer) -->
|
||||
<div class="grid grid-cols-2 gap-3 bg-gray-50 p-2.5 rounded-lg text-xs font-mono text-gray-600">
|
||||
<div class="truncate">
|
||||
<span class="text-gray-400 font-sans block text-[10px] uppercase font-bold tracking-wider mb-0.5">SKU</span>
|
||||
<%= item.sku %>
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<span class="text-gray-400 font-sans block text-[10px] uppercase font-bold tracking-wider mb-0.5">Seriennummer</span>
|
||||
<%= item.serial_number %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Zeile 3: Standort & Quick-Actions -->
|
||||
<div class="flex justify-between items-center pt-1">
|
||||
<!-- Standort-Badge -->
|
||||
<div class="text-xs">
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-900 font-semibold bg-green-50 text-green-800 px-2 py-1 rounded-md border border-green-200">
|
||||
👤 <%= item.user.name %>
|
||||
</span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-700 bg-blue-50 text-blue-800 px-2 py-1 rounded-md border border-blue-200">
|
||||
📍 <%= item.room.name %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center gap-1 text-amber-800 bg-amber-50 px-2 py-1 rounded-md border border-amber-200 font-medium">
|
||||
📦 Hauptlager
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Aktions-Icons -->
|
||||
<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 %>
|
||||
<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 %>
|
||||
<%= 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 %>
|
||||
<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 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 2. DESKTOP-ANSICHT: STICKY-TABELLE (hidden md:block) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="hidden md:block overflow-x-auto max-h-[calc(100vh-12rem)]">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
||||
<thead class="bg-gray-50 sticky top-0 z-20 shadow-[0_1px_0_0_rgba(229,231,235,1)]">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Artikel / Details</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Seriennummer (SN)</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Aktueller Standort / Inhaber</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Sticker-ID</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Wert</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% items.each do |item| %>
|
||||
<tr class="hover:bg-gray-50/50 transition">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="font-semibold text-gray-900"><%= item.name %></div>
|
||||
<div class="text-xs text-gray-400">SKU: <%= item.sku %> • <%= item.category.name %></div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs text-gray-600"><%= item.serial_number %></td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-900 font-medium">👤 <%= item.user.name %></span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-600">📍 <%= item.room.name_with_building %></span>
|
||||
<% else %>
|
||||
<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 %>
|
||||
</td>
|
||||
|
||||
<!-- STICKER-ID ALS BADGE (Jetzt auch in der Desktop-Tabelle markant) -->
|
||||
<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">
|
||||
#<%= item.sticker_id %>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<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") %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-xs">
|
||||
<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 %>
|
||||
<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 %>
|
||||
<%= 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 %>
|
||||
<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 %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
168
app/views/items/_list2.html.erb
Normal file
168
app/views/items/_list2.html.erb
Normal file
@@ -0,0 +1,168 @@
|
||||
<% content_for :title, "Gesamtbestand" %>
|
||||
|
||||
<!-- OBERE AKTIONSLISTE (Bleibt unverändert) -->
|
||||
<% 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 %>
|
||||
<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>
|
||||
Artikel hinzufügen
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
<!-- FILTER- & SUCHZEILE (Bleibt unverändert) -->
|
||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
||||
<div class="p-4 border-b border-gray-200 bg-gray-50 flex flex-col sm:flex-row gap-3 justify-between items-center">
|
||||
<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">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||
<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>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 w-full sm:w-auto justify-end">
|
||||
<%= link_to items_path(format: :csv), 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 transition shadow-sm", title: "Liste als Excel/CSV exportieren" do %>
|
||||
<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="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" /></svg>
|
||||
<span>Daten exportieren</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @items.any? %>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 1. HANDY-ANSICHT: OPTIMIERTE INVENTAR-CARDS (md:hidden) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="block md:hidden divide-y divide-gray-200 bg-white">
|
||||
<% @items.each do |item| %>
|
||||
<div class="p-4 space-y-3 hover:bg-gray-50/50 transition">
|
||||
|
||||
<!-- Zeile 1: Name, Kategorie & die markante Sticker-ID Plakette -->
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="min-w-0">
|
||||
<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>
|
||||
</div>
|
||||
<!-- MARKANTE PLAKETTE: Ersetzt die alte Text-Bezeichnung und hebt die ID stark hervor -->
|
||||
<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 shrink-0 tracking-wider">
|
||||
#<%= item.sticker_id %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Zeile 2: Technische Gerätedaten (SKU & Seriennummer) -->
|
||||
<div class="grid grid-cols-2 gap-3 bg-gray-50 p-2.5 rounded-lg text-xs font-mono text-gray-600">
|
||||
<div class="truncate">
|
||||
<span class="text-gray-400 font-sans block text-[10px] uppercase font-bold tracking-wider mb-0.5">SKU</span>
|
||||
<%= item.sku %>
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<span class="text-gray-400 font-sans block text-[10px] uppercase font-bold tracking-wider mb-0.5">Seriennummer</span>
|
||||
<%= item.serial_number %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Zeile 3: Standort, Wert & Quick-Actions -->
|
||||
<div class="flex justify-between items-center pt-1">
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<!-- Standort-Badge -->
|
||||
<div class="text-xs">
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-900 font-semibold bg-green-50 text-green-800 px-2 py-1 rounded-md border border-green-200">
|
||||
👤 <%= item.user.name %>
|
||||
</span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-700 bg-blue-50 text-blue-800 px-2 py-1 rounded-md border border-blue-200">
|
||||
📍 <%= item.room.name %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center gap-1 text-amber-800 bg-amber-50 px-2 py-1 rounded-md border border-amber-200 font-medium">
|
||||
📦 Hauptlager
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Kompakter Preis-Tag -->
|
||||
<span class="text-xs font-bold text-gray-500 font-mono">
|
||||
<%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Aktions-Icons -->
|
||||
<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 %>
|
||||
<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 %>
|
||||
<%= 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 %>
|
||||
<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 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 2. DESKTOP-ANSICHT: KLASSISCHE STICKY-TABELLE (Versteckt auf Mobilgeräten, aktiv ab 'md:') -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="hidden md:block overflow-x-auto max-h-[calc(100vh-12rem)]">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
||||
<thead class="bg-gray-50 sticky top-0 z-20 shadow-[0_1px_0_0_rgba(229,231,235,1)]">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Artikel / Details</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Seriennummer (SN)</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Aktueller Standort / Inhaber</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Sticker-ID</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Wert</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% @items.each do |item| %>
|
||||
<tr class="hover:bg-gray-50/50 transition">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="font-semibold text-gray-900"><%= item.name %></div>
|
||||
<div class="text-xs text-gray-400">SKU: <%= item.sku %> • <%= item.category.name %></div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs text-gray-600"><%= item.serial_number %></td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-900 font-medium">👤 <%= item.user.name %></span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-600">📍 <%= item.room.name_with_building %></span>
|
||||
<% else %>
|
||||
<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 %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs font-bold text-blue-600">#<%= item.sticker_id %></td>
|
||||
<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") %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-xs">
|
||||
<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 %>
|
||||
<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 %>
|
||||
<%= 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 %>
|
||||
<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 %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<!-- EMPTY STATE (Falls die Datenbank komplett leer ist) -->
|
||||
<div class="text-center py-16 text-gray-400">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<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" />
|
||||
</svg>
|
||||
<p class="text-sm mt-3 font-medium">Bisher sind keine Inventargegenstände erfasst.</p>
|
||||
<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 %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
31
app/views/items/_search_bar.html.erb
Normal file
31
app/views/items/_search_bar.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Aktions-Bereich rechts -->
|
||||
<div class="flex items-center gap-2 w-full sm:w-auto justify-end">
|
||||
<!-- CSV-Export wird nur angezeigt, wenn explizit gewünscht -->
|
||||
<% if local_assigns[:show_csv] %>
|
||||
<%= link_to items_path(format: :csv), 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 transition shadow-sm", title: "Liste als Excel/CSV exportieren" do %>
|
||||
<!-- Heroicon: arrow-down-tray -->
|
||||
<svg class="h-4 w-4 text-gray-500" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" /></svg>
|
||||
<span>Daten exportieren</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 -->
|
||||
<svg class="h-4 w-4 text-gray-500" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 0 1-.659 1.591l-5.432 5.432a2.25 2.25 0 0 0-.659 1.591v2.927a2.25 2.25 0 0 1-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 0 0-.659-1.591L3.659 7.409A2.25 2.25 0 0 1 3 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0 1 12 3Z" /></svg>
|
||||
<span>Filter</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -30,125 +30,31 @@
|
||||
|
||||
<% content_for :title, "Gesamtbestand" %>
|
||||
|
||||
<!-- OBERE AKTIONSLISTE (Der funktionierende Button für neue Artikel) -->
|
||||
<% 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 %>
|
||||
<!-- Heroicon: plus -->
|
||||
<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>
|
||||
Artikel hinzufügen
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
<!-- FILTER- & SUCHZEILE -->
|
||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
||||
<div class="p-4 border-b border-gray-200 bg-gray-50 flex flex-col sm:flex-row gap-3 justify-between items-center">
|
||||
|
||||
<!-- 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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CSV Export & Filter Toggles -->
|
||||
<div class="flex items-center gap-2 w-full sm:w-auto justify-end">
|
||||
<%= link_to items_path(format: :csv), 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 transition shadow-sm", title: "Liste als Excel/CSV exportieren" do %>
|
||||
<!-- Heroicon: arrow-down-tray -->
|
||||
<svg class="h-4 w-4 text-gray-500" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" /></svg>
|
||||
<span>Daten exportieren</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="w-full space-y-4">
|
||||
<!-- 1. Suchleiste laden (mit aktiviertem CSV-Export) -->
|
||||
<%= render "items/search_bar", show_csv: true %>
|
||||
|
||||
<!-- 2. Artikelliste laden -->
|
||||
<% if @items.any? %>
|
||||
<%= render "items/list", items: @items %>
|
||||
<% else %>
|
||||
<div class="text-center py-16 text-gray-400 bg-white border border-gray-200 rounded-xl shadow-sm">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<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" />
|
||||
</svg>
|
||||
<p class="text-sm mt-3 font-medium">Bisher sind keine Inventargegenstände erfasst.</p>
|
||||
<p class="text-xs text-gray-400 mt-1">Klicke oben rechts auf "Artikel hinzufügen", um das erste Gerät einzubuchen.</p>
|
||||
</div>
|
||||
|
||||
<!-- DIE BESTANDSTABELLE -->
|
||||
<!-- DIE BESTANDSTABELLE (Mit Sticky Header) -->
|
||||
<% if @items.any? %>
|
||||
<!-- 1. Der umschließende Container bekommt eine maximale Höhe und wird scrollbar -->
|
||||
<div class="overflow-x-auto max-h-[calc(100vh-12rem)] border border-gray-200 rounded-xl shadow-sm">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-sm table-fixed sm:table-auto">
|
||||
|
||||
<!-- 2. Der THEAD wird sticky gesetzt und erhält einen festen Hintergrund -->
|
||||
<thead class="bg-gray-50 sticky top-0 z-20 shadow-[0_1px_0_0_rgba(229,231,235,1)]">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Artikel / Details</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Seriennummer (SN)</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Aktueller Standort / Inhaber</th>
|
||||
<th scope="col" class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Sticker-ID</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Wert</th>
|
||||
<th scope="col" class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% @items.each do |item| %>
|
||||
<tr class="hover:bg-gray-50/50 transition">
|
||||
|
||||
<!-- Spalte 1: Name, SKU, Kategorie -->
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="font-semibold text-gray-900"><%= item.name %></div>
|
||||
<div class="text-xs text-gray-400">SKU: <%= item.sku %> • <%= item.category.name %></div>
|
||||
</td>
|
||||
|
||||
<!-- Spalte 2: Herstellerschlüssel -->
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs text-gray-600">
|
||||
<%= item.serial_number %>
|
||||
</td>
|
||||
|
||||
<!-- Spalte 3: Inhaber-Weiche nach Variante 2 -->
|
||||
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-900 font-medium">
|
||||
👤 <%= item.user.name %>
|
||||
</span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1.5 text-gray-600">
|
||||
📍 <%= item.room.name_with_building %>
|
||||
</span>
|
||||
<% else %>
|
||||
<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 %>
|
||||
</td>
|
||||
|
||||
<!-- Spalte 4: Interne QR-ID -->
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs font-bold text-blue-600">
|
||||
#<%= item.sticker_id %>
|
||||
</td>
|
||||
|
||||
<!-- Spalte 5: Anschaffungspreis -->
|
||||
<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") %>
|
||||
</td>
|
||||
|
||||
<!-- Spalte 6: Verknüpfte REST-Links -->
|
||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium space-x-3 text-xs">
|
||||
<%= link_to "Details", item_path(item), class: "text-blue-600 hover:text-blue-900 transition" %>
|
||||
<%= link_to "Bearbeiten", edit_item_path(item), class: "text-gray-500 hover:text-gray-700 transition" %>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
<!-- EMPTY STATE (Falls die Datenbank komplett leer ist) -->
|
||||
<div class="text-center py-16 text-gray-400">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<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" />
|
||||
</svg>
|
||||
<p class="text-sm mt-3 font-medium">Bisher sind keine Inventargegenstände erfasst.</p>
|
||||
<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 %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user