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 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-28 16:23:19 +02:00
parent f96286b3fa
commit 53492ad4ab

View File

@@ -202,6 +202,8 @@ struct ProductListView: View {
/// 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 sortMode: SortMode = .nameAsc @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 busy = false
@State private var showNew = false @State private var showNew = false
@@ -212,10 +214,24 @@ struct ProductListView: View {
var id: String { rawValue } 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] { private var sichtbar: [Product] {
guard let fixedType else { return products } products.filter { p in
return products.filter { ($0.isObject ? "object" : "food") == fixedType } 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. /// Sichtbare Produkte in der gewählten Reihenfolge.
@@ -270,6 +286,17 @@ struct ProductListView: View {
Text(filterLabel).foregroundStyle(.secondary) 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) { Picker(selection: $sortMode) {
ForEach(SortMode.allCases) { Text($0.rawValue).tag($0) } ForEach(SortMode.allCases) { Text($0.rawValue).tag($0) }
} label: { } label: {