From 53492ad4abffa975c0c041055529de10afc25ffb Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Tue, 28 Jul 2026 16:23:19 +0200 Subject: [PATCH] iOS: Gegenstaende-Liste - Filter nach Verwaltungsart Neuer "Verwaltung"-Filter (nur in der Gegenstaende-Liste): Menge je Lagerort / Einzelstuecke / Verbrauchsgegenstand. Co-Authored-By: Claude Opus 4.8 --- ios/Sources/ListViews.swift | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/ios/Sources/ListViews.swift b/ios/Sources/ListViews.swift index 5d4a3b9..29663d0 100644 --- a/ios/Sources/ListViews.swift +++ b/ios/Sources/ListViews.swift @@ -202,6 +202,8 @@ struct ProductListView: View { /// nil = alle, 0 = ohne Kategorie, sonst die ID (Unterkategorien zaehlen mit). @State private var categoryId: Int? @State private var sortMode: SortMode = .nameAsc + /// nil = alle; sonst "count"/"individual"/"bulk" (nur in der Gegenstände-Liste). + @State private var verwaltungFilter: String? @State private var busy = false @State private var showNew = false @@ -212,10 +214,24 @@ struct ProductListView: View { var id: String { rawValue } } - /// Auf den festen Typ gefiltert (clientseitig, wie im Web). + private let verwaltungOptionen: [(String, String)] = [ + ("count", "Menge je Lagerort"), + ("individual", "Einzelstücke"), + ("bulk", "Verbrauchsgegenstand"), + ] + + /// Verwaltungsart eines Gegenstands. + private func verwaltung(_ p: Product) -> String { + p.isIndividual ? "individual" : (p.isBulk ? "bulk" : "count") + } + + /// Auf den festen Typ und ggf. die Verwaltungsart gefiltert (wie im Web). private var sichtbar: [Product] { - guard let fixedType else { return products } - return products.filter { ($0.isObject ? "object" : "food") == fixedType } + products.filter { p in + if let fixedType, (p.isObject ? "object" : "food") != fixedType { return false } + if let vf = verwaltungFilter, verwaltung(p) != vf { return false } + return true + } } /// Sichtbare Produkte in der gewählten Reihenfolge. @@ -270,6 +286,17 @@ struct ProductListView: View { Text(filterLabel).foregroundStyle(.secondary) } } + if fixedType == "object" { + Picker(selection: $verwaltungFilter) { + Text("Alle").tag(String?.none) + ForEach(verwaltungOptionen, id: \.0) { opt in + Text(opt.1).tag(String?.some(opt.0)) + } + } label: { + Label("Verwaltung", systemImage: "square.grid.2x2") + } + .pickerStyle(.menu) + } Picker(selection: $sortMode) { ForEach(SortMode.allCases) { Text($0.rawValue).tag($0) } } label: {