From cac1236c40490d85df7f41cf653e06067d6300d8 Mon Sep 17 00:00:00 2001 From: Maggie Date: Thu, 1 May 2014 17:41:48 -0400 Subject: [PATCH] Removed autocomplete from send email activity --- CRM/Contact/Form/Task/EmailCommon.php | 11 ++++--- CRM/Contact/Page/AJAX.php | 9 +++--- templates/CRM/Contact/Form/Task/Email.tpl | 38 +++++++++++++++++------ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index 3bb690fa9e..78863890cd 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -133,10 +133,13 @@ class CRM_Contact_Form_Task_EmailCommon { if (count($form->_contactIds) > 1) { $form->_single = FALSE; } - - $to = $form->add('text', 'to', ts('To'), '', TRUE); - $cc = $form->add('text', 'cc_id', ts('CC')); - $bcc = $form->add('text', 'bcc_id', ts('BCC')); + + $emailAttributes = array( + 'class' => 'huge', + ); + $to = $form->add('text', 'to', ts('To'), $emailAttributes, TRUE); + $cc = $form->add('text', 'cc_id', ts('CC'), $emailAttributes); + $bcc = $form->add('text', 'bcc_id', ts('BCC'), $emailAttributes); $setDefaults = TRUE; if (property_exists($form, '_context') && $form->_context == 'standalone') { diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 102924e765..5e35702a1b 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -661,10 +661,9 @@ ORDER BY sort_name "; if ($queryString) { $offset = CRM_Utils_Array::value('offset', $_GET, 0); - $rowCount = CRM_Utils_Array::value('rowcount', $_GET, 20); + $rowCount = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10); $offset = CRM_Utils_Type::escape($offset, 'Int'); - $rowCount = CRM_Utils_Type::escape($rowCount, 'Int'); // add acl clause here list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc'); @@ -691,8 +690,8 @@ LIMIT {$offset}, {$rowCount} $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $result[] = array( - 'name' => $dao->name, 'id' => $dao->id, + 'text' => $dao->name, ); } } @@ -717,13 +716,13 @@ LIMIT {$offset}, {$rowCount} $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { + //working here $result[] = array( - 'name' => '"' . $dao->name . '" <' . $dao->email . '>', + 'text' => '"' . $dao->name . '" <' . $dao->email . '>', 'id' => (CRM_Utils_Array::value('id', $_GET)) ? "{$dao->id}::{$dao->email}" : '"' . $dao->name . '" <' . $dao->email . '>', ); } } - if ($result) { echo json_encode($result); } diff --git a/templates/CRM/Contact/Form/Task/Email.tpl b/templates/CRM/Contact/Form/Task/Email.tpl index 118f837e6c..29cf4b9225 100644 --- a/templates/CRM/Contact/Form/Task/Email.tpl +++ b/templates/CRM/Contact/Form/Task/Email.tpl @@ -93,25 +93,45 @@ var toContact = ccContact = bccContact = ''; {/if} {literal} -cj('#addcc').toggle( function() { cj(this).text('Remove CC'); +CRM.$(function($){ + cj('#addcc').toggle( function() { cj(this).text('Remove CC'); cj('tr#cc').show().find('ul').find('input').focus(); },function() { cj(this).text('Add CC');cj('#cc_id').val(''); cj('tr#cc ul li:not(:last)').remove();cj('#cc').hide(); }); -cj('#addbcc').toggle( function() { cj(this).text('Remove BCC'); + cj('#addbcc').toggle( function() { cj(this).text('Remove BCC'); cj('tr#bcc').show().find('ul').find('input').focus(); },function() { cj(this).text('Add BCC');cj('#bcc_id').val(''); cj('tr#bcc ul li:not(:last)').remove();cj('#bcc').hide(); }); -var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name or email address of an existing contact.{/ts}{literal}"; -var sourceDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1' h=0 }{literal}"; -var toDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1' h=0 }{literal}"; + var sourceDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1' h=0 }{literal}"; + + function emailSelect(el){ + $(el).data('api-entity', 'contact').crmSelect2({ + minimumInputLength: 1, + multiple: true, + ajax: { + url: sourceDataUrl, + data: function(term) { + return { + name: term, + }; + }, + results: function(response) { + return { + results: response, + }; + } + } + }); + } + emailSelect('#to'); + emailSelect('#cc_id'); + emailSelect('#bcc_id'); +}); + -cj( "#to" ).tokenInput( toDataUrl, { prePopulate: toContact, theme: 'facebook', hintText: hintText }); -cj( "#cc_id" ).tokenInput( sourceDataUrl, { prePopulate: ccContact, theme: 'facebook', hintText: hintText }); -cj( "#bcc_id" ).tokenInput( sourceDataUrl, { prePopulate: bccContact, theme: 'facebook', hintText: hintText }); -cj( 'ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px' ); {/literal} {include file="CRM/common/formNavigate.tpl"} -- 2.25.1