X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=templates%2FCRM%2FContribute%2FForm%2FSoftCredit.tpl;h=f45897e4a49c4f9993b860bb55c4cc2e82cc65d2;hb=6bb107cefedbecc371bdc100b87992753e8e686c;hp=91eb2b773058398a9ff26d4097c08cf5ea154283;hpb=73be989745ea968ffa538d5679bce4303bbf5306;p=civicrm-core.git diff --git a/templates/CRM/Contribute/Form/SoftCredit.tpl b/templates/CRM/Contribute/Form/SoftCredit.tpl index 91eb2b7730..f45897e4a4 100644 --- a/templates/CRM/Contribute/Form/SoftCredit.tpl +++ b/templates/CRM/Contribute/Form/SoftCredit.tpl @@ -34,7 +34,6 @@
{$form.soft_credit_type_id.html} - ({ts}clear{/ts})
{ts}Select an option to reveal honoree information fields.{/ts}
@@ -46,28 +45,21 @@ {assign var='rowNumber' value=$smarty.section.i.index} - {ts}Select Contact{/ts} - {assign var='createNewStatus' value=true} - {if !$showCreateNew and $rowNumber lt $showSoftCreditRow} - {assign var='createNewStatus' value=false} - {/if} - {include file="CRM/Contact/Form/NewContact.tpl" noLabel=true skipBreak=true blockNo=$rowNumber - prefix="soft_credit_" showNewSelect=$createNewStatus focus=false} + {$form.soft_credit_contact_id.$rowNumber.label} {$form.soft_credit_contact_id.$rowNumber.html|crmAddClass:twenty} {$form.soft_credit_amount.$rowNumber.label} {$form.soft_credit_amount.$rowNumber.html|crmAddClass:eight} - {$form.soft_credit_type.$rowNumber.label} {$form.soft_credit_type.$rowNumber.html|crmAddClass:eight} -  {ts}delete{/ts} + {$form.soft_credit_type.$rowNumber.label} {$form.soft_credit_type.$rowNumber.html} +   {/section} - - {ts}add another soft credit{/ts} + {ts}another soft credit{/ts} @@ -87,35 +79,31 @@ } $('#addMoreSoftCredit').on('click', function () { - $('.crm-contribution-form-block-soft_credit_to tr.hiddenElement').filter(':first').show().removeClass('hiddenElement'); + if ($('tr.crm-contribution-form-block-soft_credit_to').hasClass("hiddenElement")) { + $('.crm-contribution-form-block-soft_credit_to tr.hiddenElement').filter(':first').show().removeClass('hiddenElement'); + } if ($('.crm-soft-credit-block tr.hiddenElement').length < 1) { $('#addMoreSoftCredit').hide(); } return false; }); - var pcpURL = CRM.url('civicrm/ajax/rest', - 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1'); - $('#pcp_made_through').autocomplete(pcpURL, - { width : 360, selectFirst : false, matchContains: true - }).result( function(event, data, formatted) { - $("#pcp_made_through_id" ).val( data[1]); - }); - - var rowCnt = 1; - $('input[name^="soft_credit_contact_select_id["]').each(function(){ - if ($(this).val()){ - var dataUrl = CRM.url('civicrm/ajax/rest', - 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&id=' + $(this).val()); - $.ajax({ - url : dataUrl, - async : false, - success : function(html){ - htmlText = html.split( '|' , 2); - $('#soft_credit_contact_' + rowCnt).val(htmlText[0]); - rowCnt++; - } - }); + // 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) { + return {term: term}; + }, + results: function(response) { + return {results: response}; + } + }, + initSelection: function(el, callback) { + callback({id: $(el).val(), text: $('#pcp_made_through').val()}); } }); @@ -125,10 +113,9 @@ } }); - $('.delete-link').click(function(){ - var row = $(this).attr('row-no'); - $('#soft-credit-row-' + row).hide().find('input').val(''); - $('input[name="soft_credit_contact_select_id['+row+']"]').val(''); + $('.soft-credit-delete-link').click(function(){ + $(this).closest('tr').addClass('hiddenElement').removeAttr('style'); + $('#addMoreSoftCredit').show(); return false; });