Skip to content

Commit

Permalink
Merge pull request #290 from bcgov/inspect-287-waterbody-delete-bug
Browse files Browse the repository at this point in the history
[BUGFIX][INSPECT-#289] - Fix bug in Journey Details where toggling buttons wouldn't delete Waterbodies
  • Loading branch information
davidclaveau authored Feb 13, 2024
2 parents 30ea488 + b181824 commit ed5624a
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1408,16 +1408,30 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl
private func getJourneyDetailsCellType(for indexPath: IndexPath) -> JourneyDetailsSectionRow {
guard let model = self.model else {return .Divider}

// If the prev commercial/unknown/stored are toggled off, we delete the cities from model
// If the prev commercial/unknown/stored are toggled OFF, we delete the cities from model
if !arePreviousTogglesChecked(ref: model) && model.previousWaterBodies.isEmpty {
model.deleteMajorCity(isPrevious: true)
}

// If the dest commercial/unknown/stored are toggled off, we delete the cities from model
// If the prev commercial/unknown/stored are toggled ON, we delete the waterbodies from model
if arePreviousTogglesChecked(ref: model) && !model.previousWaterBodies.isEmpty {
for index in stride(from: model.previousWaterBodies.count - 1, through: 0, by: -1) {
model.removePreviousWaterBody(at: index)
}
}

// If the dest commercial/unknown/stored are toggled OFF, we delete the cities from model
if !areDestinationTogglesChecked(ref: model) && model.destinationWaterBodies.isEmpty {
model.deleteMajorCity(isPrevious: false)
}

// If the dest commercial/unknown/stored are toggled ON, we delete the waterbodies from model
if areDestinationTogglesChecked(ref: model) && !model.destinationWaterBodies.isEmpty {
for index in stride(from: model.destinationWaterBodies.count - 1, through: 0, by: -1) {
model.removeDestinationWaterBody(at: index)
}
}

// Header for "Journey Details" always at top
if indexPath.row == 0 {
return .Header
Expand Down

0 comments on commit ed5624a

Please sign in to comment.