Added Category and User Passwort Change
This commit is contained in:
2
app/views/categories/_category.html.erb
Normal file
2
app/views/categories/_category.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="<%= dom_id category %>" class="w-full sm:w-auto my-5 space-y-5">
|
||||
</div>
|
||||
2
app/views/categories/_category.json.jbuilder
Normal file
2
app/views/categories/_category.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! category, :id, :created_at, :updated_at
|
||||
json.url category_url(category, format: :json)
|
||||
41
app/views/categories/_form.html.erb
Normal file
41
app/views/categories/_form.html.erb
Normal file
@@ -0,0 +1,41 @@
|
||||
<%= form_with(model: category, 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 category.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(category.errors.count, "Fehler") %> verhinderten das Speichern:</h2>
|
||||
<ul class="list-disc list-inside text-xs">
|
||||
<% category.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-gray-800">Kategorie-Details</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">Definiere eine übergeordnete Gruppe für dein Inventar (z.B. Laptops oder Bürostühle).</p>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- Name -->
|
||||
<div>
|
||||
<%= form.label :name, "Name der Kategorie", class: "block text-sm font-medium mb-2 text-gray-700" %>
|
||||
<%= form.text_field :name, required: true, class: "py-2.5 px-4 block w-full border border-gray-300 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50/50", placeholder: "z.B. IT-Infrastruktur" %>
|
||||
</div>
|
||||
|
||||
<!-- Beschreibung -->
|
||||
<div>
|
||||
<%= form.label :description, "Beschreibung / Notizen", class: "block text-sm font-medium mb-2 text-gray-700" %>
|
||||
<%= form.text_area :description, rows: 4, class: "py-2.5 px-4 block w-full border border-gray-300 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50/50", placeholder: "Welche Art von Gegenständen fällt in diese Kategorie?..." %>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<!-- Buttons -->
|
||||
<div class="flex justify-end gap-x-3">
|
||||
<%= link_to "Abbrechen", categories_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 "Kategorie 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 %>
|
||||
14
app/views/categories/edit.html.erb
Normal file
14
app/views/categories/edit.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<% content_for :title, "Kategorie bearbeiten" %>
|
||||
|
||||
<div class="p-4 md:p-6 space-y-6">
|
||||
<%= render "form", category: @category %>
|
||||
|
||||
<!-- Gefahrenbereich: Kategorie löschen (Nur wenn keine Items drin sind) -->
|
||||
<div class="max-w-2xl mx-auto bg-red-50/50 border border-red-200 rounded-xl p-6 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
||||
<div>
|
||||
<h3 class="text-sm font-bold text-red-800">Kategorie löschen</h3>
|
||||
<p class="text-xs text-red-600 mt-0.5">Dies kann nicht rückgängig gemacht werden. Nur möglich, wenn die Kategorie komplett leer ist.</p>
|
||||
</div>
|
||||
<%= link_to "Löschen", @category, data: { turbo_method: :delete, turbo_confirm: "Möchtest du diese Kategorie wirklich unwiderruflich löschen?" }, class: "py-2 px-3 text-xs font-semibold text-white bg-red-600 hover:bg-red-700 rounded-lg shadow-sm transition" %>
|
||||
</div>
|
||||
</div>
|
||||
44
app/views/categories/index.html.erb
Normal file
44
app/views/categories/index.html.erb
Normal file
@@ -0,0 +1,44 @@
|
||||
<!-- Ersetze den alten Button im Top-Bar-Yield durch diesen echten Link -->
|
||||
|
||||
<% content_for :title, "Inventar-Kategorien" %>
|
||||
|
||||
<div class="space-y-6">
|
||||
<!-- Header-Aktionen (Nutzt das Yield aus deinem Layout) -->
|
||||
<% content_for :top_bar_actions do %>
|
||||
<%= link_to new_category_path, class: "py-2 px-4 text-sm font-semibold rounded-lg bg-blue-600 text-white hover:bg-blue-700 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="M12 4.5v15m7.5-7.5h-15" /></svg>
|
||||
Kategorie erstellen
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<!-- Das Kachel-Grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<% @categories.each do |category| %>
|
||||
<div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm hover:shadow-md transition flex flex-col justify-between">
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="p-2.5 bg-blue-50 text-blue-600 rounded-lg">
|
||||
<!-- Heroicon: folder -->
|
||||
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" 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>
|
||||
</div>
|
||||
<!-- Dynamische Anzahl der Objekte im System -->
|
||||
<span class="inline-flex items-center py-1 px-2.5 rounded-full text-xs font-semibold bg-gray-100 text-gray-800 border border-gray-200">
|
||||
<%= category.items.count %> <%= category.items.count == 1 ? "Objekt" : "Objekte" %>
|
||||
</span>
|
||||
</div>
|
||||
<h3 class="text-base font-bold text-gray-800"><%= category.name %></h3>
|
||||
<p class="text-xs text-gray-500 mt-2 leading-relaxed"><%= category.description.presence || "Keine Beschreibung hinterlegt." %></p>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 pt-4 border-t border-gray-100 flex justify-end gap-3 text-xs font-semibold">
|
||||
|
||||
<%= link_to "Bearbeiten", edit_category_path(category), class: "text-gray-500 hover:text-gray-700 transition" %>
|
||||
|
||||
<%= link_to category_path(category), class: "text-blue-600 hover:text-blue-800 flex items-center gap-0.5 transition" do %>
|
||||
Artikel ansehen →
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/categories/index.json.jbuilder
Normal file
1
app/views/categories/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @categories, partial: "categories/category", as: :category
|
||||
5
app/views/categories/new.html.erb
Normal file
5
app/views/categories/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<% content_for :title, "Neue Kategorie erstellen" %>
|
||||
|
||||
<div class="p-4 md:p-6">
|
||||
<%= render "form", category: @category %>
|
||||
</div>
|
||||
82
app/views/categories/show.html.erb
Normal file
82
app/views/categories/show.html.erb
Normal file
@@ -0,0 +1,82 @@
|
||||
<% content_for :title, "Kategorie: #{@category.name}" %>
|
||||
|
||||
<div class="space-y-6">
|
||||
<!-- Zurück-Link im Header -->
|
||||
<% content_for :top_bar_actions do %>
|
||||
<%= link_to categories_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 %>
|
||||
<!-- Heroicon: arrow-left -->
|
||||
<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>
|
||||
Alle Kategorien
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<!-- Beschreibungskarte -->
|
||||
<div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
|
||||
<h2 class="text-sm font-bold text-gray-400 uppercase tracking-wider">Beschreibung</h2>
|
||||
<p class="text-sm text-gray-600 mt-1 leading-relaxed"><%= @category.description.presence || "Keine Beschreibung hinterlegt für diese Kategorie." %></p>
|
||||
</div>
|
||||
|
||||
<!-- Tabelle der zugeordneten Artikel -->
|
||||
<div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
|
||||
<h3 class="font-bold text-gray-700 text-sm">Registrierte Unikate in dieser Kategorie</h3>
|
||||
</div>
|
||||
|
||||
<% if @items.any? %>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
||||
<thead class="bg-gray-50/50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Artikel / Modell</th>
|
||||
<th class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Seriennummer (SN)</th>
|
||||
<th class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">Aktueller Standort / Inhaber</th>
|
||||
<th class="px-6 py-3 text-start font-semibold text-gray-500 uppercase tracking-wider">QR-ID</th>
|
||||
<th class="px-6 py-3 text-end font-semibold text-gray-500 uppercase tracking-wider">Wert</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% @items.each do |item| %>
|
||||
<tr class="hover:bg-gray-50/50 transition">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="font-semibold text-gray-900"><%= item.name %></div>
|
||||
<div class="text-xs text-gray-400">SKU: <%= item.sku %></div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs text-gray-600">
|
||||
<%= item.serial_number %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
||||
<!-- Deine saubere Variante-2-Weiche für Inhaber vs. Raum -->
|
||||
<% if item.user.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-900 font-medium">
|
||||
👤 <%= item.user.name %>
|
||||
</span>
|
||||
<% elsif item.room.present? %>
|
||||
<span class="inline-flex items-center gap-1 text-gray-600">
|
||||
📍 <%= item.room.name_with_building %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center py-0.5 px-2 rounded-full text-xs font-medium bg-amber-50 text-amber-800 border border-amber-200">
|
||||
📦 Im Hauptlager
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap font-mono text-xs font-bold text-blue-600">
|
||||
#<%= item.sticker_id %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-end font-medium text-gray-900">
|
||||
<%= number_to_currency(item.price, unit: "€", separator: ",", delimiter: ".", format: "%n %u") %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
<!-- Empty State -->
|
||||
<div class="text-center py-12 text-gray-400">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" /></svg>
|
||||
<p class="text-sm mt-2">Bisher sind keine Artikel in dieser Kategorie registriert.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/categories/show.json.jbuilder
Normal file
1
app/views/categories/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "categories/category", category: @category
|
||||
Reference in New Issue
Block a user