Added Items and Dashboard
This commit is contained in:
137
app/views/items/_form.html.erb
Normal file
137
app/views/items/_form.html.erb
Normal file
@@ -0,0 +1,137 @@
|
||||
<!--<%= form_with(model: item, class: "contents") do |form| %>
|
||||
<% if item.errors.any? %>
|
||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-md mt-3">
|
||||
<h2><%= pluralize(item.errors.count, "error") %> prohibited this item from being saved:</h2>
|
||||
|
||||
<ul class="list-disc ml-6">
|
||||
<% item.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
-->
|
||||
|
||||
<%= form_with(model: item, class: "space-y-6 max-w-2xl mx-auto bg-white border border-gray-200 rounded-xl shadow-sm p-6 md:p-8") do |form| %>
|
||||
|
||||
<% if item.errors.any? %>
|
||||
<div class="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 border border-red-200" role="alert">
|
||||
<h2 class="font-bold mb-1"><%= pluralize(item.errors.count, "Fehler") %> verhinderten das Speichern:</h2>
|
||||
<ul class="list-disc list-inside text-xs">
|
||||
<% item.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<!-- Ändert die Überschrift dynamisch je nach Zustand des Artikels -->
|
||||
<h2 class="text-xl font-bold text-gray-800">
|
||||
<%= item.new_record? ? "Artikel registrieren" : "Artikel bearbeiten" %>
|
||||
</h2>
|
||||
|
||||
<p class="text-sm text-gray-500 mt-1">
|
||||
<%= item.new_record? ? "Trage hier die Unikat-Daten wie Seriennummer und Sticker-ID ein." : "Aktualisiere die Daten oder verändere den aktuellen Standort des Geräts." %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- Stammdaten (Name und SKU) -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<%= form.label :name, "Artikelname / Modell", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.text_field :name, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= form.label :sku, "SKU (Artikelnummer)", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.text_field :sku, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Herstelldaten & Preise (Bereinigt um min_stock) -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
<div class="sm:col-span-2">
|
||||
<%= form.label :serial_number, "Seriennummer (Hersteller)", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.text_field :serial_number, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= form.label :price, "Einkaufspreis (€)", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.text_field :price, placeholder: "0.00", class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Kategorie-Auswahl -->
|
||||
<div>
|
||||
<%= form.label :category_id, "Kategorie", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.collection_select :category_id, Category.all, :id, :name, { prompt: "Bitte wählen..." }, { class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-white" } %>
|
||||
</div>
|
||||
|
||||
<!-- QR STICKER-ID -->
|
||||
<div data-controller="scanner">
|
||||
<%= form.label :sticker_id, "Vorgedruckte Sticker-ID / QR-Nummer", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<div class="relative flex rounded-lg shadow-sm">
|
||||
<%= form.text_field :sticker_id, data: { scanner_target: "input" }, class: "py-2 px-3 block w-full border border-gray-300 rounded-l-lg text-sm bg-gray-50/50" %>
|
||||
<button type="button" data-action="click->scanner#startCamera" class="py-2 px-4 border border-l-0 border-gray-300 bg-gray-50 text-gray-700 rounded-r-lg text-sm flex items-center gap-1.5 hover:bg-gray-100 transition">
|
||||
Scannen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- INTERAKTIVE ZUWEISUNGS-WEICHE (Variante 2) -->
|
||||
<div data-controller="assignment" class="space-y-4">
|
||||
<label class="block text-sm font-semibold text-gray-800">Standort / Zuweisung festlegen</label>
|
||||
|
||||
<div class="flex flex-wrap gap-4 p-3 bg-gray-50 rounded-lg border border-gray-200">
|
||||
<label class="flex items-center gap-2 text-sm text-gray-700 font-medium cursor-pointer">
|
||||
<input type="radio" name="assignment_type" value="storage" data-action="change->assignment#toggle" checked class="text-blue-600 focus:ring-blue-500 h-4 w-4 border-gray-300">
|
||||
📦 Im Hauptlager belassen
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-gray-700 font-medium cursor-pointer">
|
||||
<input type="radio" name="assignment_type" value="user" data-action="change->assignment#toggle" class="text-blue-600 focus:ring-blue-500 h-4 w-4 border-gray-300">
|
||||
👤 Mitarbeiter zuweisen
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-gray-700 font-medium cursor-pointer">
|
||||
<input type="radio" name="assignment_type" value="room" data-action="change->assignment#toggle" class="text-blue-600 focus:ring-blue-500 h-4 w-4 border-gray-300">
|
||||
📍 Raum zuweisen
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Dropdown: Mitarbeiter -->
|
||||
<div data-assignment-target="userSection" class="hidden">
|
||||
<%= form.label :user_id, "Mitarbeiter auswählen", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.collection_select :user_id, User.all, :id, :name_with_department, { prompt: "Mitarbeiter wählen..." }, { class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-white" } %>
|
||||
</div>
|
||||
|
||||
<!-- Dropdown: Räume -->
|
||||
<div data-assignment-target="roomSection" class="hidden">
|
||||
<%= form.label :room_id, "Raum / Standort auswählen", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.collection_select :room_id, Room.all, :id, :name_with_building, { prompt: "Raum wählen..." }, { class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-white" } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- Notizen -->
|
||||
<div>
|
||||
<%= form.label :notes, "Zusätzliche Notizen / Details", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
|
||||
<%= form.text_area :notes, rows: 3, class: "py-2 px-3 block w-full border border-gray-300 rounded-lg text-sm bg-gray-50/50" %>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- Buttons -->
|
||||
<div class="flex justify-end gap-x-3">
|
||||
<%= link_to "Abbrechen", items_path, class: "py-2.5 px-4 inline-flex items-center text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition shadow-sm" %>
|
||||
<%= form.submit "Artikel speichern", class: "py-2.5 px-4 inline-flex items-center text-sm font-semibold rounded-lg bg-blue-600 text-white hover:bg-blue-700 shadow-sm transition cursor-pointer" %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user