Skip to content

Replace date picker for entities card#6899

Merged
bramkragten merged 2 commits intodevfrom
date-picker
Nov 9, 2020
Merged

Replace date picker for entities card#6899
bramkragten merged 2 commits intodevfrom
date-picker

Conversation

@thomasloven
Copy link
Contributor

Proposed change

Type of change

Use the vaadin-date-picker we already have for input_datetime in the entities card too.
I made a wrapper to make is ISO compliant and change the formating a bit so it looks more like the paper-input used for time inputs.

I also replaced the date picker in the more-info dialog with the wrapped version.
image

Finally fixes #4866.

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@thomasloven thomasloven force-pushed the date-picker branch 2 times, most recently from 57a5340 to b72f898 Compare September 9, 2020 21:51
Comment on lines +9 to +10
this.i18n.formatDate = this._formatISODate;
this.i18n.parseDate = this._parseISODate;
Copy link
Member

Choose a reason for hiding this comment

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

We should show the date in the format of the user language, we have functions for that: https://github.com/home-assistant/frontend/blob/dev/src/common/datetime/format_date.ts#L4

Copy link
Member

Choose a reason for hiding this comment

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

Something like formatDateShort(new Date(d.year, d.month, d.day), this.hass.language)

@bramkragten
Copy link
Member

Styling in dark mode is wrong:
image

@bramkragten
Copy link
Member

And can someone remind me why we can't use <input type="date">?

@KTibow
Copy link
Contributor

KTibow commented Sep 29, 2020

Maybe because it might look old or bad on some devices? Also not everything supports it.

@zsarnett
Copy link
Contributor

Fing safari man
image

@bramkragten
Copy link
Member

bramkragten commented Sep 29, 2020

Fuck safari, let them have text inputs 😛 but then we can't parse that to a date object because safari only accepts ISO 8601 strings....

@zsarnett
Copy link
Contributor

I don't understand why they have to make literally everything so Difficult

@bramkragten
Copy link
Member

It's weird that we don't have a localDateStringToDate function...

@thomasloven
Copy link
Contributor Author

image
Theming has been fixed.

Parsing date strings according to locale seems way harder than you'd think at first glance. Especially since we allow several formats for this; DD, MM-DD, YY-MM-DD and YYYY-MM-DD.
Then there's the order, separators, pre- and postfixes to keep track of. And that's just for those that use the Julian calendar...

@thomasloven
Copy link
Contributor Author

There's still an annoying 5 px difference in alignment between date and time numbers, but I didn't want to ugly-hack it away, and anything better would require getting more vaadin stuff imported - which I believe we try to avoid? The date picker is used here because we already had it anyway.

@bramkragten bramkragten merged commit 4fe0276 into dev Nov 9, 2020
@bramkragten bramkragten deleted the date-picker branch November 9, 2020 22:27
KTibow pushed a commit to KTibow/frontend-1 that referenced this pull request Nov 10, 2020
KTibow added a commit to KTibow/frontend-1 that referenced this pull request Nov 10, 2020
@bramkragten bramkragten mentioned this pull request Nov 11, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date Picker Display Issues on Chrome (Windows 10)

5 participants