Missing Field Handling

This commit is contained in:
2026-05-01 13:54:05 -05:00
parent 5a6491fa51
commit 09447be473
9 changed files with 252 additions and 105 deletions

View File

@@ -66,19 +66,21 @@ final class AddChemicalViewModel {
}
/// Edit mode all fields pre-populated from the existing chemical.
/// Required fields may be nil on rows that were imported with missing data;
/// the form will show them blank and require the user to fill them in to save.
init(editing chemical: Chemical) {
self.editingID = chemical.id
chemicalName = chemical.chemicalName
casNumber = chemical.casNumber
physicalState = chemical.physicalState
storageDevice = chemical.storageDevice
piFirstName = chemical.piFirstName
bldgCode = chemical.bldgCode
lab = chemical.lab
storageLocation = chemical.storageLocation
numberOfContainers = chemical.numberOfContainers
amountPerContainer = chemical.amountPerContainer
unitOfMeasure = chemical.unitOfMeasure
chemicalName = chemical.chemicalName ?? ""
casNumber = chemical.casNumber ?? ""
physicalState = chemical.physicalState ?? ""
storageDevice = chemical.storageDevice ?? "Glass Bottle"
piFirstName = chemical.piFirstName ?? ""
bldgCode = chemical.bldgCode ?? ""
lab = chemical.lab ?? ""
storageLocation = chemical.storageLocation ?? ""
numberOfContainers = chemical.numberOfContainers ?? ""
amountPerContainer = chemical.amountPerContainer ?? ""
unitOfMeasure = chemical.unitOfMeasure ?? ""
chemicalFormula = chemical.chemicalFormula ?? ""
molecularWeight = chemical.molecularWeight ?? ""
concentration = chemical.concentration ?? ""