From 2a7f98d61cb295eb1bcbbb7e8fe584c663a9953e Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Sat, 25 Jul 2026 23:33:18 +0200 Subject: [PATCH] iOS: Artikel ohne Barcode anlegen offensichtlich machen Anlegen ohne EAN war nur versteckt im Scan-Screen erreichbar. Jetzt zwei klare Wege: ein "+" in der Produkte-Liste und eine Kachel "Artikel anlegen" im Scannen-Tab (jeweils fuer Admins). Beide oeffnen das Anlege-Formular ohne Barcode; ein Abbrechen-Knopf schliesst es. Co-Authored-By: Claude Opus 4.8 --- ios/Sources/ListViews.swift | 26 ++++++++++++++++++++++++++ ios/Sources/RootView.swift | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/ios/Sources/ListViews.swift b/ios/Sources/ListViews.swift index 1d13146..b2fbd64 100644 --- a/ios/Sources/ListViews.swift +++ b/ios/Sources/ListViews.swift @@ -171,12 +171,14 @@ struct ExpiringView: View { // MARK: - Produktliste struct ProductListView: View { + @EnvironmentObject private var session: Session @State private var query = "" @State private var products: [Product] = [] @State private var categories: [CategoryItem] = [] /// nil = alle, 0 = ohne Kategorie, sonst die ID (Unterkategorien zaehlen mit). @State private var categoryId: Int? @State private var busy = false + @State private var showNew = false private var filterLabel: String { if categoryId == 0 { return "Ohne Kategorie" } @@ -223,6 +225,30 @@ struct ProductListView: View { .navigationTitle("Produkte") .navigationBarTitleDisplayMode(.inline) .refreshable { await load() } + .toolbar { + if session.isAdmin { + ToolbarItem(placement: .topBarTrailing) { + Button { showNew = true } label: { + Label("Artikel anlegen", systemImage: "plus") + } + } + } + } + .sheet(isPresented: $showNew) { + NavigationStack { + // Ohne Barcode: nur Name + Kategorie nötig. Nach dem Anlegen + // schließt sich das Formular und die Liste wird aufgefrischt. + ProductFormView(prefillBarcode: nil, groupId: nil) { _ in + showNew = false + Task { await load() } + } + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button("Abbrechen") { showNew = false } + } + } + } + } .task { categories = (try? await APIClient.shared.categories()) ?? [] await load() diff --git a/ios/Sources/RootView.swift b/ios/Sources/RootView.swift index 12ee60d..1cf0a65 100644 --- a/ios/Sources/RootView.swift +++ b/ios/Sources/RootView.swift @@ -73,6 +73,8 @@ struct HomeView: View { /// Die beiden Kacheln, die frueher die Startseite waren. struct ScanTabView: View { @EnvironmentObject private var router: Router + @EnvironmentObject private var session: Session + @State private var showNew = false var body: some View { NavigationStack { @@ -91,10 +93,28 @@ struct ScanTabView: View { ActionTile(title: "Auslagern", subtitle: "Barcode scannen und Menge entnehmen", systemImage: "arrow.up.to.line") } + // Ohne Barcode: gerade bei Gegenstaenden (Kleidung, Werkzeug) gibt + // es keinen Code zum Scannen. Deshalb hier ein offensichtlicher Weg. + if session.isAdmin { + Button { + showNew = true + } label: { + ActionTile(title: "Artikel anlegen", + subtitle: "Ohne Barcode – Name, Kategorie, eigene Felder", + systemImage: "plus") + } + } Spacer() } .padding() .navigationTitle("Scannen") + .sheet(isPresented: $showNew) { + NavigationStack { + ProductFormView(prefillBarcode: nil, groupId: nil) { _ in + showNew = false + } + } + } } } }