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 <noreply@anthropic.com>
This commit is contained in:
@@ -171,12 +171,14 @@ struct ExpiringView: View {
|
|||||||
// MARK: - Produktliste
|
// MARK: - Produktliste
|
||||||
|
|
||||||
struct ProductListView: View {
|
struct ProductListView: View {
|
||||||
|
@EnvironmentObject private var session: Session
|
||||||
@State private var query = ""
|
@State private var query = ""
|
||||||
@State private var products: [Product] = []
|
@State private var products: [Product] = []
|
||||||
@State private var categories: [CategoryItem] = []
|
@State private var categories: [CategoryItem] = []
|
||||||
/// nil = alle, 0 = ohne Kategorie, sonst die ID (Unterkategorien zaehlen mit).
|
/// nil = alle, 0 = ohne Kategorie, sonst die ID (Unterkategorien zaehlen mit).
|
||||||
@State private var categoryId: Int?
|
@State private var categoryId: Int?
|
||||||
@State private var busy = false
|
@State private var busy = false
|
||||||
|
@State private var showNew = false
|
||||||
|
|
||||||
private var filterLabel: String {
|
private var filterLabel: String {
|
||||||
if categoryId == 0 { return "Ohne Kategorie" }
|
if categoryId == 0 { return "Ohne Kategorie" }
|
||||||
@@ -223,6 +225,30 @@ struct ProductListView: View {
|
|||||||
.navigationTitle("Produkte")
|
.navigationTitle("Produkte")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.refreshable { await load() }
|
.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 {
|
.task {
|
||||||
categories = (try? await APIClient.shared.categories()) ?? []
|
categories = (try? await APIClient.shared.categories()) ?? []
|
||||||
await load()
|
await load()
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ struct HomeView: View {
|
|||||||
/// Die beiden Kacheln, die frueher die Startseite waren.
|
/// Die beiden Kacheln, die frueher die Startseite waren.
|
||||||
struct ScanTabView: View {
|
struct ScanTabView: View {
|
||||||
@EnvironmentObject private var router: Router
|
@EnvironmentObject private var router: Router
|
||||||
|
@EnvironmentObject private var session: Session
|
||||||
|
@State private var showNew = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
@@ -91,10 +93,28 @@ struct ScanTabView: View {
|
|||||||
ActionTile(title: "Auslagern", subtitle: "Barcode scannen und Menge entnehmen",
|
ActionTile(title: "Auslagern", subtitle: "Barcode scannen und Menge entnehmen",
|
||||||
systemImage: "arrow.up.to.line")
|
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()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
.navigationTitle("Scannen")
|
.navigationTitle("Scannen")
|
||||||
|
.sheet(isPresented: $showNew) {
|
||||||
|
NavigationStack {
|
||||||
|
ProductFormView(prefillBarcode: nil, groupId: nil) { _ in
|
||||||
|
showNew = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user