Skip to content
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

Merged
merged 3 commits into from
Oct 3, 2017

Conversation

jwalgran
Copy link
Contributor

@jwalgran jwalgran commented Sep 12, 2017

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.


Testing
  • On a test instance, add one of each type of custom field to the Tree model.
Date default and clear button
  • Create a tree and tap to focus on the Date Planted field. Save the tree and verify that the current date is saved as the value of Date Planted
  • Edit the tree, tap to focus on the Date Planted field, and click the Clear button. Save the tree and verify that the value has been removed from the tree.
Persistence, clearing, and display
  • Add a tree and set a value in all of the custom fields.
  • Save, deselect the tree, select the tree, view the details and verify that all values display correctly.
  • Edit the tree and clear each custom field value one at a time. Save and reload the tree and verify that the field values have been cleared.

Connects to #217
Connects to #357

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.
@jwalgran
Copy link
Contributor Author

Reopening to connect with issues.

@jwalgran jwalgran closed this Sep 13, 2017
@jwalgran jwalgran reopened this Sep 13, 2017
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:OTMEnvironmentDateStringShort];
NSDate *newDate=[dateFormatter dateFromString:dateString];

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

Copy link
Contributor Author

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.

@jwalgran jwalgran merged commit 0ce029e into OpenTreeMap:master Oct 3, 2017
@jwalgran jwalgran deleted the feature/date-field-handling branch October 3, 2017 17:00
@jwalgran jwalgran removed the in review label Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants