rubyforgood / casa

Volunteer management system for nonprofit CASA, which serves foster youth in counties across America.
https://casavolunteertracking.org/
MIT License
286 stars 462 forks source link

Format date to US format MM/DD/YYYY #5580

Closed bcastillo32 closed 2 months ago

bcastillo32 commented 3 months ago

What type(s) of user does this feature affect?

Description

Date is formatted in an odd format. See screenshot below from Case Creation as an Admin:

image

we would instead like all date picking and formatting to be in US format (MM/DD/YYYY). Users should also be able to type it in as long as it matches the format. If they type it incorrectly please return a message letting them know the correct format required.

How to access the QA site

Login Details:
Link to QA site

Login Emails:

password for all users: 12345678

Questions? Join Slack!

We highly recommend that you join us in slack #casa channel to ask questions quickly. And discord for office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.

daviluis321 commented 3 months ago

I would like to help with this issue :)

bcastillo32 commented 3 months ago

I would like to help with this issue :)

Assigned. Thank you for the help! :)

github-actions[bot] commented 3 months ago

This issue has been inactive for 242 hours (10.08 days) and will be unassigned after 118 more hours (4.92 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time

RobBoothAppDev21 commented 3 months ago

Hi

By the way, ActiveRecord's default date format is yyyy/mm/dd. Dates passed along as mm/dd/yyyy are converted to "" resulting in court date objects being nil.

Removing bootstrap datepicker and data options and changing the input to a date_field will default to the browsers default picker and use the users locale format, mm/dd/yyyy for the US, but should submit in ActiveRecords preferred format of yyyy/mm/dd. The native picker has some slight styling difference and could require light js to open the calendar when the input field is selected. I included screenshots using the native picker in chrome.

app/views/casa_cases/_form.html.erb:67 current: <%= cdf.text_field :date, data: {provide: "datepicker", date_format: "yyyy/mm/dd"}, class: "form-control" %>

update: <%= cdf.date_field :date, class: "form-control" %>

Screenshot 2024-04-04 at 12 42 50 PM Screenshot 2024-04-04 at 12 43 35 PM

bcastillo32 commented 3 months ago

Hi

By the way, ActiveRecord's default date format is yyyy/mm/dd. Dates passed along as mm/dd/yyyy are converted to "" resulting in court date objects being nil.

Removing bootstrap datepicker and data options and changing the input to a date_field will default to the browsers default picker and use the users locale format, mm/dd/yyyy for the US, but should submit in ActiveRecords preferred format of yyyy/mm/dd. The native picker has some slight styling difference and could require light js to open the calendar when the input field is selected. I included screenshots using the native picker in chrome.

app/views/casa_cases/_form.html.erb:67 current: <%= cdf.text_field :date, data: {provide: "datepicker", date_format: "yyyy/mm/dd"}, class: "form-control" %>

update: <%= cdf.date_field :date, class: "form-control" %>

Screenshot 2024-04-04 at 12 42 50 PM Screenshot 2024-04-04 at 12 43 35 PM

Hi @RobBoothAppDev21 apologies for my delayed response - I had just got back from traveling and was catching up on some stuff for work. Thank you for the detailed explanation. Can we go ahead and change all date pickers to the native one? From what I understand, this will fix the issue, correct?

RobBoothAppDev21 commented 3 months ago

Yes, using the native browser should fix it.

No problem I'll get started on it.

bcastillo32 commented 3 months ago

Yes, using the native browser should fix it.

No problem I'll get started on it.

Thanks so much! 🙏🏼

ryoung-sf commented 2 months ago

@bcastillo32 Almost finished with updating the date picker to use mm/dd/yyyy format.

I added "onfocus: this.showPicker()" to the date fields to enable the date picker, calendar, to open when a user clicks on the field. The onfocus attribute in views/layouts/components/_ranged_date_picker.html.erb causes the tests on lines 42 and 189 to fail in the spec/systems/case_contacts/new_spec.rb to fail. The hours and minutes used to calculate the duration are being submitted as "0" in the test. I think the wizard and the onfocus attribute are conflicting but I can't determine where. However, this issue doesn't exist when running the app locally.

bcastillo32 commented 2 months ago

@bcastillo32 Almost finished with updating the date picker to use mm/dd/yyyy format.

I added "onfocus: this.showPicker()" to the date fields to enable the date picker, calendar, to open when a user clicks on the field. The onfocus attribute in views/layouts/components/_ranged_date_picker.html.erb causes the tests on lines 42 and 189 to fail in the spec/systems/case_contacts/new_spec.rb to fail. The hours and minutes used to calculate the duration are being submitted as "0" in the test. I think the wizard and the onfocus attribute are conflicting but I can't determine where. However, this issue doesn't exist when running the app locally.

Hi @ryoung-sf thanks for the update! Are you on our slack by chance? You can post there for help with tests if you need it.

github-actions[bot] commented 2 months ago

This issue has been inactive for 241 hours (10.04 days) and will be unassigned after 119 more hours (4.96 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time