edisonywh / backoffice

Admin tool built with the PETAL stack
MIT License
217 stars 15 forks source link

Datetime picker #53

Open NduatiK opened 3 years ago

NduatiK commented 3 years ago

Hi @edisonywh,

Are there any plans implement a datetime picker for Ecto date and time types (:utc_datetime, :naive_datetime, :date, :time, :any, :utc_datetime_usec, :naive_datetime_usec, :time_usec)?

According to Mozilla's browser documentation, text=[datetime-local] is not fully supported.. This makes me think we would need a cross browser (read custom) implementation for a consistent experience.

What do you think of using an existing tailwind implementation? Here are some I found:

Does it even have to be a tailwind datepicker?

I think we can ignore the lack of time pickers as most people will have no trouble typing them in (default to the current time?) but will benefit from not having to type in dates using the ISO format.

Things become tricky when we have to handle UTC vs local timezone so maybe placing a dropdown with UTC vs local might be of value.


What do you think?

edisonywh commented 3 years ago

Tailwind is just the CSS portion, from the example you shared, the first one seems to re-implement the datepicker UI, the second one uses pikaday, and not sure about the 3rd one, maybe it's pure Vue? We're definitely not going to go implement Vue for just a small part like this though, so most likely we'd need a pure JS implementation like flatpickr/pikaday.

I'm not sure why UTC vs local timezone matters, we only support whatever Ecto does, or do you mean that maybe sometimes people want to store in UTC but display in local? (Now that I'm typing it, this does seem like a potential use case).

Like you said though, this is probably not a super huge priority in the grand scheme of things, but it definitely be nice to have.

By the way, I've been busy with some things lately, I'll get to review & reply your other comments soon!

NduatiK commented 3 years ago

I'm not sure why UTC vs local timezone matters, we only support whatever Ecto does, or do you mean that maybe sometimes people want to store in UTC but display in local? (Now that I'm typing it, this does seem like a potential use case).

I was thinking of :naive_datetime that ignores timezones. If a user puts in today's date at 3pm, I imagine in that case we would want to store the exact time put in and not one offset by their timezone.

NduatiK commented 3 years ago

By the way, I've been busy with some things lately, I'll get to review & reply your other comments soon!

No problem

edisonywh commented 3 years ago

I was thinking of :naive_datetime that ignores timezones. If a user puts in today's date at 3pm, I imagine in that case we would want to store the exact time put in and not one offset by their timezone.

Exactly, so I don't really see how that matters, we don't need a timezone field in the datepicker

NduatiK commented 3 years ago

🤦🏽‍♂️ Its obvious that we don't need one now. I'm not sure what I was going for. I agree - no timezone field.