Missing Field Handling
This commit is contained in:
@@ -7,6 +7,10 @@ final class InventoryViewModel {
|
||||
var isLoading = false
|
||||
var errorMessage: String?
|
||||
|
||||
var missingInfoCount: Int {
|
||||
chemicals.filter(\.isMissingKeyInfo).count
|
||||
}
|
||||
|
||||
private let client = ChemicalsClient()
|
||||
|
||||
func loadChemicals() async {
|
||||
@@ -73,6 +77,12 @@ struct InventoryView: View {
|
||||
}
|
||||
} else {
|
||||
List {
|
||||
if viewModel.missingInfoCount > 0 && !isSelectMode {
|
||||
Section {
|
||||
MissingInfoBanner(count: viewModel.missingInfoCount)
|
||||
}
|
||||
.listRowBackground(Color.orange.opacity(0.08))
|
||||
}
|
||||
ForEach(viewModel.chemicals) { chemical in
|
||||
if isSelectMode {
|
||||
Button {
|
||||
@@ -204,3 +214,27 @@ struct InventoryView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Missing-info banner
|
||||
|
||||
/// Shown above the inventory list when one or more rows are missing required
|
||||
/// fields (typically the result of a web spreadsheet import). Mirrors the
|
||||
/// amber banner on the web inventory page.
|
||||
private struct MissingInfoBanner: View {
|
||||
let count: Int
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .top, spacing: 10) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(.orange)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Missing Key Information")
|
||||
.font(.subheadline.weight(.semibold))
|
||||
Text("\(count) \(count == 1 ? "item is" : "items are") missing required fields. Tap an item flagged with “Missing info” to see exactly which fields and edit them.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user