Skip to content

Fix #3585 date-time and time support#3651

Merged
MV88 merged 11 commits intogeosolutions-it:masterfrom
MV88:3585_date_time
May 2, 2019
Merged

Fix #3585 date-time and time support#3651
MV88 merged 11 commits intogeosolutions-it:masterfrom
MV88:3585_date_time

Conversation

@MV88
Copy link
Copy Markdown
Contributor

@MV88 MV88 commented Mar 27, 2019

Description

This pr add the support for date-time and time attributes.
Now you can use them in the Attribute Filter field.

  • When changing the operator it will reset the value
  • It starts with time 00:00:00 when selecting a date
  • updated formats for date and hours
  • requests are done in date UTC (the same you see in the input field)

Issues

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
date-time and time are not supported
We are not using utc date in the date picker and in the requests they are shifted to UTC
Hours are set to actual date if date only is used

What is the new behavior?
see description

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:
Please note that the date formats are a bit changed since it was not displaying correctly the Year,
and for the hours it was using month instead of minutes

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 27, 2019

Coverage Status

Coverage increased (+0.2%) to 81.208% when pulling 1292ff4 on MV88:3585_date_time into e3f4f11 on geosolutions-it:master.

@geosolutions-it geosolutions-it deleted a comment Mar 27, 2019
@geosolutions-it geosolutions-it deleted a comment Mar 28, 2019
Copy link
Copy Markdown
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have time to test it. I'll do it tomorrow morning. But you can start fixing namings and other things

* @param {object} options to pass to the enhancer
* @param {string} options.dateType type choosed from ("date", "time", "date-time")
* @param {string} options.dateField date to use
* @param {string} options.setDateField function to use to update the date
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call them props, not fields.
dateProp, setDateProp

* instead without it will be used as 2019-03-19T23:00:00.000Z (in cql filter), but in the UI it will be used the
* actual timezone
*/
module.exports = ({dateType = "type", dateField = 'date', setDateField = 'onSetDate'} = {}) => compose(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"type" is not one of the allowed values. use datetime

Copy link
Copy Markdown
Contributor Author

@MV88 MV88 Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dateType is where to check in the props the prop type = ('time', 'date', 'date-time')
I would call it dateTypeProp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. Yes, fine. That's a better name

expect(LocaleUtils.getDateFormat("hr-HR")).toBe("DD/MM/YYYY");
expect(LocaleUtils.getDateFormat("pt-PT")).toBe("DD/MM/YYYY");
});
it('DATE_FORMATS', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not useful at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if you accidentally erase the it-IT date format customization. it will use the default one.
this checks the presence of the customization for the some locales. i'll update the it description

expect(LocaleUtils.getLocalizedProp('fr-FR', localizedObjectProp)).toBe('title');
});
it('getDateFormat', () => {
expect(LocaleUtils.getDateFormat()).toBe("YYYY/MM/DD");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is a check for unknown locale. Please describe in a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for getting the default one

* @param {object} date
* @return {number} the offset in milliseconds
*/
const getTimezoneOffset = (date) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTimezoneOffsetMillis, or can be confused with original one

};

/**
* @param {object} date to get only date parts (without time parts)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {object} date to get only date parts (without time parts)
* @param {Date|string} date to parse


/**
* @param {object} date to get only date parts (without time parts)
* @return {string} used to compose a UTC date
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return {string} used to compose a UTC date
* @return {string} date part of the TimeStamp

});
it('render with value', () => {
ReactDOM.render(<DateTimeFilter type="date" value={"2017-01-05Z"}/>, document.getElementById("container"));
ReactDOM.render(<DateTimeFilter type="date" value="2017-01-05T04:04:04Z"/>, document.getElementById("container"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateTimeFilter should be enhanced, or I'm afraid it will not work with dates or times only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean it should handle partial date or time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw it is using the utcDateWrapper enhancer

const enddate = this.props.fieldValue && this.props.fieldValue.endDate || null;

// needed to initialize the time parts to 00:00:00
const defaultCurrentDate = moment().startOf("day").toDate();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why this is here (and in date filter) if is needed to make UTCDateTimePicker work, it should be inside it (enhancer, setting, for instance moment().startOf("day").toDate() as default value.

If has another reason, please explain better.

Copy link
Copy Markdown
Contributor Author

@MV88 MV88 Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to initialize the time part

Imagine the "date" case:
DateTimePicker component is initialized with a new Date based on that moment and it includes the time part.

then you select a date from the calendar but the time part will remain untouched.
with defaultCurrentDate it changes the time part of the initial value

notice that it does that also for date-time case (we may want to not do it for that case)
i think we can put it in the enhancer enabled by a flag or by the type

Copy link
Copy Markdown
Contributor Author

@MV88 MV88 Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@offtherailz I'll update the enhancer with the defaultCurrentDate = moment().startOf("day").toDate(); at least for "date" format

@geosolutions-it geosolutions-it deleted a comment Apr 1, 2019
Copy link
Copy Markdown
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one comment. In addition:
we are waiting for a VM to test this kind of stuff. It should be ready in the next few days.

It should be perfect if we postpone the check of the functionalities when we have that VM (so we don't have to recreate test data every time on our machines).
Now I'm not able to test this without spending a couple of hours configuring the local environment with the required data. I prefer to spend this time to make this data available for testers. @tdipisa what do you think?

@offtherailz
Copy link
Copy Markdown
Member

Tested with this map.
It works 👍
Only the last comment is still pending @MV88

@geosolutions-it geosolutions-it deleted a comment from offtherailz Apr 18, 2019
@geosolutions-it geosolutions-it deleted a comment Apr 24, 2019
@geosolutions-it geosolutions-it deleted a comment Apr 24, 2019
@MV88 MV88 requested a review from offtherailz April 29, 2019 10:32
@tdipisa tdipisa added this to the 2019.02.00 milestone Apr 29, 2019
@tdipisa tdipisa modified the milestones: 2019.02.00, 2019.01.01 Apr 29, 2019
@MV88 MV88 merged commit fd1fe07 into geosolutions-it:master May 2, 2019
MV88 added a commit to MV88/MapStore2 that referenced this pull request May 2, 2019
…3651)

Fix geosolutions-it#3585 added date-time and time support (geosolutions-it#3651)

* Add utc enhancer to the dateTimePicker components + tests
* Fix tests for date time
* tentative fix for date time tests
* remove timezone test
* fix timeutils test
* update var names and tests
* Fix date or time values used in cql filter
* fix utcDateWrapper test
* Fix date problem with firefox
* fix failing test on firefox
MV88 added a commit that referenced this pull request May 2, 2019
Fix #3585 added date-time and time support (#3651)

* Add utc enhancer to the dateTimePicker components + tests
* Fix tests for date time
* tentative fix for date time tests
* remove timezone test
* fix timeutils test
* update var names and tests
* Fix date or time values used in cql filter
* fix utcDateWrapper test
* Fix date problem with firefox
* fix failing test on firefox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QueryPanel DateTime filter issues

4 participants