Added Items and Dashboard
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-22 03:52:54 +02:00
parent a706dbe7ff
commit 44d019b4b5
24 changed files with 966 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
require "rqrcode"
class Item < ApplicationRecord
belongs_to :category
belongs_to :user, optional: true # Optional, falls im Raum oder Lager
@@ -13,6 +15,22 @@ class Item < ApplicationRecord
# Überwacht Besitzer- oder Raumwechsel für die Historie
before_save :track_assignment_changes, if: -> { will_save_change_to_user_id? || will_save_change_to_room_id? }
def generate_qr_code
return if sticker_id.blank?
# Erzeugt das QR-Code-Objekt basierend auf deiner vorgedruckten Sticker-ID
qrcode = RQRCode::QRCode.new(sticker_id.to_s)
# Rendert den QR-Code als SVG-Vektorgrafik (perfekt scharf für Bildschirme)
qrcode.as_svg(
color: "000", # Farbe: Schwarz
shape_rendering: "crispEdges", # Erzwingt scharfe Kanten im Browser
module_size: 4, # Kompakte Größe
standalone: true,
use_path: true
).html_safe # Sagt Rails, dass das HTML unbedenklich ausgegeben werden darf
end
private
def either_user_or_room