FIX Use better inheritance based logic for deciding which active tab to display in edit page

This commit is contained in:
Robbie Averill 2017-07-18 13:19:04 +12:00
parent dd10aadddb
commit fb6e6162ca
4 changed files with 16 additions and 10 deletions

View File

@ -351,17 +351,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
/**
* Decide which is the active primary tab in a CMS edit screen
* Return the active tab identifier for the CMS. Used by templates to decide which tab to give the active state.
* The default value is "edit", as the primary content tab. Child controllers will override this.
*
* @return string
*/
public function getActiveTab()
public function getTabIdentifier()
{
if ($this instanceof CMSPageSettingsController) {
return 'settings';
} elseif ($this instanceof CMSPageHistoryController) {
return 'history';
}
return 'edit';
}

View File

@ -464,4 +464,9 @@ class CMSPageHistoryController extends CMSMain
{
return $this->versionID;
}
public function getTabIdentifier()
{
return 'history';
}
}

View File

@ -26,4 +26,9 @@ class CMSPageSettingsController extends CMSMain
$crumbs[0]->Title = _t('SilverStripe\\CMS\\Controllers\\CMSPagesController.MENUTITLE', 'Pages');
return $crumbs;
}
public function getTabIdentifier()
{
return 'settings';
}
}

View File

@ -10,17 +10,17 @@
<div class="cms-content-header-tabs cms-tabset">
<ul class="cms-tabset-nav-primary nav nav-tabs">
<li class="nav-item content-treeview<% if $ActiveTab == 'edit' %> ui-tabs-active<% end_if %>">
<li class="nav-item content-treeview<% if $TabIdentifier == 'edit' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageEdit" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageEdit">
<% _t('SilverStripe\CMS\Controllers\CMSMain.TabContent', 'Content') %>
</a>
</li>
<li class="nav-item content-listview<% if $ActiveTab == 'settings' %> ui-tabs-active<% end_if %>">
<li class="nav-item content-listview<% if $TabIdentifier == 'settings' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageSettings" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageSettings">
<% _t('SilverStripe\CMS\Controllers\CMSMain.TabSettings', 'Settings') %>
</a>
</li>
<li class="nav-item content-listview<% if $ActiveTab == 'history' %> ui-tabs-active<% end_if %>">
<li class="nav-item content-listview<% if $TabIdentifier == 'history' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageHistory" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageHistory">
<% _t('SilverStripe\CMS\Controllers\CMSMain.TabHistory', 'History') %>
</a>