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

Towards supporting Smarty5 (replace addDate by datepicker) #736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mlutfy
Copy link

@mlutfy mlutfy commented Dec 29, 2024

Fixes a few jcalendar/smarty5 issues on the "Create new Mandate" form, but it still has a bug, which unfortunately I could not figure out.

To reproduce: enable smarty5 (by default in CiviCRM 5.80+), enable SEPA ext, and then create a new mandate. The popup will fail with a network error, and the error will be Syntax error in template "file:CRM/common/jcalendar.tpl" .

This PR includes:

  • Replaces $form->addDate by $form->add('datepicker', ...
  • Removes jcalendar from the tpl files (it does not work on smarty5)
  • Uses CRM.utils.formatDate() for formatting dates
  • Fixes the JavaScript closure so that we can use $ and ts without the domain (but didn't change everything)

This PR has a bug:

  • sdd_recalculate_fields recalculates all fields, and also updates them, which causes recursive updates if we want to trigger "change" so that things like selecting the earliest rcur start date works. I don't know enough about the logic of the code to be sure that I will not be introducing bugs.

@@ -24,29 +25,25 @@ cj(document).ready(function() {
* Utility function to set the date on the %^$W#$&$&% datepicker elements
* PRs welcome :)
**/
function sdd_setDate(fieldname, date) {
function sdd_setDate(fieldname, date, recalculate = true) {
Copy link
Author

Choose a reason for hiding this comment

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

This recalculate param can be ignored, does not work. It was to avoid recursive issues, when sdd_setDate is called from sdd_recalculate_fields. It is not enough, because there is also an event listener for change on most of the date fields.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot @mlutfy, we'll try to pick this up after the holidays.

Happy holidays and new year!

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.

2 participants