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:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user