From d8249fcb5f6e1668b6f1246ae5c2052f9b09d892 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 7 Jan 2014 18:06:50 -0800 Subject: [PATCH] CRM-12872 - Ajax-enable pager links --- CRM/Contribute/Page/Tab.php | 2 +- CRM/Utils/Pager.php | 8 +-- CRM/Utils/System.php | 10 +++- templates/CRM/Contact/Form/Search/Custom.tpl | 1 + templates/CRM/Contact/Form/Selector.tpl | 1 + templates/CRM/Contact/Page/View/Log.tpl | 11 ---- templates/CRM/Report/Form/Contact/Detail.tpl | 4 +- templates/CRM/Report/Form/Event/Income.tpl | 4 +- templates/CRM/Report/Form/Layout/Overlay.tpl | 4 +- templates/CRM/Report/Form/Layout/Table.tpl | 4 +- templates/CRM/common/pager.tpl | 56 +++++++++++++++----- 11 files changed, 67 insertions(+), 38 deletions(-) diff --git a/CRM/Contribute/Page/Tab.php b/CRM/Contribute/Page/Tab.php index ca154e71f0..7edef06acc 100644 --- a/CRM/Contribute/Page/Tab.php +++ b/CRM/Contribute/Page/Tab.php @@ -166,7 +166,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('crid', $this->_crid); - $controller->set('context', 'contribution'); + $controller->set('context', 'Search'); $controller->process(); $controller->run(); diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index db8f3f4148..08a6674c4d 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -294,7 +294,7 @@ class CRM_Utils_Pager extends Pager_Sliding { } $href = $this->makeURL(self::PAGE_ID, 1); - return sprintf('%s', + return sprintf('%s', $href, str_replace('%d', 1, $this->_altFirst), $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost @@ -307,7 +307,7 @@ class CRM_Utils_Pager extends Pager_Sliding { } $href = $this->makeURL(self::PAGE_ID, $this->_totalPages); - return sprintf('%s', + return sprintf('%s', $href, str_replace('%d', $this->_totalPages, $this->_altLast), $this->_lastPagePre . $this->_lastPageText . $this->_lastPagePost @@ -317,7 +317,7 @@ class CRM_Utils_Pager extends Pager_Sliding { function getBackPageLink() { if ($this->_currentPage > 1) { $href = $this->makeURL(self::PAGE_ID, $this->getPreviousPageID()); - return sprintf('%s', + return sprintf('%s', $href, $this->_altPrev, $this->_prevImg ) . $this->_spacesBefore . $this->_spacesAfter; @@ -328,7 +328,7 @@ class CRM_Utils_Pager extends Pager_Sliding { function getNextPageLink() { if ($this->_currentPage < $this->_totalPages) { $href = $this->makeURL(self::PAGE_ID, $this->getNextPageID()); - return $this->_spacesAfter . sprintf('%s', + return $this->_spacesAfter . sprintf('%s', $href, $this->_altNext, $this->_nextImg ) . $this->_spacesBefore . $this->_spacesAfter; diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 06ff598a79..71bca4f36f 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -126,8 +126,14 @@ class CRM_Utils_System { $qs['force'] = 1; } - unset($qs['snippet']); - unset($qs['section']); + // Ok this is a big assumption but usually works + // If we are in snippet mode, retain the 'section' param, if not, get rid of it. + if (!empty($qs['snippet'])) { + unset($qs['snippet']); + } + else { + unset($qs['section']); + } if ($skipUFVar) { $config = CRM_Core_Config::singleton(); diff --git a/templates/CRM/Contact/Form/Search/Custom.tpl b/templates/CRM/Contact/Form/Search/Custom.tpl index 1db46eee55..3b1ab45a3c 100644 --- a/templates/CRM/Contact/Form/Search/Custom.tpl +++ b/templates/CRM/Contact/Form/Search/Custom.tpl @@ -178,6 +178,7 @@ function toggleContactSelection( name, qfKey, selection ){ var formName = "{/literal}{$form.formName}{literal}"; on_load_init_checkboxes(formName); } + return false; } diff --git a/templates/CRM/Contact/Form/Selector.tpl b/templates/CRM/Contact/Form/Selector.tpl index 21a2d27d88..c218769f9c 100644 --- a/templates/CRM/Contact/Form/Selector.tpl +++ b/templates/CRM/Contact/Form/Selector.tpl @@ -202,6 +202,7 @@ function toggleContactSelection(name, qfKey, selection) { params.name = name; } cj.getJSON(url, params, countSelections); + return false; } {/literal} diff --git a/templates/CRM/Contact/Page/View/Log.tpl b/templates/CRM/Contact/Page/View/Log.tpl index 7949821751..b940ff3951 100644 --- a/templates/CRM/Contact/Page/View/Log.tpl +++ b/templates/CRM/Contact/Page/View/Log.tpl @@ -66,17 +66,6 @@ $('#changeLog .instance_data').crmSnippet('refresh'); }; CRM.reloadChangeLogTab({/literal}"{$instanceUrl}"{literal}); - - $('#changeLog').on('click', '.report-pager .crm-pager-nav a', function(e) { - CRM.reloadChangeLogTab(this.href + '§ion=2'); - return false; - }); - - $('#changeLog').on('click', 'input[name="PagerBottomButton"], input[name="PagerTopButton"]', function(e) { - var url = $('#changeLog .instance_data .report-pager .crm-pager-nav a:first').attr('href') + '§ion=2'; - CRM.reloadChangeLogTab(url + '&crmPID=' + $(this).siblings('input[type=text]').val()); - return false; - }); }); diff --git a/templates/CRM/Report/Form/Contact/Detail.tpl b/templates/CRM/Report/Form/Contact/Detail.tpl index 40cf07a220..79fbe38af3 100644 --- a/templates/CRM/Report/Form/Contact/Detail.tpl +++ b/templates/CRM/Report/Form/Contact/Detail.tpl @@ -37,7 +37,7 @@ {/if} {if $rows}
- {include file="CRM/common/pager.tpl" location="top" noForm=0} + {include file="CRM/common/pager.tpl" location="top"}
{* pre-compile section header here, rather than doing it every time under foreach *} @@ -173,7 +173,7 @@ {/foreach}
- {include file="CRM/common/pager.tpl" noForm=0} + {include file="CRM/common/pager.tpl"}

{if $grandStat} diff --git a/templates/CRM/Report/Form/Event/Income.tpl b/templates/CRM/Report/Form/Event/Income.tpl index d1785502cb..537e46d797 100644 --- a/templates/CRM/Report/Form/Event/Income.tpl +++ b/templates/CRM/Report/Form/Event/Income.tpl @@ -39,7 +39,7 @@ {if $events}
- {include file="CRM/common/pager.tpl" location="top" noForm=0} + {include file="CRM/common/pager.tpl" location="top"}
{foreach from=$events item=eventID} @@ -82,7 +82,7 @@ {/foreach}
- {include file="CRM/common/pager.tpl" noForm=0} + {include file="CRM/common/pager.tpl"}
{if !$section } {*Statistics at the bottom of the page*} diff --git a/templates/CRM/Report/Form/Layout/Overlay.tpl b/templates/CRM/Report/Form/Layout/Overlay.tpl index 3a6353bfeb..3ab123dcb6 100644 --- a/templates/CRM/Report/Form/Layout/Overlay.tpl +++ b/templates/CRM/Report/Form/Layout/Overlay.tpl @@ -26,7 +26,7 @@ {if (!$chartEnabled || !$chartSupported )&& $rows} {if $pager and $pager->_response and $pager->_response.numPages > 1}
- {include file="CRM/common/pager.tpl" location="top" noForm=0} + {include file="CRM/common/pager.tpl" location="top"}
{/if}
@@ -147,7 +147,7 @@
{if $pager and $pager->_response and $pager->_response.numPages > 1}
- {include file="CRM/common/pager.tpl" noForm=0} + {include file="CRM/common/pager.tpl" }
{/if} {/if} diff --git a/templates/CRM/Report/Form/Layout/Table.tpl b/templates/CRM/Report/Form/Layout/Table.tpl index b2c59e4cfa..fb8faeee13 100644 --- a/templates/CRM/Report/Form/Layout/Table.tpl +++ b/templates/CRM/Report/Form/Layout/Table.tpl @@ -26,7 +26,7 @@ {if (!$chartEnabled || !$chartSupported )&& $rows} {if $pager and $pager->_response and $pager->_response.numPages > 1}
- {include file="CRM/common/pager.tpl" location="top" noForm=0} + {include file="CRM/common/pager.tpl" location="top"}
{/if}
@@ -152,7 +152,7 @@
{if $pager and $pager->_response and $pager->_response.numPages > 1}
- {include file="CRM/common/pager.tpl" noForm=0} + {include file="CRM/common/pager.tpl" }
{/if} {/if} diff --git a/templates/CRM/common/pager.tpl b/templates/CRM/common/pager.tpl index 1ced52c0cd..5464a00de1 100644 --- a/templates/CRM/common/pager.tpl +++ b/templates/CRM/common/pager.tpl @@ -26,15 +26,14 @@ {if $pager and $pager->_response} {if $pager->_response.numPages > 1}
- {if empty($noForm)} {if $location eq 'top'} - {$pager->_response.titleTop}  + {$pager->_response.titleTop} {else} - {$pager->_response.titleBottom}  + {$pager->_response.titleBottom} {/if} - {/if} + {$pager->_response.first}  {$pager->_response.back}  @@ -44,14 +43,6 @@
- {if empty($noForm) and $location neq 'top'} - - {/if} {/if} {* Controller for 'Rows Per Page' *} @@ -65,4 +56,45 @@
{/if} + {if $location neq 'top'} + + {/if} + {/if} -- 2.25.1