mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FEATURE SSF-124 first version of tree list view added
This commit is contained in:
parent
68aa59b25e
commit
f101595921
@ -43,6 +43,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'SiteTreeAsUL',
|
'SiteTreeAsUL',
|
||||||
'getshowdeletedsubtree',
|
'getshowdeletedsubtree',
|
||||||
'batchactions',
|
'batchactions',
|
||||||
|
'ListView',
|
||||||
|
'getListView',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
@ -434,6 +436,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function getEditForm($id = null, $fields = null) {
|
public function getEditForm($id = null, $fields = null) {
|
||||||
|
|
||||||
if(!$id) $id = $this->currentPageID();
|
if(!$id) $id = $this->currentPageID();
|
||||||
$form = parent::getEditForm($id);
|
$form = parent::getEditForm($id);
|
||||||
|
|
||||||
@ -506,7 +509,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->extend('updateEditForm', $form);
|
$this->extend('updateEditForm', $form);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
} else if($id) {
|
} else if($id) {
|
||||||
return new Form($this, "EditForm", new FieldList(
|
return new Form($this, "EditForm", new FieldList(
|
||||||
@ -515,6 +517,64 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
public function currentPageID() {
|
||||||
$id = parent::currentPageID();
|
$id = parent::currentPageID();
|
||||||
|
|
||||||
|
@ -48,8 +48,10 @@
|
|||||||
//this.find(':submit').attr('disabled', true);
|
//this.find(':submit').attr('disabled', true);
|
||||||
|
|
||||||
this.find(':submit[name=action_doSearchTree]').addClass('loading');
|
this.find(':submit[name=action_doSearchTree]').addClass('loading');
|
||||||
|
|
||||||
this._reloadSitetree(this.serializeArray());
|
var params = this.serializeArray();
|
||||||
|
this._reloadSitetree(params);
|
||||||
|
this._reloadListview(params)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -87,6 +89,28 @@
|
|||||||
errorMessage('Could not filter site tree<br />' + response.responseText);
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#cms-content-galleryview" class="content-galleryview"><% _t('CMSPagesController.GalleryView', 'Gallery View') %></a>
|
<a href="#cms-content-galleryview" class="content-galleryview"><% _t('CMSPagesController.GalleryView', 'Gallery View') %></a>
|
||||||
</li>
|
</li>
|
||||||
|
-->
|
||||||
<li>
|
<li>
|
||||||
<a href="#cms-content-listview" class="content-listview"><% _t('CMSPagesController.ListView', 'List View') %></a>
|
<a href="#cms-content-listview" class="content-listview"><% _t('CMSPagesController.ListView', 'List View') %></a>
|
||||||
</li>
|
</li>
|
||||||
-->
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -43,12 +43,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
<div id="cms-content-listview">
|
<div id="cms-content-listview">
|
||||||
<i>Not implemented yet</i>
|
<div class="cms-list" data-url-list="$Link(getListViewHTML)">
|
||||||
|
$ListView
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
<div id="cms-content-galleryview">
|
<div id="cms-content-galleryview">
|
||||||
<i>Not implemented yet</i>
|
<i>Not implemented yet</i>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user