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

fix(shortcode): load modal forms in form grid via AJAX #2951 #2955

Merged
merged 55 commits into from Apr 17, 2018

Conversation

Sidsector9
Copy link
Contributor

@Sidsector9 Sidsector9 commented Mar 27, 2018

Closes #2951

Phase - 1

All the forms were loaded and hidden via CSS on the form grid page.

Phase - 2

@kevinwhoffman suggested instead of loading every form at once, we should instead use AJAX and fetch only the form that is required. This will also speed up the load time of the form grid page.

After some research here and here, it was determined that implementing AJAX at the current stage of Give Core, it might break certain add-ons.

Phase - 3

This phase was reverting back to phase - 1 and making some additional fixes as suggested by @kevinwhoffman and @ravinderk here and here.

Future plans

We will be implementing this with Ajax after the Javascript files have been refactored to the requirements.

How Has This Been Tested?

Manually tested

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows has proper inline documentation.

Earlier every grid item had form hidden using CSS, now the hidden form is instead fetched using AJAX.
@ravinderk
Copy link
Collaborator

ravinderk commented Mar 27, 2018

@Sidsector9

  1. Can you confirm that you tested this with recurring addon + multiple payment gateways?
  2. Also, did you test a case where the same form exist twice on the page?

@@ -263,3 +259,125 @@
.my-mfp-slide-bottom.mfp-removing.mfp-bg {
opacity: 0;
}

.white-popup {
Copy link
Member

Choose a reason for hiding this comment

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

@Sidsector9 I feel these magnific styles should exist outside of the grid stylesheet within their own since likely these styles will be used in other places as well and finding them here seems difficult for developer who don't know. @kevinwhoffman what are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Sid and I are going to meet and review ITCSS and I think reworking these class names and locations would be a good first task.

@DevinWalker
Copy link
Member

@Sidsector9 please reply to @ravinderk's query above asap. I'm also going to request a review by @ravinderk

@kevinwhoffman also wants to do a call with @Sidsector9 regarding ITCSS. I'm moving this from the "Ready for QA" pipeline.

@Sidsector9
Copy link
Contributor Author

Sidsector9 commented Mar 29, 2018

Call Summary
Participants: @ravinderk and @Sidsector9
Topic: Events don't fire of elements loaded via AJAX after DOM is loaded.

Result: We are fetching HTML of the form to show inside a popup. Till here, it works well.
The problem arises when the fetched HTML contains elements which are attached to event handlers. Since this fetched HTML was not originally part of the DOM and appended via AJAX after the DOM was loaded, the event handlers could not be attached to the the elements, unless, they're already being handled via event delegation.

For example, I wasn't able to change the payment method because the radio buttons were not attached to the event handlers since they were loaded after the DOM was loaded. So I made a small change (see here), where I was able to make it work via event delegation. Then came another problem where the the CC number wasn't being formatted because Give.form.fn.field.formatCreditCard() was fired on give_gateway_loaded event.

@ravinderk and I concluded that the existing JS must be rewritten in a way that we don't miss out on anything while working on this feature OR we should only implement the redirect feature and have the modal feature for future release.

CC: @DevinWalker @kevinwhoffman

@kevinwhoffman
Copy link
Contributor

It sounds like there will be a lot of hurdles in the way of making Give forms load entirely through AJAX. We also have to consider all of our add-ons' functionality and ensure that they get initiated correctly when the form does not exist on the page at load time.

@ravinderk Can you please provide a story point estimate of what it would take to get Give forms to load via AJAX, including compatibility with each of our add-ons?

@ravinderk
Copy link
Collaborator

@kevinwhoffman @DevinWalker

Suggestion:
I think we can output HTML of form in the hidden mode for modal view.
I can see backward compatibility issue which we will face when we will update logic to render modal with ajax. My recommendation is to change the name from modal to something and preserve it for ajaxify modal display_style which will help us to deprecated functionality without compromising shortcode attribute name.

Question:

  1. @kevinwhoffman can we change default display_style value from redirect to other because we can not force the admin to enable single donation form page if not doing yet.

@DevinWalker
Copy link
Member

@ravinderk - yes it's fine to switch the default display_style.

@kevinwhoffman
Copy link
Contributor

kevinwhoffman commented Apr 5, 2018

Slack Call Summary

Participants: @ravinderk @kevinwhoffman
Topic: Discuss backwards compatibility concerns with renaming modal
Result: Ravinder made a good point about third-party code possibly breaking in the future if we change the forms to load via AJAX. Therefore we should treat the AJAX and non-AJAX display styles as separate attributes.

Set the default display_style to modal_reveal which will load the hidden forms on the page and reveal them when the card is clicked. This is the current behavior as seen in the last video I recorded.

In the future, we may introduce a truly modal display style which will load the forms via AJAX. Do not worry about including this for now.

Remaining Tasks

  • Set default display_style to modal_reveal and update logic accordingly.

Sidsector9 and others added 3 commits April 5, 2018 15:22
This is a revert commit. The forms are shown/hidden instead of
using AJAX to load the form.
display_style "modal" is changed to "modal_reveal"
Copy link
Collaborator

@ravinderk ravinderk left a comment

Choose a reason for hiding this comment

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

@DevinWalker @kevinwhoffman please review this pr and merge it. Working fine for me.

@DevinWalker
Copy link
Member

Review Findings

@Sidsector9 it's working well but I found a plugin conflict with Currency Switcher add-ons. Please work with @emgk and @ravinderk to resolve the following:

  • Very noticeable delays in load time needs resolving
  • Ensure modal window loads properly
  • Ensure feature image displays as expected

See my video while I debugged for more info: https://goo.gl/6HT84Z

After I finished recording I isolated the issue to the Currency Switcher add-on.

@Sidsector9
Copy link
Contributor Author

Call Summary

Participants: @emgk and @Sidsector9
Topic: Form data don't display in modal popup due to Currency Switcher add-on
Result: Enabling Currency Switcher sets form id to 0 which is why the popup doesn't show up the data. @emgk will be fixing this issue.

@Sidsector9
Copy link
Contributor Author

@DevinWalker, 2/3 points you mentioned are being addressed below:

Ensure modal window loads properly

@emgk has fixed the bug in Currency Switcher add-on and that made the form load correclty

Ensure feature image displays as expected

The feature image too loads correctly after the above said fix

Kindly test this from your end and let me know if further improvements need to be done.

Sidsector9 and others added 2 commits April 12, 2018 18:58
# Conflicts:
#	assets/src/css/frontend/give-frontend.scss
#	assets/src/css/frontend/modal.scss
#	includes/shortcodes.php
@ravinderk
Copy link
Collaborator

@Sidsector9 I think do not care about #3030 issue for on form grid page. Currently auto open modal on basis of URL param does not work with a form with display_style set to button.

We have to work from the ground to make it compatible with display_style=button also. So ignore it for now.

@DevinWalker What do you think

Sidsector9 and others added 3 commits April 13, 2018 11:14
If you visit a URL directly with query parameters 'form-id' and 'payment-mode' for a form with display type 'button', the popup will pop up.
ravinderk and others added 25 commits April 16, 2018 21:04
new fn give_get_donation_donor_email
Stop using Give_Payment and Give_Donor to improve performance on frontend
Stop using Give_Payment and Give_Donor to improve performance on frontend
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.

None yet

7 participants