diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 0341a98..f5e46f4 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -65,7 +65,6 @@
|
<%= link_to item_path(item), class: "shrink-0 transition hover:scale-105 active:scale-95 block" do %>
-
- #<%= item.sticker_id %>
-
+ <%= render "layouts/badge", type: :sticker, label: "##{item.sticker_id}" %>
<% end %>
- <%= link_to item_path(item), class: "font-bold text-gray-900 hover:text-blue-600 hover:underline inline leading-tight" do %>
- <%= item.name %>
+ <% if item.present? %>
+ <%= link_to item_path(item), class: "font-bold text-gray-900 hover:text-blue-600 hover:underline inline leading-tight" do %>
+ <%= item.name %>
+ <%= item.category.name %>
+ <% end %>
+ <% else %>
+ Gelöschter Artikel
<% end %>
- <%= item.category.name %>
+
+ <%= render "layouts/badge", type: item.location_badge_type, label: item.location_badge_label(short_room: true) %>
+
|
- - <% if item.user.present? %> - - - <%= item.user.name %> - - <% elsif item.room.present? %> - <%= link_to room_path item.room do %> - - - <%= item.room.name %> - - <% end %> - <% else %> - - - Hauptlager - - <% end %> - | <%= time_ago_in_words(item.created_at) %> | @@ -149,44 +126,19 @@
<%= link_to item_path(log.item), class: "shrink-0 transition hover:scale-105 active:scale-95 block" do %>
-
- #<%= log.item.sticker_id %>
-
+ <%= render "layouts/badge", type: :sticker, label: "##{log.item.sticker_id}" %>
<% end %>
-
- <% if log.item.present? %>
- <%= link_to item_path(log.item), class: "font-bold text-gray-900 hover:text-blue-600 hover:underline inline leading-tight" do %>
- <%= log.item.name %>
- <% end %>
+
diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb
index cc0675d..a12a710 100644
--- a/app/views/items/show.html.erb
+++ b/app/views/items/show.html.erb
@@ -3,7 +3,7 @@
<% content_for :top_bar_actions do %>
+ <% if log.item.present? %>
+ <%= link_to item_path(log.item), class: "font-bold text-gray-900 hover:text-blue-600 hover:underline inline leading-tight" do %>
+ <%= log.item.name %>
+ <%= log.item.category.name %>
+ <% end %>
<% else %>
Gelöschter Artikel
<% end %>
-
- <% if log.user.present? %>
-
-
- <%= log.user.name %> zugewiesen
-
- <% elsif log.room.present? %>
- <%= link_to room_path log.room do %>
-
-
- In <%= log.room.name %> platziert
-
- <% end %>
- <% else %>
-
-
- Hauptlager zurückgebracht
-
- <% end %>
+ <%= render "layouts/badge", type: log.item.location_badge_type, label: log.item.location_badge_label(short_room: true) %>
- <%= 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 %>
+ <%= link_to "javascript:history.back()", 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 %>
Zurück
diff --git a/app/views/layouts/_badge.html.erb b/app/views/layouts/_badge.html.erb
index 3921d28..dcfd0ac 100644
--- a/app/views/layouts/_badge.html.erb
+++ b/app/views/layouts/_badge.html.erb
@@ -9,7 +9,7 @@
type = local_assigns[:type] || ""
# 2. Icons als Strings definieren
- icon_user = ''
+ icon_user = ''
icon_room = ''
icon_storage = ''
icon_in_use = ''
@@ -24,32 +24,47 @@
# 3. Logik-Weiche für Farben, Standard-Icons und Standard-Labels
case type.to_s
when "storage"
- css, computed_icon, computed_label = "bg-amber-50 text-amber-800 border-amber-200", icon_storage, "Hauptlager"
+ css = "bg-amber-50 text-amber-800 border-amber-200" if css.blank?
+ computed_icon, computed_label = icon_storage, "Hauptlager"
when "user"
- css, computed_icon, computed_label = "bg-green-50 text-green-800 border-green-200", icon_user, ""
+ css = "bg-green-50 text-green-800 border-green-200" if css.blank?
+ computed_icon, computed_label = icon_user, ""
when "room"
- css, computed_icon, computed_label = "bg-blue-50 text-blue-800 border-blue-200", icon_room, ""
+ css = "bg-blue-50 text-blue-800 border-blue-200" if css.blank?
+ computed_icon, computed_label = icon_room, ""
when "in_use"
- css, computed_icon, computed_label = "bg-gray-100 text-gray-600 border-gray-200", icon_in_use, "In Benutzung"
+ css = "bg-gray-100 text-gray-600 border-gray-200" if css.blank?
+ computed_icon, computed_label = icon_in_use, "In Benutzung"
when "new_item"
- css, computed_icon, computed_label = "bg-green-50 text-green-700 border-green-200", icon_new, Item.human_attribute_name("conditions.new_item")
+ css = "bg-green-50 text-green-700 border-green-200" if css.blank?
+ computed_icon, computed_label = icon_new, Item.human_attribute_name("conditions.new_item")
when "as_new"
- css, computed_icon, computed_label = "bg-emerald-50 text-emerald-700 border-emerald-200", icon_as_new, Item.human_attribute_name("conditions.as_new")
+ css = "bg-emerald-50 text-emerald-700 border-emerald-200" if css.blank?
+ computed_icon, computed_label = icon_as_new, Item.human_attribute_name("conditions.as_new")
when "used"
- css, computed_icon, computed_label = "bg-yellow-50 text-yellow-700 border-yellow-200", icon_used, Item.human_attribute_name("conditions.used")
+ css = "bg-yellow-50 text-yellow-700 border-yellow-200" if css.blank?
+ computed_icon, computed_label = icon_used, Item.human_attribute_name("conditions.used")
when "heavily_used"
- css, computed_icon, computed_label = "bg-orange-50 text-orange-700 border-orange-200", icon_heavy, Item.human_attribute_name("conditions.heavily_used")
+ css = "bg-orange-50 text-orange-700 border-orange-200" if css.blank?
+ computed_icon, computed_label = icon_heavy, Item.human_attribute_name("conditions.heavily_used")
when "defective"
- css, computed_icon, computed_label = "bg-red-50 text-red-700 border-red-200", icon_defective, Item.human_attribute_name("conditions.defective")
- css += " animate-pulse font-bold"
+ css = "bg-red-50 text-red-700 border-red-200 animate-pulse font-bold" if css.blank?
+ computed_icon, computed_label = icon_defective, Item.human_attribute_name("conditions.defective")
when "unknown"
- css, computed_icon, computed_label = "bg-gray-50 text-gray-400 border-gray-100", icon_unknown, Item.human_attribute_name("conditions.unknown")
+ css = "bg-gray-50 text-gray-400 border-gray-100" if css.blank?
+ computed_icon, computed_label = 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, ""
+ css = "bg-blue-50 text-blue-800 border-blue-200" if css.blank?
+ computed_icon, computed_label = icon_category, ""
+ when "sticker"
+ # Wenn von außen kein custom CSS kommt, brennen wir den sportlichen Sticker-Look direkt hier ein
+ css = "bg-blue-600 text-white border-blue-600 font-mono font-black tracking-wider uppercase py-0.5 px-1.5" if css.blank?
+ computed_icon, computed_label = "", ""
end
# 4. Optionale Variablen-Überlagerung von außen (Falls manuell übergeben)
final_label = local_assigns[:label].presence || computed_label
+
final_icon = if local_assigns[:icon_svg].present?
local_assigns[:icon_svg]
elsif local_assigns[:icon_type].present?
@@ -59,7 +74,8 @@
end
%>
-
+
+
<%= final_icon if final_icon.present? %>
<%= final_label %>
|