From: Coleman Watts Date: Sat, 13 Jun 2015 17:48:23 +0000 (-0400) Subject: CRM-16645 - More consistently use PCP autocomplete field X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d4abe8029e80136cead19d425dec2b6e3330f657;p=civicrm-core.git CRM-16645 - More consistently use PCP autocomplete field --- diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 9bee323ed9..ca5c26abe2 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -877,16 +877,10 @@ class CRM_Contribute_BAO_Query { array('entity' => 'contribution', 'label' => ts('Payment Method'), 'option_url' => NULL, 'placeholder' => ts('- any -')) ); - $form->add('select', 'contribution_pcp_made_through_id', - ts('Personal Campaign Page'), - array( - '' => ts('- any -'), - ) + - CRM_Contribute_PseudoConstant::pcPage(), - FALSE, array('class' => 'crm-select2') - ); - - $status = array(); + // Fixme: Not a true entityRef field. Relies on PCP.js.tpl + $form->add('text', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('class' => 'twenty', 'id' => 'pcp_made_through_id', 'placeholder' => ts('- any -'))); + // stores the label + $form->add('hidden', 'pcp_made_through'); $statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status'); // Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue). diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index eee9ffce6e..fc482dd4e3 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -145,8 +145,10 @@ class CRM_Contribute_Form_SoftCredit { $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage(); if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) { $form->assign('siteHasPCPs', 1); - $form->add('hidden', 'pcp_made_through'); // stores the label - $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty')); + // Fixme: Not a true entityRef field. Relies on PCP.js.tpl + $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -'))); + // stores the label + $form->add('hidden', 'pcp_made_through'); $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL); $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)')); $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)')); diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 9a4e34a5bb..09231b0530 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -262,7 +262,7 @@ {$form.pcp_made_through_id.label} {$form.pcp_made_through_id.html}   - {ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts} +
{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}
@@ -274,15 +274,15 @@ {$form.pcp_roll_nickname.label} {$form.pcp_roll_nickname.html|crmAddClass:big}
- {ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts} +
{ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}
{$form.pcp_personal_note.label} {$form.pcp_personal_note.html} - {ts}Personal message submitted by contributor for display in the Honor Roll.{/ts} +
{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}
@@ -292,6 +292,7 @@
+ {include file="CRM/Contribute/Form/PCP.js.tpl"} {/if} diff --git a/templates/CRM/Contribute/Form/PCP.js.tpl b/templates/CRM/Contribute/Form/PCP.js.tpl new file mode 100644 index 0000000000..846cc19f81 --- /dev/null +++ b/templates/CRM/Contribute/Form/PCP.js.tpl @@ -0,0 +1,54 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2015 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{literal} + +{/literal} diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index 9e55106e75..59702b860b 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -128,7 +128,8 @@ {$form.contribution_pcp_made_through_id.label}
- {$form.contribution_pcp_made_through_id.html|crmAddClass:twenty} + {$form.contribution_pcp_made_through_id.html} + {include file="CRM/Contribute/Form/PCP.js.tpl"} {$form.contribution_pcp_display_in_roll.label} diff --git a/templates/CRM/Contribute/Form/SoftCredit.tpl b/templates/CRM/Contribute/Form/SoftCredit.tpl index 9d30c5d0a5..a1780524e8 100644 --- a/templates/CRM/Contribute/Form/SoftCredit.tpl +++ b/templates/CRM/Contribute/Form/SoftCredit.tpl @@ -89,29 +89,6 @@ return false; }); - // FIXME: This could be much simpler as an entityRef field but pcp doesn't have a searchable api :( - var pcpURL = CRM.url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1'); - $('#pcp_made_through_id').crmSelect2({ - placeholder: {/literal}'{ts escape="js"}- select -{/ts}'{literal}, - minimumInputLength: 1, - ajax: { - url: pcpURL, - data: function(term, page) { - return {term: term, page: page}; - }, - results: function(response) { - return response; - } - }, - initSelection: function(el, callback) { - callback({id: $(el).val(), text: $('[name=pcp_made_through]', $form).val()}); - } - }) - // This is just a cheap trick to store the name in case of a formrule error - .on('change', function() { - $('[name=pcp_made_through]', $form).val($(this).select2('data').text || ''); - }); - $('.crm-soft-credit-block tr span').each(function () { if ($(this).hasClass('crm-error')) { $(this).parents('tr').show();