Skip to content
Browse files

NEW "Show children as list" tree context action

Allows for easier navigation between tree and list,
particularly if a node has many children nodes
(since it doesn't require expanding that node).

Uses a new 'ss-tabs-force-active' class on the tabset
to enforce the correct view state. This also fixes an issue
where you couldn't link to a list view directly via URL.
  • Loading branch information...
1 parent 2dd0e3f commit 1e1049b5c82dd4d0e00aa1fd5f4a09e5f3ed7c20 @chillu chillu committed Mar 14, 2013
View
17 javascript/CMSMain.Tree.js
@@ -12,12 +12,27 @@
'edit': {
'label': ss.i18n._t('Tree.EditPage'),
'action': function(obj) {
- $('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
+ $('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
self.data('urlEditpage'), obj.data('id')
));
}
}
};
+
+ // Add "show as list"
+ if(!node.hasClass('nochildren')) {
+ menuitems['showaslist'] = {
+ 'label': ss.i18n._t('Tree.ShowAsList'),
+ 'action': function(obj) {
+ $('.cms-container').entwine('.ss').loadPanel(
+ self.data('urlListview') + '&ParentID=' + obj.data('id'),
+ null,
+ // Default to list view tab
+ {tabState: {'pages-controller-cms-content': {'tabSelector': '.content-listview'}}}
+ );
+ }
+ };
+ }
// Build a list for allowed children as submenu entries
var pagetype = node.data('pagetype'),
View
1 javascript/lang/en_US.js
@@ -33,6 +33,7 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') {
'Tree.EditPage': 'Edit',
'Tree.ThisPageOnly': 'This page only',
'Tree.ThisPageAndSubpages': 'This page and subpages',
+ 'Tree.ShowAsList': 'Show children as list',
'CMSMain.ConfirmRestoreFromLive': "Do you really want to copy the published content to the draft site?",
'CMSMain.RollbackToVersion': "Do you really want to roll back to version #%s of this page?",
'URLSEGMENT.Edit': 'Edit',
View
2 templates/Includes/CMSMain_TreeView.ss
@@ -19,7 +19,7 @@ $ExtraTreeTools
</div>
<% end_if %>
- <div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s&amp;SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}?SecurityID=$SecurityID" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}?SecurityID=$SecurityID" data-hints="$SiteTreeHints.XML">
+ <div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s&amp;SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}?SecurityID=$SecurityID" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}?SecurityID=$SecurityID" data-url-listview="{$Link('?view=list')}" data-hints="$SiteTreeHints.XML">
$SiteTreeAsUL
</div>
</div>
View
4 templates/Includes/CMSPagesController_Content.ss
@@ -7,10 +7,10 @@
<div class="cms-content-header-tabs">
<ul class="cms-tabset-nav-primary">
- <li class="content-treeview<% if ViewState == tree %> ui-tabs-active<% end_if %> cms-tabset-icon tree">
+ <li class="content-treeview<% if ViewState == tree %> ui-tabs-active ss-tabs-force-active<% end_if %> cms-tabset-icon tree">
<a href="#cms-content-treeview" class="cms-panel-link" data-href="$LinkTreeView"><% _t('CMSPagesController.TreeView', 'Tree View') %></a>
</li>
- <li class="content-listview<% if ViewState == list %> ui-tabs-active<% end_if %> cms-tabset-icon list">
+ <li class="content-listview<% if ViewState == list %> ui-tabs-active ss-tabs-force-active<% end_if %> cms-tabset-icon list">
<a href="#cms-content-listview" class="cms-panel-link" data-href="$LinkListView"><% _t('CMSPagesController.ListView', 'List View') %></a>
</li>
<!--

0 comments on commit 1e1049b

Please sign in to comment.
Something went wrong with that request. Please try again.