Skip to content

Commit

Permalink
Extract selectedChild tabheader functionality and enable for Manage E…
Browse files Browse the repository at this point in the history
…vents
  • Loading branch information
mattwire committed Sep 5, 2018
1 parent 0ab5c4c commit 8d536fa
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 51 deletions.
2 changes: 1 addition & 1 deletion CRM/Admin/Page/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function run($args = NULL, $pageArgs = NULL, $sort = NULL) {

CRM_Core_BAO_MessageTemplate::revert($id);
}
$selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'String', $this);
$selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this);
if (in_array($selectedChild, array('user', 'workflow'))) {
$this->assign('selectedChild', $selectedChild);
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Page/View/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function view() {
->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
->addSetting(array(
'summaryPrint' => array('mode' => $this->_print),
'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')),
'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, 'summary')),
));
$this->assign('summaryPrint', $this->_print);
$session = CRM_Core_Session::singleton();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/ManageEvent/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function postProcess() {
unset($params['id']);

$url = 'civicrm/event/manage/repeat';
$urlParams = "action=update&reset=1&id={$this->_id}";
$urlParams = "action=update&reset=1&id={$this->_id}&selectedChild=repeat";

$linkedEntities = array(
array(
Expand Down
4 changes: 3 additions & 1 deletion CRM/Event/Form/ManageEvent/TabHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CRM_Event_Form_ManageEvent_TabHeader {
* @return array
*/
public static function build(&$form) {
$form->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $form));

$tabs = $form->get('tabHeader');
if (!$tabs || empty($_GET['reset'])) {
$tabs = self::process($form);
Expand Down Expand Up @@ -235,7 +237,7 @@ public static function getCurrentTab($tabs) {

if (is_array($tabs)) {
foreach ($tabs as $subPage => $pageVal) {
if ($pageVal['current'] === TRUE) {
if (CRM_Utils_Array::value('current', $pageVal) === TRUE) {
$current = $subPage;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/UF/Page/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function run() {

// assign vars to templates
$this->assign('action', $action);
$this->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'String', $this));
$this->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this));
$id = CRM_Utils_Request::retrieve('id', 'Positive',
$this, FALSE, 0
);
Expand Down
15 changes: 1 addition & 14 deletions templates/CRM/Admin/Page/Extensions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,7 @@
</script>
{/literal}

{* Tab management *}
<script type="text/javascript">
var selectedTab = 'summary';
{if $selectedChild}selectedTab = "{$selectedChild}";{/if}
{literal}
CRM.$(function($) {
var tabIndex = $('#tab_' + selectedTab).prevAll().length;
$("#mainTabContainer").tabs({active: tabIndex});
$(".crm-tab-button").addClass("ui-corner-bottom");
});
{/literal}
</script>
{include file="CRM/common/TabSelected.tpl" defaultTab="summary"}

{* Refresh buttons *}
{literal}
Expand Down
11 changes: 1 addition & 10 deletions templates/CRM/Admin/Page/MessageTemplates.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,7 @@
{/foreach}
</div>
</div>
<script type='text/javascript'>
var selectedTab = 'user';
{if $selectedChild}selectedTab = '{$selectedChild}';{/if}
{literal}
CRM.$(function($) {
var tabIndex = $('#tab_' + selectedTab).prevAll().length
$("#mainTabContainer").tabs( {active: tabIndex} );
});
{/literal}
</script>
{include file="CRM/common/TabSelected.tpl" defaultTab="user"}

{elseif $action ne 1 and $action ne 2 and $action ne 4 and $action ne 8}
<div class="messages status no-popup">
Expand Down
12 changes: 1 addition & 11 deletions templates/CRM/Contribute/Page/Tab.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,8 @@
<div class="contact-summary-contribute-tab view-content">

<div id="secondaryTabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
{* Tab management *}
<script type="text/javascript">
var selectedTab = 'contributions';
{include file="CRM/common/TabSelected.tpl" defaultTab="contributions" tabContainer="#secondaryTabContainer"}

{literal}
CRM.$(function($) {
var tabIndex = $('#tab_' + selectedTab).prevAll().length;
$("#secondaryTabContainer").tabs({active: tabIndex});
$(".crm-tab-button").addClass("ui-corner-bottom");
});
{/literal}
</script>
<ul class="ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header">
<li id="tab_contributions" class="crm-tab-button ui-corner-all ui-tabs-tab ui-corner-top ui-state-default ui-tab ui-tabs-active ui-state-active">
<a href="#contributions-subtab" title="{ts}Contributions{/ts}">
Expand Down
1 change: 1 addition & 0 deletions templates/CRM/Event/Form/ManageEvent/Tab.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ CRM.$(function($) {
</script>
{/literal}
{include file="CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl" entityID=$id entityTable="civicrm_event"}
{include file="CRM/common/TabSelected.tpl" defaultTab="settings"}
13 changes: 2 additions & 11 deletions templates/CRM/UF/Page/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,8 @@
</div>
</div>{* reserved profile*}

</div> {* maincontainer*}
<script type='text/javascript'>
var selectedTab = 'user-profiles';
{if $selectedChild}selectedTab = '{$selectedChild}';{/if}
{literal}
CRM.$(function($) {
var tabIndex = $('#tab_' + selectedTab).prevAll().length
$("#mainTabContainer").tabs( {active: tabIndex} );
});
{/literal}
</script>
</div>
{include file="CRM/common/TabSelected.tpl" defaultTab="user-profiles"}

{else}
{if $action ne 1} {* When we are adding an item, we should not display this message *}
Expand Down
12 changes: 12 additions & 0 deletions templates/CRM/common/TabSelected.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script type='text/javascript'>
var selectedTab = '{$defaultTab}';
var tabContainer = '#mainTabContainer';
{if $tabContainer}tabContainer = '{$tabContainer}';{/if}
{if $selectedChild}selectedTab = '{$selectedChild}';{/if}
{literal}
CRM.$(function($) {
var tabIndex = $('#tab_' + selectedTab).prevAll().length
$(tabContainer).tabs( {active: tabIndex} );
});
{/literal}
</script>

0 comments on commit 8d536fa

Please sign in to comment.