-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INSPECT-313] FEATURE** Further enhance inspection validation #318
Conversation
README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
The linter went wild in this file. So there is a lot more diffs than anticipated.
There is information added about working with XCode 15, and deleting all Realm objects added
…atus flow. convert status check for consistency
6e8fdce
to
d520884
Compare
- Add formDidValidate to prevent submission of unvalidated inspection at restart - renamed water craft inspection folder - optimized updateStatuses() function - removed print statement in viewWillDisappear function
setupCollectionView() | ||
self.collectionView.reloadData() | ||
addListeners() | ||
} | ||
|
||
/// Iterates through inspections checking formDidValidate. If any form does validate, modifies all appropraite statuses to `.Errors` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimized updateStatuses so that if model is null, we don't have a crash (use of guard as found elsewhere in the file)
@@ -177,12 +193,14 @@ class ShiftViewController: BaseViewController { | |||
@objc func completeAction(sender: UIBarButtonItem) { | |||
guard let model = self.model else { return } | |||
self.dismissKeyboard() | |||
|
|||
self.updateStatuses() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added updateStatus before checking canSubmit, so we have the most up to date info on the validation of inspections
// if can submit | ||
var alertMessage = "This shift and the inspections will be uploaded when possible" | ||
if model.shiftStartDate < Calendar.current.startOfDay(for: Date()) { | ||
alertMessage += "\n\n You've entered a date that occurred before today. If this was intentional, no problem! Otherwise, please double-check the entered date: \n\(model.shiftStartDate.stringShort())" | ||
} | ||
if canSubmit() { | ||
if canSubmit() && model.inspections.allSatisfy({ $0.formDidValidate }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addition of the if statement prevents the user to submit an error containing inspection (avoiding our open loop validation problem)
|
||
if !message.isEmpty { | ||
model.set(status: .Errors) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if !message.isEmpty block may be redundant and removable with our other checks in place, however I will have to confirm with some testing
@@ -343,6 +361,17 @@ class ShiftViewController: BaseViewController { | |||
} | |||
} | |||
} | |||
|
|||
// Check for invalid inspections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checks our invalid inspections and let's the user know that the inspections contain validation errors. It is possible to let the users know which validation in particular here too, but that is handled in the inspections page specifically (may be something to review with SO)
Warning
This work was not approved for the on-season (as of 06/14/24) and should not be merged in without the SO verifying they want it. It should remain saved until the off-season and made part of the normal bundle of work.
Caution
This work was off of the existing production branch that had its targets pointing to
dev
. This may require the branch being updated to point point at.dev
again if this has been changed to.prod
Pull Request Standards
HOTFIX
,FEATURE
,etc
][INSPECT-###]
Description
This PR includes the following proposed change(s):
Add new boolean flag to Inspections
formDidValidate
When user goes to submit a shift, the shift checks that
all
inspections haveformDidValidate == true
.Errors
Converted several
string == ""
checks to the swift built in flagstring.isEmpty
Added check of inspection validation errors on reboot when user selects submit
Renamed Watercraft Inspection folder
Current error message when a user reboots the app with the validation errors and attempts to submit the invalidated shift: