From 4a36b1e490428f3a5d563d144ed74bb5580e33d8 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 10 Apr 2012 14:14:42 +1200 Subject: [PATCH] ENHANCEMENT SSF-124 finished ajax version of admin/pages/listchildren/ID in Pages admin --- code/controllers/CMSMain.php | 11 ++++++++--- javascript/CMSMain.js | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 8015988a..87f18659 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -45,6 +45,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'batchactions', 'ListView', 'getListView', + 'listchildren', ); public function init() { @@ -561,7 +562,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')'); }else{ - $list->filter("ParentID", 0); + $parentID = 0; + if($this->urlParams['Action'] == 'listchildren' && $this->urlParams['ID']){ + $parentID = $this->urlParams['ID']; + } + $list->filter("ParentID", $parentID); } return $list; @@ -636,9 +641,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function listchildren(){ if(Director::is_ajax()){ - return $this; + return $this->getListViewHTML(); }else{ - + return $this; } } diff --git a/javascript/CMSMain.js b/javascript/CMSMain.js index a0d85f21..1cc7164d 100644 --- a/javascript/CMSMain.js +++ b/javascript/CMSMain.js @@ -111,6 +111,23 @@ errorMessage(e); } }); + }, + replace: function(url){ + if(window.History.enabled) { + var container = $('.cms-container') + container.loadPanel(url, '', {selector: '.cms-list'}); + } else { + window.location = $.path.makeUrlAbsolute(url, $('base').attr('href')); + } + } + }); + + $('.cms-list .list-children-link').entwine({ + onclick: function(e) { + this.closest('.cms-list').replace(this.attr('href')); + e.preventDefault(); + return false; + } });