Skip to content

Commit

Permalink
Merge pull request #1950 from open-sausages/pulls/4.0/fix-cms-tree-re…
Browse files Browse the repository at this point in the history
…loading

BUG Prevent treeview loading repeatedly on each page edit form
  • Loading branch information
flamerohr committed Sep 5, 2017
2 parents 24a8cfb + 4b26ed6 commit eed7359
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions code/Controllers/CMSMain.php
Expand Up @@ -138,7 +138,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr

private static $url_handlers = [
'EditForm/$ID' => 'EditForm',
'treeview/$ID' => 'treeview',
'listview/$ParentID' => 'listview',
];

Expand Down Expand Up @@ -330,13 +329,7 @@ public function LinkListViewChildren($parentID)
*/
public function LinkTreeViewDeferred()
{
$link = $this->Link('treeview');
// Ensure selected page is encoded into URL
$selectedID = $this->currentPageID();
if ($selectedID) {
$link = Controller::join_links($link, $selectedID);
}
return $this->LinkWithSearch($link);
return $this->Link('treeview');
}

public function LinkPageEdit($id = null)
Expand Down Expand Up @@ -547,11 +540,6 @@ public function getTreeNodeClasses(SiteTree $node)
// Get classes from object
$classes = $node->CMSTreeClasses();

// Flag as current
if ($this->isCurrentPage($node)) {
$classes .= ' current';
}

// Get status flag classes
$flags = $node->getStatusFlags();
if ($flags) {
Expand Down Expand Up @@ -1345,14 +1333,10 @@ protected function getArchiveWarningMessage($record)
* This method exclusively handles deferred ajax requests to render the
* pages tree deferred handler (no pjax-fragment)
*
* @param HTTPRequest $request
* @return string HTML
*/
public function treeview($request)
public function treeview()
{
// Ensure selected page ID is highlighted
$pageID = $request->param('ID') ?: 0;
$this->setCurrentPageID($pageID);
return $this->renderWith($this->getTemplatesWithSuffix('_TreeView'));
}

Expand Down

0 comments on commit eed7359

Please sign in to comment.