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

Fixed bug that required alMax #245

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Fixed bug that required alMax #245

merged 1 commit into from
Jan 17, 2024

Conversation

BryceStevenWilley
Copy link
Contributor

#241 introduced a slight regression that assumed that both alMax and alMin would be present. If they weren't, the JS on the page would stop running, resulting in error messages not going away even when corrected.

Tested on my local server and it fixed the problem, removing the errors in my browser console.

Fix #244

Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

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

Great catch! Sorry you had to run into that. I think it needs one fix before it's ready to go.

Comment on lines +547 to +550
if (!max_attr) {{
// Validation should always succeed if no minimum given
return true;
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's a birthdate field, it still needs to have a max birthdate. I can't make a full suggestion because it would include code that isn't changed, but I imagine would go something like this:

max_date = new Date();
max_attr = ...
if ( max_attr ) {
  max_date = max_attr stuff
} else {
  if ( !is_birthdate) { return true; }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's true? The demo doesn't specify a max date for the example birth date at all (and it doesn't look like there's any available in the DOM.

  - Birth date (today is valid): date_of_birth
    datatype: BirthDate
    required: True
    validation messages:
      required: This is a custom 'required' message.

If we do want to start enforcing the max attribute for birthdates, what is it supposed to do if there isn't a max attribute on the birthdate? I don't see any good examples of our error handling for developer errors in javascript.

Should it just keep the current PR's code, and have future dates be handled by the python validation, which always happens for Birth dates?

Copy link
Member

Choose a reason for hiding this comment

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

It sounds to me like @plocket forgot that the birthdate validation was happening in Python, not JS. This seems good to merge to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the code in the DOM sets the max date for BirthDate to the current date as the default:

if ( isNaN(max_date) && is_birthdate(field)) {{
max_date = new Date();
}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, thanks plocket. I misunderstood what you were saying, and I got a little lost in the code and didn't see the line right below. I'll fix this in a new PR since this was merged too soon.

@nonprofittechy nonprofittechy merged commit ab998e2 into main Jan 17, 2024
4 checks passed
@BryceStevenWilley BryceStevenWilley deleted the almax_bug branch January 17, 2024 20:38
BryceStevenWilley added a commit that referenced this pull request Jan 19, 2024
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.

Three Part Date: TypeError get_$original_date(...).attr(....) is undefined
3 participants