Missing Field Handling
This commit is contained in:
@@ -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 ?? ""
|
||||
|
||||
Reference in New Issue
Block a user