-
+
@@ -17,7 +16,7 @@
<% end %>
-
+
@@ -27,33 +26,27 @@
<% end %>
-
-
+
+
<%= item.category.name %>
•
- SKU: <%= item.sku %>
+ SKU: <%= item.sku.presence || "—" %>
+ •
+ SN: <%= item.serial_number.presence || "—" %>
-
-
- <% if item.user.present? %>
-
-
- <%= item.user.name %>
-
- <% elsif item.room.present? %>
-
-
- <%= item.room.name %>
-
- <% else %>
-
-
- Hauptlager
-
- <% end %>
+
+
+
+
+ <%= render "layouts/badge", type: item.location_badge_type, label: item.location_badge_label(short_room: true) %>
+
+
+ <%= render "layouts/badge", type: item.condition_badge_type %>
+
+
@@ -71,103 +64,74 @@
<% end %>
-
-
-
-
-
-
-
- | Artikel / Details |
- SN |
- Standort / Inhaber |
- Sticker-ID |
- Wert |
- Aktionen |
-
-
-
- <% items.each do |item| %>
-
- |
- <%= item.name %>
- SKU: <%= item.sku %> • <%= item.category.name %>
- |
- <%= item.serial_number %> |
-
-
- <% if item.user.present? %>
-
-
-
- <%= item.user.name %>
-
- <% elsif item.room.present? %>
-
-
-
- <%= item.room.name_with_building %>
-
- <% else %>
-
-
-
- Hauptlager
-
+
+
+
+
+
+
+
+
+ | Sticker-ID |
+ Artikeldetails |
+ Aktueller Standort |
+ Zustand |
+ Aktionen |
+
+
+
+ <% items.each do |item| %>
+
+
+
+ |
+ <%= link_to item_path(item), data: { turbo_frame: "_top" }, class: "inline-block transition hover:scale-105" do %>
+
+ #<%= item.sticker_id %>
+
+ <% end %>
+ |
+
+
+
+
+ <%= link_to item_path(item), data: { turbo_frame: "_top" }, class: "font-bold text-gray-900 hover:text-blue-600 hover:underline inline" do %>
+ <%= item.name %>
<% end %>
- |
-
-
-
-
- <%= link_to item_path(item), data: { turbo_frame: "_top" }, class: "inline-block transition hover:scale-105" do %>
-
- #<%= item.sticker_id %>
-
- <% end %>
-
- |
- <%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
- |
-
-
-
-
-
-
- <%= 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 flex items-center justify-center transition",
- title: "Details anzeigen" do %>
-
- <% end %>
-
-
- <%= 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 flex items-center justify-center transition",
- title: "Artikel bearbeiten" do %>
-
- <% end %>
-
+ <%= item.category.name %>
+
+
+ SKU: <%= item.sku.presence || "—" %>
+ •
+ SN: <%= item.serial_number.presence || "—" %>
- |
+
+
-
- <% end %>
-
-
-
+
+ |
+ <%= render "layouts/badge", type: item.location_badge_type, label: item.location_badge_label(short_room: false) %>
+ |
+
+
+
+ <%= render "layouts/badge", type: item.condition_badge_type %>
+ |
+
+
+
+
+ <%= 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 flex items-center justify-center transition" do %>
+
+ <% end %>
+ <%= 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 flex items-center justify-center transition" do %>
+
+ <% end %>
+
+ |
+
+
+ <% end %>
+
+
diff --git a/app/views/layouts/_badge.html.erb b/app/views/layouts/_badge.html.erb
new file mode 100644
index 0000000..b688fa0
--- /dev/null
+++ b/app/views/layouts/_badge.html.erb
@@ -0,0 +1,56 @@
+<%
+ # optons: class = overide css class
+ # label = overide label
+ # icon_type = choose one of the given icons.
+ # icon_svg = costum svg icon
+
+ # 1. Standard-Design festlegen (Fallback)
+ css = local_assigns[:class] || ""
+
+ # 2. Icons als Strings definieren
+ icon_user = '
'
+ icon_room = '
'
+ icon_storage = '
'
+ icon_in_use = '
'
+ icon_new = '
'
+ icon_as_new = '
'
+ icon_used = '
'
+ icon_heavy = '
'
+ icon_defective = '
'
+ icon_unknown = '
'
+
+ # 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"
+ when "user"
+ css, computed_icon, computed_label = "bg-green-50 text-green-800 border-green-200", icon_user, ""
+ when "room"
+ css, computed_icon, computed_label = "bg-blue-50 text-blue-800 border-blue-200", icon_room, ""
+ when "in_use"
+ css, computed_icon, computed_label = "bg-gray-100 text-gray-600 border-gray-200", 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")
+ 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")
+ when "used"
+ css, computed_icon, computed_label = "bg-yellow-50 text-yellow-700 border-yellow-200", 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")
+ 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"
+ when "unknown"
+ css, computed_icon, computed_label = "bg-gray-50 text-gray-400 border-gray-100", icon_unknown, Item.human_attribute_name("conditions.unknown")
+ 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 = lcoal_assigns[:icon_svg].present? ? local_assigns[:icon_svg] : computed_icon.to_s.html_safe
+%>
+
+
+ <%= final_icon if final_icon.present? %>
+ <%= final_label %>
+
diff --git a/config/application.rb b/config/application.rb
index 3ea0a6b..25a2058 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -16,6 +16,12 @@ module Vault171
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets tasks])
+ # Setzt die Standard-Sprache der App dauerhaft auf Deutsch
+ config.i18n.default_locale = :de
+
+ # Erlaubt Rails, auch Unterordner in locales zu durchsuchen
+ config.i18n.available_locales = [ :de, :en ]
+
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
diff --git a/config/locales/de.yml b/config/locales/de.yml
new file mode 100644
index 0000000..4a7a053
--- /dev/null
+++ b/config/locales/de.yml
@@ -0,0 +1,12 @@
+de:
+ activerecord:
+ attributes:
+ item:
+ condition: "Zustand bei Einlagerung"
+ item/conditions:
+ unknown: "Unbekannt"
+ new_item: "Neu"
+ as_new: "Neuwertig"
+ used: "Gebraucht"
+ heavily_used: "Stark Gebraucht"
+ defective: "Defekt"
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6c349ae..c4faa47 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -28,4 +28,14 @@
# enabled: "ON"
en:
- hello: "Hello world"
+ activerecord:
+ attributes:
+ item:
+ condition: "Condition upon storage"
+ conditions:
+ unknown: "Unknown"
+ new_item: "New"
+ as_new: "Like New"
+ used: "Used"
+ heavily_used: "Heavily Used"
+ defective: "Defective"
diff --git a/db/migrate/20260528181506_add_condition_to_items.rb b/db/migrate/20260528181506_add_condition_to_items.rb
new file mode 100644
index 0000000..91fc7af
--- /dev/null
+++ b/db/migrate/20260528181506_add_condition_to_items.rb
@@ -0,0 +1,5 @@
+class AddConditionToItems < ActiveRecord::Migration[8.1]
+def change
+ add_column :items, :condition, :string, default: "unknown", null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0e12cd1..d0a708f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[8.1].define(version: 2026_05_21_125254) do
+ActiveRecord::Schema[8.1].define(version: 2026_05_28_181506) do
create_table "assignment_logs", force: :cascade do |t|
t.datetime "assigned_at"
t.datetime "created_at", null: false
@@ -50,6 +50,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_05_21_125254) do
create_table "items", force: :cascade do |t|
t.integer "category_id"
+ t.string "condition", default: "unknown", null: false
t.datetime "created_at", null: false
t.string "name"
t.text "notes"