Added Search function for items and fixed javascript controller
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
2026-05-25 04:23:08 +02:00
parent 650b83bdf4
commit 204a6c05dc
9 changed files with 178 additions and 121 deletions

View File

@@ -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" %>
<!-- OBERE AKTIONSLISTE -->
<% 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>
@@ -38,23 +9,17 @@
<% end %>
<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 %>
<!-- 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>
<!-- 2. NUR DIE LISTE WIRD IN DEN TURBO-FRAME GEPAKT -->
<%= turbo_frame_tag "items_list_frame" do %>
<% 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">
<p class="text-sm font-medium">Keine passenden Inventargegenstände gefunden.</p>
</div>
<% end %>
<% end %>
</div>
</div>