Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Use shared TabHeader.tpl for contact summary tabs as well #31697

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CRM/Contact/Page/View/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,18 @@ public function getTabs(array $contact) {
// ensure all keys used in the template are set, to avoid notices
$allTabs = \CRM_Core_Smarty::setRequiredTabTemplateKeys($allTabs);

// ensure the array keys match the value in the "id" of each item
$tabs = [];

foreach ($allTabs as $key => $tab) {
$finalKey = $tab['id'] ?? $key;
$tabs[$finalKey] = $tab;
}

// now sort the tabs based on weight
usort($allTabs, ['CRM_Utils_Sort', 'cmpFunc']);
return $allTabs;
usort($tabs, ['CRM_Utils_Sort', 'cmpFunc']);

return $tabs;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions CRM/Core/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,17 @@ public static function setRequiredTabTemplateKeys(array $tabs): array {
'count' => NULL,
'hideCount' => FALSE,
'template' => NULL,
'active' => TRUE,
'valid' => TRUE,
// Afform tabs set the afform module and directive - NULL for non-afform tabs
'module' => NULL,
'directive' => NULL,
];

foreach ($tabs as $i => $tab) {
if (empty($tab['url'])) {
$tab['url'] = $tab['link'] ?? '';
}
$tabs[$i] = array_merge($defaults, (array) $tab);
}
return $tabs;
Expand Down
14 changes: 7 additions & 7 deletions CRM/Event/Form/ManageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,21 @@ private function processTab() {
];

$tabs = [];
$tabs['settings'] = ['title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage'] + $default;
$tabs['location'] = ['title' => ts('Event Location')] + $default;
$tabs['settings'] = ['title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage', 'icon' => 'crm-i fa-circle-info'] + $default;
$tabs['location'] = ['title' => ts('Event Location'), 'icon' => 'crm-i fa-map-marker'] + $default;
// If CiviContribute is active, create the Fees tab.
if (CRM_Core_Component::isEnabled('CiviContribute')) {
$tabs['fee'] = ['title' => ts('Fees')] + $default;
$tabs['fee'] = ['title' => ts('Fees'), 'icon' => 'crm-i fa-money'] + $default;
}
$tabs['registration'] = ['title' => ts('Online Registration')] + $default;
$tabs['registration'] = ['title' => ts('Online Registration'), 'icon' => 'crm-i fa-check'] + $default;
// @fixme I don't understand the event permissions check here - can we just get rid of it?
$permissions = CRM_Event_BAO_Event::getAllPermissions();
if (CRM_Core_Permission::check('administer CiviCRM data') || !empty($permissions[CRM_Core_Permission::EDIT])) {
$tabs['reminder'] = ['title' => ts('Schedule Reminders'), 'class' => 'livePage'] + $default;
$tabs['reminder'] = ['title' => ts('Schedule Reminders'), 'class' => 'livePage', 'icon' => 'crm-i fa-envelope'] + $default;
}

$tabs['pcp'] = ['title' => ts('Personal Campaigns')] + $default;
$tabs['repeat'] = ['title' => ts('Repeat')] + $default;
$tabs['pcp'] = ['title' => ts('Personal Campaigns'), 'icon' => 'crm-i fa-user'] + $default;
$tabs['repeat'] = ['title' => ts('Repeat'), 'icon' => 'crm-i fa-repeat'] + $default;

// Repeat tab must refresh page when switching repeat mode so js & vars will get set-up
if (!$this->_isRepeatingEvent) {
Expand Down
29 changes: 1 addition & 28 deletions templates/CRM/Contact/Page/View/Summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,8 @@
</div><!-- .crm-actions-ribbon -->
{/if}

<div class="crm-block crm-content-block crm-contact-page crm-inline-edit-container">
<div id="mainTabContainer">
<ul class="crm-contact-tabs-list">
{foreach from=$allTabs item=tabValue}
<li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-all{if is_numeric($tabValue.count)} crm-count-{$tabValue.count}{/if}{if $tabValue.class} {$tabValue.class}{/if}">
<a href="{if $tabValue.template}#contact-{$tabValue.id}{else}{$tabValue.url|smarty:nodefaults}{/if}" title="{$tabValue.title|escape}">
<i class="{if !empty($tabValue.icon)}{$tabValue.icon}{else}crm-i fa-puzzle-piece{/if}" aria-hidden="true"></i>
<span>{$tabValue.title}</span>
{if empty($tabValue.hideCount)}<em>{if is_numeric($tabValue.count)}{$tabValue.count}{/if}</em>{/if}
</a>
</li>
{/foreach}
</ul>
{include file='CRM/common/TabHeader.tpl' tabHeader=$allTabs containerClasses="crm-contact-page crm-inline-edit-container" listClasses="crm-contact-tabs-list" tabIdPrefix="contact-"}

{foreach from=$allTabs item=tabValue}
{if $tabValue.template}
<div id="contact-{$tabValue.id}">
{if $tabValue.module}
<!-- afform tab - need to pass module and directive to afform param -->
{include file=$tabValue.template afform=$tabValue}
{else}
{include file=$tabValue.template}
{/if}
</div>
{/if}
{/foreach}
</div>
<div class="clear"></div>
</div>
{/if}

{* CRM-10560 *}
Expand Down
35 changes: 18 additions & 17 deletions templates/CRM/common/TabHeader.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@
+--------------------------------------------------------------------+
*}
{* enclose all tabs and its content in a block *}
<div class="crm-block crm-content-block">
<div class="crm-block crm-content-block {$containerClasses|default:''}">
{if $tabHeader}
<div id="mainTabContainer">
<ul>
{foreach from=$tabHeader key=tabName item=tabValue}
<li id="tab_{$tabName}" class="crm-tab-button ui-corner-all{if !$tabValue.valid} disabled{/if} {$tabValue.class}" {$tabValue.extra}>
{if $tabValue.active}
<a href="{if $tabValue.template}#panel_{$tabName}{else}{$tabValue.link|smarty:nodefaults}{/if}" title="{$tabValue.title|escape}{if !$tabValue.valid} ({ts}disabled{/ts}){/if}">
{if $tabValue.icon}<i class="{$tabValue.icon}"></i>{/if}
<span>{$tabValue.title}</span>
{if is_numeric($tabValue.count)}<em>{$tabValue.count}</em>{/if}
</a>
{else}
<span {if !$tabValue.valid} title="{ts}disabled{/ts}"{/if}>{$tabValue.title}</span>
{/if}
<ul class="{$listClasses|default:''}">
{foreach from=$tabHeader key=tabName item=tabValue}
<li id="tab_{$tabName}" class="crm-tab-button ui-corner-all {if !$tabValue.valid}disabled{/if} {if is_numeric($tabValue.count)}crm-count-{$tabValue.count}{/if} {if $tabValue.class} {$tabValue.class}{/if}" {$tabValue.extra}>
{if $tabValue.active}
<a href="{if $tabValue.template}#{$tabIdPrefix|default:'panel_'}{$tabName}{else}{$tabValue.url|smarty:nodefaults}{/if}" title="{$tabValue.title|escape} {if !$tabValue.valid}({ts}disabled{/ts}){/if}">
<i class="{$tabValue.icon|default:'crm-i fa-puzzle-piece'}" aria-hidden="true"></i>
<span>{$tabValue.title}</span>
{if empty($tabValue.hideCount) && is_numeric($tabValue.count)}<em>{$tabValue.count}</em>{/if}
</a>
{else}
<span {if !$tabValue.valid} title="{ts}disabled{/ts}"{/if}>{$tabValue.title}</span>
{/if}
</li>
{/foreach}
</ul>
{/foreach}
</ul>

{foreach from=$tabHeader key=tabName item=tabValue}
{if $tabValue.template}
<div id="panel_{$tabName}">
<div id="{$tabIdPrefix|default:'panel_'}{$tabName}">
{if $tabValue.module}
<!-- afform tab - need to pass module and directive to afform param -->
{include file=$tabValue.template afform=$tabValue}
Expand All @@ -41,4 +42,4 @@
</div>
{/if}
<div class="clear"></div>
</div> {* crm-content-block ends here *}
</div>