From: Coleman Watts Date: Fri, 29 Aug 2014 15:38:03 +0000 (+0100) Subject: CRM-15058 - Cleanup and js bug fixes in ScheduleReminder forms X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=581c7be275490a5de6224655eed07800ceb63f20;p=civicrm-core.git CRM-15058 - Cleanup and js bug fixes in ScheduleReminder forms --- diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 0d764aaa30..9f81d2e847 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -176,7 +176,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->addElement('checkbox', 'record_activity', $recordActivity); $this->addElement('checkbox', 'is_repeat', ts('Repeat'), - NULL, array('onclick' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);") + NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);") ); $this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay); @@ -203,7 +203,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions); $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient], - FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") + FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") ); if (!empty($_POST['is_recipient_listing'])) { @@ -212,18 +212,14 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { elseif (!empty($this->_values['recipient_listing'])) { $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']); } - $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'), $recipientListingOptions); - $recipientListing->setMultiple(TRUE); - $this->add('hidden', 'is_recipient_listing', empty($recipientListingOptions) ? FALSE : TRUE, array('id' => 'is_recipient_listing')); + $this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE, + array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE)); + $this->add('hidden', 'is_recipient_listing', (int) !empty($recipientListingOptions)); $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE)); - $this->addElement( - 'select', - 'group_id', - ts('Group'), - // CRM-13577 - CRM_Core_PseudoConstant::group() + $this->add('select', 'group_id', ts('Group'), + CRM_Core_PseudoConstant::nestedGroup(), FALSE, array('class' => 'crm-select2 huge') ); CRM_Mailing_BAO_Mailing::commonCompose($this); @@ -235,6 +231,8 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->add('checkbox', 'is_active', $isActive); $this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule')); + + $this->setPageTitle(ts('Scheduled Reminder')); } /** * global form rule diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index 7df95e15ff..f05acc485c 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -296,52 +296,27 @@ LIMIT $limit"; } function mappingList() { - $params = array('mappingID'); - foreach ($params as $param) { - $$param = CRM_Utils_Array::value($param, $_POST); + if (empty($_GET['mappingID'])) { + CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.')); } - if (!$mappingID) { - CRM_Utils_JSON::output(array('error_msg' => 'required params missing.')); - } - - $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID); - extract($selectionOptions); - - $elements = array(); - foreach ($sel4 as $id => $name) { - $elements[] = array( - 'name' => $name, - 'value' => $id, - ); - } - - CRM_Utils_JSON::output($elements); - } - - function mappingList1() { - $params = array('mappingID'); - foreach ($params as $param) { - $$param = CRM_Utils_Array::value($param, $_POST); - } - - if (!$mappingID) { - CRM_Utils_JSON::output(array('error_msg' => 'required params missing.')); - } + $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($_GET['mappingID']); - $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID); - extract($selectionOptions); - - $elements = array(); - foreach ($sel5 as $id => $name) { - $elements['sel5'][] = array( - 'name' => $name, - 'value' => $id, - ); + $output = array( + 'sel4' => array(), + 'sel5' => array(), + 'recipientMapping' => $selectionOptions['recipientMapping'], + ); + foreach (array(4, 5) as $sel) { + foreach ($selectionOptions["sel$sel"] as $id => $name) { + $output["sel$sel"][] = array( + 'value' => $name, + 'key' => $id, + ); + } } - $elements['recipientMapping'] = $recipientMapping; - CRM_Utils_JSON::output($elements); + CRM_Utils_JSON::output($output); } static function mergeTags() { @@ -366,16 +341,11 @@ LIMIT $limit"; } function recipient() { - $params = array('recipient'); - foreach ($params as $param) { - $$param = CRM_Utils_Array::value($param, $_POST); - } - - if (!$recipient) { - CRM_Utils_JSON::output(array('error_msg' => 'required params missing.')); + if (empty($_GET['recipient'])) { + CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.')); } - switch ($recipient) { + switch ($_GET['recipient']) { case 'Participant Status': $values = CRM_Event_PseudoConstant::participantStatus(); break; @@ -391,8 +361,8 @@ LIMIT $limit"; $elements = array(); foreach ($values as $id => $name) { $elements[] = array( - 'name' => $name, - 'value' => $id, + 'value' => $name, + 'key' => $id, ); } diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php index d93f58954e..4f375464d2 100644 --- a/CRM/Admin/Page/ScheduleReminders.php +++ b/CRM/Admin/Page/ScheduleReminders.php @@ -72,7 +72,6 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { 'url' => 'civicrm/admin/scheduleReminders', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Schedule Reminders'), - 'class' => 'no-popup', ), CRM_Core_Action::ENABLE => array( 'name' => ts('Enable'), diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index f0c4688834..2fc095c3fd 100755 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -92,6 +92,7 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage // Update tab "disabled" css class $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList); } + $this->setPageTitle(ts('Scheduled Reminder')); } /** @@ -192,16 +193,14 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient], FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") ); - $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'), - $sel3[$this->_mappingID][0], FALSE, array('class' => 'crm-select2 huge') + $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Roles'), + $sel3[$this->_mappingID][0], FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE) ); - $recipientListing->setMultiple(TRUE); $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => true)); - $groups = CRM_Contact_BAO_Group::getGroupsHierarchy(CRM_Core_PseudoConstant::staticGroup(), NULL, '  ', TRUE); $this->add('select', 'group_id', ts('Group'), - $groups, FALSE, array('class' => 'crm-select2 huge') + CRM_Core_PseudoConstant::nestedGroup(), FALSE, array('class' => 'crm-select2 huge') ); CRM_Mailing_BAO_Mailing::commonCompose($this); diff --git a/js/Common.js b/js/Common.js index 1a614e3e41..c7856defcc 100644 --- a/js/Common.js +++ b/js/Common.js @@ -213,16 +213,15 @@ CRM.strings = CRM.strings || {}; /** * Populate a select list, overwriting the existing options except for the placeholder. - * @param $el jquery collection - 1 or more select elements + * @param select jquery selector - 1 or more select elements * @param options array in format returned by api.getoptions * @param placeholder string */ - CRM.utils.setOptions = function($el, options, placeholder) { - $el.each(function() { + CRM.utils.setOptions = function(select, options, placeholder) { + $(select).each(function() { var $elect = $(this), val = $elect.val() || [], - multiple = $el.is('[multiple]'), opts = placeholder || placeholder === '' ? '' : '[value!=""]', newOptions = '', theme = function(options) { @@ -243,8 +242,8 @@ CRM.strings = CRM.strings || {}; $elect.find('option' + opts).remove(); theme(options); if (typeof placeholder === 'string') { - if (multiple) { - $el.attr('placeholder', placeholder); + if ($elect.is('[multiple]')) { + select.attr('placeholder', placeholder); } else { newOptions = '' + newOptions; } diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index fb8cbae96f..7dee089b7e 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -152,45 +152,66 @@ {literal} {/literal} diff --git a/templates/CRM/Admin/Page/ScheduleReminders.tpl b/templates/CRM/Admin/Page/ScheduleReminders.tpl index 234011941d..40ecbf322c 100644 --- a/templates/CRM/Admin/Page/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Page/ScheduleReminders.tpl @@ -29,26 +29,23 @@ {if $action eq 1 or $action eq 2 or $action eq 8 or $action eq 16384} {include file="CRM/Admin/Form/ScheduleReminders.tpl"} {else} -{* include wysiwyg related files*} -{include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true} -{capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture} -
- {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} -
-{if $rows} + {* include wysiwyg related files*} + {include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true} + {capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture} +
+ {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} +
+ {if $rows}
{include file="CRM/Admin/Page/Reminders.tpl"} - -
- -{else} + {else}
- {capture assign=crmURL}class="no-popup" href="{crmURL p='civicrm/admin/scheduleReminders' q="action=add&reset=1"}" class="action-item"{/capture} - {ts 1=$crmURL}There are no Scheduled Reminders configured. You can add one.{/ts} + {ts}None found.{/ts}
-{/if} + {/if} + {/if} diff --git a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl index 9b9ba34623..ada0d04c2b 100755 --- a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl @@ -149,48 +149,48 @@ {literal} {/literal} {/if}
- {include file="CRM/common/formButtons.tpl" location="bottom"}
+ {include file="CRM/common/formButtons.tpl" location="bottom"} + {/if}