-
Notifications
You must be signed in to change notification settings - Fork 22
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
Update date field handling #358
Update date field handling #358
Conversation
Before this commit setting the value of a date field to the current date required changing the date picker to some other value and then changing it back to the current date. This commit fixes that workflow by setting the date field value on focus and adding a toolbar with a "Clear" button to remove the value if it was set accidentally. To properly clear a previously saved date value required changing the implementation of `updateDictWithValueFromCell:` to set an `NSNull` in the dictionary rather than omitting the key from the dictionary entirely.
The `updatedString` property is nil in two situations, the field was initially empty or an initially non-empty field was cleared. To remove the ambiguity I added two new properties to keep track of the initial value of the field and whether or not it was cleared by the user.
Some date strings include a `00:00` time that was causing string to date object conversions to fail. We have implemented a simple solution, falling back to trying to parse the date+time format if parsing the date-only format returns nil.
Reopening to connect with issues. |
{ | ||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | ||
[dateFormatter setDateFormat:OTMEnvironmentDateStringShort]; | ||
NSDate *newDate=[dateFormatter dateFromString:dateString]; |
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.
Might want to format with spaces around equals sign here
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.
Deferring this whitespace fix to to avoid spending time rebasing and retesting.
Before this commit setting the value of a date field to the current date required changing the date picker to some other value and then changing it back to the current date. This commit fixes that workflow by setting the date field value on focus and adding a toolbar with a "Clear" button to remove the value if it was set accidentally.
To properly clear a previously saved date value required changing the implementation of
updateDictWithValueFromCell:
to set anNSNull
in the dictionary rather than omitting the key from the dictionary entirely.The
updatedString
property is nil in two situations, the field was initially empty or an initially non-empty field was cleared. To remove the ambiguity I added two new properties to keep track of the initial value of the field and whether or not it was cleared by the user.Some date strings include a
00:00
time that was causing string to date object conversions to fail. We have implemented a simple solution, falling back to trying to parse the date+time format if parsing the date-only format returns nil.Testing
Date default and clear button
Date Planted
field. Save the tree and verify that the current date is saved as the value ofDate Planted
Date Planted
field, and click theClear
button. Save the tree and verify that the value has been removed from the tree.Persistence, clearing, and display
Connects to #217
Connects to #357