Added condition badge in show and removed in_use
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-30 01:45:23 +02:00
parent 5c9e6a34b4
commit fd3149b13f
3 changed files with 29 additions and 15 deletions

View File

@@ -15,18 +15,22 @@
</div>
-->
<% content_for :title, "Artikel-Details: #{@item.name}" %>
<% content_for :title, "Artikel-Details" %>
<!-- OBERE AKTIONSLISTE (Yield im Top-Bar deines Hauptlayouts) -->
<% content_for :top_bar_actions do %>
<div class="flex items-center gap-2">
<%= link_to items_path, class: "py-2 px-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 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="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18" /></svg>
Zurück
<div class="hidden md:inline">
Zurück
</div>
<% end %>
<%= link_to edit_item_path(@item), class: "py-2 px-3 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg 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="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" /></svg>
Bearbeiten
<div class="hidden md:inline">
Bearbeiten
</div>
<% end %>
</div>
<% end %>
@@ -42,9 +46,11 @@
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-4 md:p-6 space-y-4">
<div class="flex items-start justify-between flex-wrap gap-2">
<h2 class="text-lg md:text-xl font-bold text-gray-900 leading-tight"><%= @item.name %></h2>
<span class="inline-flex items-center py-0.5 px-2.5 rounded-full text-xs font-semibold bg-blue-50 text-blue-800 border border-blue-200 shrink-0">
<%= @item.category.name %>
</span>
<div class="flex items-center gap-2 shrink-0">
<%= render "layouts/badge", type: @item.condition_badge_type %>
<%= render "layouts/badge", type: :category, label: @item.category.name %>
</div>
</div>
<hr class="border-gray-200">

View File

@@ -1,11 +1,12 @@
<%
# optons: class = overide css class
# label = overide label
# icon_type = choose one of the given icons.
# icon_svg = costum svg icon
# options: class = override css class
# label = override label
# icon_type = choose one of the given icons.
# icon_svg = custom svg icon
# 1. Standard-Design festlegen (Fallback)
css = local_assigns[:class] || ""
type = local_assigns[:type] || ""
# 2. Icons als Strings definieren
icon_user = '<svg class="h-3.5 w-3.5 text-green-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>'
@@ -13,11 +14,12 @@
icon_storage = '<svg class="h-3.5 w-3.5 text-amber-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" 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>'
icon_in_use = '<svg class="h-3.5 w-3.5 text-gray-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" /></svg>'
icon_new = '<svg class="h-3.5 w-3.5 text-green-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 21l-.813-5.096L3.096 15 8 14.187 8.813 9l.813 5.187L15 15l-5.187.904ZM18 5.25l-.45 1.8-.45-1.8-1.8-.45 1.8-.45.45-1.8.45 1.8 1.8.45-1.8.45ZM21.75 9.75l-.3.9-.3-.9-.9-.3.9-.3.3-.9.3.9.9.3-.9.3Z" /></svg>'
icon_as_new = '<svg class="h-3.5 w-3.5 text-emerald-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6.633 10.25c.896 0 1.7-.393 2.287-1.011l3.34-3.52c.536-.565 1.433-.317 1.62.428l1.042 4.161h4.582a2.25 2.25 0 0 1 2.478l-.997 8.475A2.25 2.25 0 0 1 18.522 23H6.633a2.25 2.25 0 0 1-2.228-1.889L2.83 11.913A2.25 2.25 0 0 1 5.058 9.5h1.575c-.21 0-.422.02-.63.06l-.002.008ZM6.633 10.25V23" /></svg>'
icon_as_new = '<svg class="h-3.5 w-3.5 text-emerald-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6.633 10.25c.896 0 1.7-.393 2.287-1.011l3.34-3.52c.536-.565 1.433-.317 1.62.428l1.042 4.161h4.582a2.25 2.25 0 0 1 2.247 2.478l-.997 8.475A2.25 2.25 0 0 1 18.522 23H6.633a2.25 2.25 0 0 1-2.228-1.889L2.83 11.913A2.25 2.25 0 0 1 5.058 9.5h1.575c-.21 0-.422.02-.63.06l-.002.008ZM6.633 10.25V23" /></svg>'
icon_used = '<svg class="h-3.5 w-3.5 text-yellow-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>'
icon_heavy = '<svg class="h-3.5 w-3.5 text-orange-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.65 2.65 0 1 0 21 17.25l-5.83-5.83m0 0a2.65 2.65 0 1 1-3.75-3.75 2.65 2.65 0 0 1 3.75 3.75Zm-5.83 5.83a2.65 2.65 0 1 1-3.75-3.75 2.65 2.65 0 0 1 3.75 3.75M21 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 7a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM16.5 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z" /></svg>'
icon_defective = '<svg class="h-3.5 w-3.5 text-red-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>'
icon_unknown = '<svg class="h-3.5 w-3.5 text-gray-300 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z" /></svg>'
icon_category = '<svg class="h-3.5 w-3.5 text-blue-600 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-19.5 0A2.25 2.25 0 0 0 2.25 15v2.25m0-4.5A2.25 2.25 0 0 1 4.5 12h15a2.25 2.25 0 0 1 2.25 2.25m-19.5 0v4.5A2.25 2.25 0 0 0 4.5 21h15a2.25 2.25 0 0 0 2.25-2.25V15M2.25 12V6a2.25 2.25 0 0 1 2.25-2.25h2.25c.59 0 1.157.234 1.576.652L9.75 5.85a2.25 2.25 0 0 0 1.576.652h6.924a2.25 2.25 0 0 1 2.25 2.25v3.25" /></svg>'
# 3. Logik-Weiche für Farben, Standard-Icons und Standard-Labels
case type.to_s
@@ -42,12 +44,19 @@
css += " animate-pulse font-bold"
when "unknown"
css, computed_icon, computed_label = "bg-gray-50 text-gray-400 border-gray-100", icon_unknown, Item.human_attribute_name("conditions.unknown")
when "category"
css, computed_icon, computed_label = "bg-blue-50 text-blue-800 border-blue-200", icon_category, ""
end
# 4. Optionale Variablen-Überlagerung von außen (Falls manuell übergeben)
final_label = local_assigns[:label].presence || computed_label
final_icon = local_assigns[:icon_type].present? ? local_assigns[:icon_type] : computed_icon.to_s.html_safe
final_icon = local_assigns[:icon_svg].present? ? local_assigns[:icon_svg] : computed_icon.to_s.html_safe
final_icon = if local_assigns[:icon_svg].present?
local_assigns[:icon_svg]
elsif local_assigns[:icon_type].present?
local_assigns[:icon_type]
else
computed_icon.to_s.html_safe
end
%>
<span class="inline-flex items-center gap-1.5 py-1 px-2.5 rounded-md text-xs font-semibold shadow-sm border <%= css %> ">