Skip to content

Commit

Permalink
MAE-179: Improving autorenewal user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
omarabuhussein committed Jul 27, 2021
1 parent 5f24ff4 commit 4c6ff48
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions js/webform_civicrm_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,29 @@ var wfCiviAdmin = (function ($, D) {
}
}).change();

var autorenewMembershipsTracker = {};
var $membershipPageSelect = $('.form-item-membership-1-number-of-membership');
$('select[name$=_membership_auto_renew]').change(function(e, type) {
var fieldName = $(this).attr('name');
autorenewMembershipsTracker[fieldName] = $(this).val();

autorenew_counter = 0;
for(var key in autorenewMembershipsTracker){
if (autorenewMembershipsTracker[key] != 0) {
autorenew_counter++;
}
}

if (autorenew_counter > 1) {
if (!$('.wf-crm-membership-autorenew-alert').length) {
var msg = Drupal.t("Ensure that the memberships selected to be Auto-Renewed have the same frequency unit and interval or otherwise it might not work well !");
$membershipPageSelect.after('<div class="messages error wf-crm-membership-autorenew-alert">' + msg + '</div>');
}
} else {
$('.wf-crm-membership-autorenew-alert').remove();
}
});

function billingMessages() {
var $pageSelect = $('[name=civicrm_1_contribution_1_contribution_contribution_page_id]');
// Warning about contribution page with no email
Expand Down

0 comments on commit 4c6ff48

Please sign in to comment.