Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FEATURE SSF-124 first version of tree list view added

  • Loading branch information...
commit f101595921e2a3e03ba4ffbdd6afedf12e62568d 1 parent 68aa59b
Normann Lou normann authored
62 code/controllers/CMSMain.php
View
@@ -43,6 +43,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'SiteTreeAsUL',
'getshowdeletedsubtree',
'batchactions',
+ 'ListView',
+ 'getListView',
);
public function init() {
@@ -434,6 +436,7 @@ public function getRecord($id, $versionID = null) {
* @return Form
*/
public function getEditForm($id = null, $fields = null) {
+
if(!$id) $id = $this->currentPageID();
$form = parent::getEditForm($id);
@@ -506,7 +509,6 @@ public function getEditForm($id = null, $fields = null) {
}
$this->extend('updateEditForm', $form);
-
return $form;
} else if($id) {
return new Form($this, "EditForm", new FieldList(
@@ -515,6 +517,64 @@ public function getEditForm($id = null, $fields = null) {
}
}
+ /**
+ * Returns the files and subfolders contained in the currently selected folder,
+ * defaulting to the root node. Doubles as search results, if any search parameters
+ * are set through {@link SearchForm()}.
+ *
+ * @return SS_List
+ */
+ public function getList() {//return 'haha';
+ $list = new DataList($this->stat('tree_class'));
+
+ $request = $this->request;
+ $filter = null;
+ if($filterClass = $request->requestVar('FilterClass')){
+ if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
+ throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
+ }
+ $filter = new $filterClass($request->requestVars());
+ $ids = array();
+ foreach($pages=$filter->pagesIncluded() as $pageMap){
+ $ids[] = $pageMap['ID'];
+ }
+ }
+
+ if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
+ return $list;
+ }
+
+ public function getListView(){
+ $list = $this->getList();
+ $gridFieldConfig = GridFieldConfig::create()->addComponents(
+ new GridFieldSortableHeader(),
+ new GridFieldDataColumns(),
+ new GridFieldPaginator(15),
+ new GridFieldEditButton(),
+ new GridFieldDeleteAction(),
+ new GridFieldDetailForm()
+ );
+ $gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
+ $listview = new Form(
+ $this,
+ 'ListView',
+ new FieldList($gridField),
+ new FieldList()
+ );
+
+ $this->extend('updateListView', $listview);
+ $listview->disableSecurityToken();
+ return $listview;
+ }
+
+ public function getListViewHTML(){
+ return $this->getListView()->forTemplate();
+ }
+
+ public function ListView() {
+ return $this->getListView();
+ }
+
public function currentPageID() {
$id = parent::currentPageID();
28 javascript/CMSMain.js
View
@@ -48,8 +48,10 @@
//this.find(':submit').attr('disabled', true);
this.find(':submit[name=action_doSearchTree]').addClass('loading');
-
- this._reloadSitetree(this.serializeArray());
+
+ var params = this.serializeArray();
+ this._reloadSitetree(params);
+ this._reloadListview(params)
return false;
},
@@ -87,6 +89,28 @@
errorMessage('Could not filter site tree<br />' + response.responseText);
}
);
+ },
+
+ _reloadListview: function(params){
+ $('.cms-list').refresh(params);
+
+ }
+ });
+
+ $('#cms-content-listview .cms-list').entwine({
+ refresh: function(params){
+ var self = this;
+
+ $.ajax({
+ url: this.data('url-list'),
+ data: params,
+ success: function(data, status, xhr) {
+ self.html(data);
+ },
+ error: function(xhr, status, e) {
+ errorMessage(e);
+ }
+ });
}
});
11 templates/Includes/CMSPagesController_Content.ss
View
@@ -15,10 +15,10 @@
<li>
<a href="#cms-content-galleryview" class="content-galleryview"><% _t('CMSPagesController.GalleryView', 'Gallery View') %></a>
</li>
+ -->
<li>
<a href="#cms-content-listview" class="content-listview"><% _t('CMSPagesController.ListView', 'List View') %></a>
</li>
- -->
</ul>
</div>
</div>
@@ -43,12 +43,13 @@
</div>
</div>
-
- <!--
+
<div id="cms-content-listview">
- <i>Not implemented yet</i>
+ <div class="cms-list" data-url-list="$Link(getListViewHTML)">
+ $ListView
+ </div>
</div>
-
+ <!--
<div id="cms-content-galleryview">
<i>Not implemented yet</i>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.