4site-interactive-studios / engrid

The Unlicense
10 stars 4 forks source link

allow embedded ecard to have multiple recipients #308

Closed MichaelT372 closed 3 months ago

MichaelT372 commented 3 months ago

This patch adds an enhancement to the Embedded Ecard component to allow for Ecards to have multiple recipients. In the previous version, it was only intended to have 1 recipient, the "add recipient" button was hidden and the values from the inputs were taken as the recipient name+email.

In this new version, if the "add recipient" button is hidden, the old functionality will still work - allowing us to keep that streamlined form experienced.

But if the "add recipient" button is visible then recipients are taken from the "recipient list" element. This is done with a MutationObserver on that element so that the recipients are kept up to date when adding/removing them from the list.

Also introduced an "isSubmitting" flag to prevent some circular logic that re-set the session storage items in some conditions.. 🙃

Functionality can be tested on this page: https://protect.worldwildlife.org/page/71102/donate/1 it uses a build of WWF's theme with this branch.

To try it with a single recipient experience, go to the ecard page https://us.engagingnetworks.app/index.html#pages/71103/edit and uncomment the code in the "test single recipient code block"