Added Category and User Passwort Change
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 02:24:56 +02:00
parent b7f0c35378
commit a706dbe7ff
20 changed files with 472 additions and 69 deletions

View File

@@ -0,0 +1,73 @@
class CategoriesController < ApplicationController
before_action :set_category, only: %i[ show edit update destroy ]
# GET /categories or /categories.json
def index
@categories = Category.all.order(:name)
end
# GET /categories/1 or /categories/1.json
def show
@category = Category.find(params[:id])
@items = @category.items.includes(:user, :room).order(:name)
end
# GET /categories/new
def new
@category = Category.new
end
# GET /categories/1/edit
def edit
end
# POST /categories or /categories.json
def create
@category = Category.new(category_params)
respond_to do |format|
if @category.save
format.html { redirect_to @category, notice: "Category was successfully created." }
format.json { render :show, status: :created, location: @category }
else
format.html { render :new, status: :unprocessable_content }
format.json { render json: @category.errors, status: :unprocessable_content }
end
end
end
# PATCH/PUT /categories/1 or /categories/1.json
def update
respond_to do |format|
if @category.update(category_params)
format.html { redirect_to @category, notice: "Category was successfully updated.", status: :see_other }
format.json { render :show, status: :ok, location: @category }
else
format.html { render :edit, status: :unprocessable_content }
format.json { render json: @category.errors, status: :unprocessable_content }
end
end
end
# DELETE /categories/1 or /categories/1.json
def destroy
@category.destroy!
respond_to do |format|
format.html { redirect_to categories_path, notice: "Category was successfully destroyed.", status: :see_other }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_category
@category = Category.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def category_params
params.require(:category).permit(:name, :description)
end
end

View File

@@ -0,0 +1,2 @@
module CategoriesHelper
end

View File

@@ -1,2 +1,5 @@
class Category < ApplicationRecord
has_many :items, dependent: :restrict_with_error
validates :name, presence: true, uniqueness: true
end

View File

@@ -38,28 +38,7 @@
<div class="max-w-2xl mx-auto space-y-6">
<!-- DYNAMISCHE TAB-NAVIGATION -->
<div class="border-b border-gray-200 mb-6">
<nav class="flex space-x-6" aria-label="Tabs">
<!-- Tab 1: Sicherheit (Inaktiv) -->
<%= link_to edit_password_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
Sicherheit
<% end %>
<!-- Tab 2: Sitzungen & Geräte (Inaktiv) -->
<%= link_to sessions_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" /></svg>
Sitzungen & Geräte
<% end %>
<!-- Tab 3: Aktivitäten (Aktiv) -->
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2" aria-current="page">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" /></svg>
Aktivitäten
</span>
</nav>
</div>
<%= render "identity/account_tabs", active_tab: :activities %>
<!-- Info-Header -->
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 flex flex-col sm:flex-row items-start sm:items-center gap-4 justify-between">

View File

@@ -0,0 +1,2 @@
<div id="<%= dom_id category %>" class="w-full sm:w-auto my-5 space-y-5">
</div>

View File

@@ -0,0 +1,2 @@
json.extract! category, :id, :created_at, :updated_at
json.url category_url(category, format: :json)

View 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 %>

View 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>

View 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 &rarr;
<% end %>
</div>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1 @@
json.array! @categories, partial: "categories/category", as: :category

View File

@@ -0,0 +1,5 @@
<% content_for :title, "Neue Kategorie erstellen" %>
<div class="p-4 md:p-6">
<%= render "form", category: @category %>
</div>

View 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>

View File

@@ -0,0 +1 @@
json.partial! "categories/category", category: @category

View File

@@ -0,0 +1,81 @@
<!-- 1. MOBILE ANSICHT: Ein sauberes Dropdown-Menü (Sichtbar auf Handys, versteckt ab 'sm:') -->
<div class="sm:hidden">
<label for="mobile-account-tabs" class="sr-only">Navigationsbereich wechseln</label>
<select id="mobile-account-tabs"
onchange="window.location.href = this.value"
class="block w-full rounded-lg border-gray-300 bg-white py-2.5 px-3 text-sm font-medium text-gray-700 shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="<%= edit_password_path %>" <%= 'selected' if active_tab == :security %>>
🔒 Sicherheit
</option>
<option value="<%= edit_identity_email_path %>" <%= 'selected' if active_tab == :email %>>
✉️ E-Mail-Adresse
</option>
<option value="<%= sessions_path %>" <%= 'selected' if active_tab == :sessions %>>
💻 Sitzungen & Geräte
</option>
<option value="<%= authentications_events_path %>" <%= 'selected' if active_tab == :activities %>>
📊 Aktivitäten
</option>
</select>
</div>
<!-- 2. DESKTOP ANSICHT: Die klassische Tab-Leiste (Versteckt auf Mobilgeräten, sichtbar ab 'sm:') -->
<div class="hidden sm:block border-b border-gray-200 mb-6 overflow-x-auto">
<nav class="flex space-x-6 min-w-max" aria-label="Tabs">
<!-- Tab 1: Sicherheit (Passwort) -->
<% if active_tab == :security %>
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
Sicherheit
</span>
<% else %>
<%= link_to edit_password_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
Sicherheit
<% end %>
<% end %>
<!-- Tab 2: E-Mail-Adresse -->
<% if active_tab == :email %>
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0l-7.5-4.615a2.25 2.25 0 0 1-1.07-1.916V6.75" /></svg>
E-Mail-Adresse
</span>
<% else %>
<%= link_to edit_identity_email_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0l-7.5-4.615a2.25 2.25 0 0 1-1.07-1.916V6.75" /></svg>
E-Mail-Adresse
<% end %>
<% end %>
<!-- Tab 3: Sitzungen & Geräte -->
<% if active_tab == :sessions %>
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" /></svg>
Sitzungen & Geräte
</span>
<% else %>
<%= link_to sessions_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" /></svg>
Sitzungen & Geräte
<% end %>
<% end %>
<!-- Tab 4: Aktivitäten -->
<% if active_tab == :activities %>
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" /></svg>
Aktivitäten
</span>
<% else %>
<%= link_to authentications_events_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" /></svg>
Aktivitäten
<% end %>
<% end %>
</nav>
</div>

View File

@@ -1,4 +1,4 @@
<p style="color: red"><%= alert %></p>
<!--<p style="color: red"><%= alert %></p>
<% if Current.user.verified? %>
<h1>Change your email</h1>
@@ -41,3 +41,70 @@
<div>
<%= link_to "Back", root_path %>
</div>
-->
<% content_for :title, "E-Mail-Adresse ändern" %>
<div class="max-w-2xl mx-auto space-y-6">
<%= render "identity/account_tabs", active_tab: :email %>
<!-- Info-Header -->
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 flex flex-col sm:flex-row items-start sm:items-center gap-4">
<div class="p-3 bg-blue-50 text-blue-600 rounded-lg shrink-0">
<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="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0l-7.5-4.615a2.25 2.25 0 0 1-1.07-1.916V6.75" />
</svg>
</div>
<div>
<h2 class="text-lg font-bold text-gray-800">E-Mail-Adresse aktualisieren</h2>
<p class="text-sm text-gray-500">Ändere deine primäre Login-Adresse. Aus Sicherheitsgründen musst du diese Aktion mit deinem Passwort bestätigen.</p>
</div>
</div>
<%= form_with(url: identity_email_path, method: :patch, class: "bg-white border border-gray-200 rounded-xl shadow-sm p-6 md:p-8 space-y-6") do |form| %>
<!-- Fehleranzeige bei falschem Passwort oder ungültiger Mail -->
<% if Current.user.errors.any? %>
<div class="p-4 text-sm text-red-800 rounded-lg bg-red-50 border border-red-200" role="alert">
<h3 class="font-bold mb-1">Fehler beim Aktualisieren:</h3>
<ul class="list-disc list-inside text-xs">
<% Current.user.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<!-- Feld 1: Neue E-Mail-Adresse -->
<div>
<%= form.label :email, "Neue E-Mail-Adresse", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
<div class="relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0l-7.5-4.615a2.25 2.25 0 0 1-1.07-1.916V6.75" />
</svg>
</div>
<%= form.email_field :email, value: Current.user.email, required: true, autofocus: true, autocomplete: "email", class: "block w-full pl-10 pr-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-gray-50/50" %>
</div>
</div>
<!-- Feld 2: Passwort zur Bestätigung -->
<div>
<%= form.label :password_challenge, "Aktuelles Passwort zur Bestätigung", class: "block text-sm font-medium mb-1.5 text-gray-700" %>
<div class="relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25z" />
</svg>
</div>
<%= form.password_field :password_challenge, required: true, autocomplete: "current-password", class: "block w-full pl-10 pr-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-gray-50/50" %>
</div>
</div>
<hr class="border-gray-200">
<!-- Abschicken-Button -->
<div class="flex justify-end">
<%= form.submit "E-Mail-Adresse speichern", class: "py-2.5 px-5 text-sm font-semibold rounded-lg bg-blue-600 text-white hover:bg-blue-700 shadow-sm transition cursor-pointer" %>
</div>
<% end %>
</div>

View File

@@ -76,7 +76,7 @@
<span class="collapse-text ml-3 transition-all duration-300 ease-in-out max-w-[180px] opacity-100 overflow-hidden whitespace-nowrap">Wareneingang</span>
<% end %>
<%= link_to "", class: nav_link_class("categories") do %>
<%= link_to categories_path, class: nav_link_class("categories") do %>
<svg class="h-5 w-5 shrink-0 ml-0.5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621 Clyde5.04 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" /></svg>
<span class="collapse-text ml-3 transition-all duration-300 ease-in-out max-w-[180px] opacity-100 overflow-hidden whitespace-nowrap">Kategorien</span>
<% end %>

View File

@@ -47,28 +47,7 @@
<div class="max-w-2xl mx-auto space-y-6">
<!-- INTERNE PROFIL-NAVIGATION (Tabs) -->
<div class="border-b border-gray-200">
<nav class="flex space-x-6" aria-label="Tabs">
<!-- Aktiver Tab: Profil & Sicherheit -->
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<!-- Heroicon: user -->
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
Sicherheit
</span>
<!-- Link zur Sitzungsübersicht von authentication-zero -->
<%= link_to sessions_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<!-- Heroicon: computer-desktop -->
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" /></svg>
Sitzungen & Geräte
<% end %>
<%= link_to authentications_events_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" /></svg>
Aktivitäten
<% end %>
</nav>
</div>
<%= render "identity/account_tabs", active_tab: :security %>
<!-- Sektion 1: Benutzerdaten (Schreibgeschützt) -->
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 md:p-8">

View File

@@ -38,29 +38,7 @@
<div class="max-w-2xl mx-auto space-y-6">
<div class="border-b border-gray-200 mb-6">
<nav class="flex space-x-6" aria-label="Tabs">
<!-- Inaktiv verlinkt -->
<%= link_to edit_password_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
Sicherheit
<% end %>
<!-- Aktiv -->
<span class="border-blue-500 text-blue-600 border-b-2 py-4 px-1 text-sm font-semibold flex items-center gap-2">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" /></svg>
Sitzungen & Geräte
</span>
<!-- Diesen Link fügst du einfach in die Navigationsleisten der anderen beiden Views ein -->
<%= link_to authentications_events_path, class: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 border-b-2 py-4 px-1 text-sm font-medium flex items-center gap-2 transition" do %>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" /></svg>
Aktivitäten
<% end %>
</nav>
</div>
<%= render "identity/account_tabs", active_tab: :sessions %>
<!-- Info-Header -->
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 flex flex-col sm:flex-row items-start sm:items-center gap-4 justify-between">

View File

@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :categories
namespace :authentications do
resources :events, only: :index
end

View File

@@ -0,0 +1,48 @@
require "test_helper"
class CategoriesControllerTest < ActionDispatch::IntegrationTest
setup do
@category = categories(:one)
end
test "should get index" do
get categories_url
assert_response :success
end
test "should get new" do
get new_category_url
assert_response :success
end
test "should create category" do
assert_difference("Category.count") do
post categories_url, params: { category: {} }
end
assert_redirected_to category_url(Category.last)
end
test "should show category" do
get category_url(@category)
assert_response :success
end
test "should get edit" do
get edit_category_url(@category)
assert_response :success
end
test "should update category" do
patch category_url(@category), params: { category: {} }
assert_redirected_to category_url(@category)
end
test "should destroy category" do
assert_difference("Category.count", -1) do
delete category_url(@category)
end
assert_redirected_to categories_url
end
end