mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00:00
NEW Set correct ParentID when creating page from list view
This commit is contained in:
parent
2dd0e3f02e
commit
ec93643f49
@ -757,6 +757,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
||||||
);
|
);
|
||||||
$gridField->getConfig()->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('getTreeTitle' => 'Title'));
|
$gridField->getConfig()->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('getTreeTitle' => 'Title'));
|
||||||
|
$gridField->getState()->ParentID = $parentID;
|
||||||
|
|
||||||
if(!$params) {
|
if(!$params) {
|
||||||
$fields = array_merge(array('listChildrenLink' => ''), $fields);
|
$fields = array_merge(array('listChildrenLink' => ''), $fields);
|
||||||
|
@ -91,9 +91,18 @@
|
|||||||
|
|
||||||
$(".cms-page-add-button").entwine({
|
$(".cms-page-add-button").entwine({
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
var selected = $('.cms-tree').jstree('get_selected'),
|
var tree = $('.cms-tree'), list = $('.cms-list'), parentId = 0;
|
||||||
parentId = selected ? $(selected[0]).data('id') : null,
|
|
||||||
data = {selector: this.data('targetPanel'),pjax: this.data('pjax')},
|
// Choose parent ID either from tree or list view, depending which is visible
|
||||||
|
if(tree.is(':visible')) {
|
||||||
|
var selected = tree.jstree('get_selected');
|
||||||
|
parentId = selected ? $(selected[0]).data('id') : null;
|
||||||
|
} else {
|
||||||
|
var state = list.find('input[name="Page[GridState]"]').val();
|
||||||
|
if(state) parentId = parseInt(JSON.parse(state).ParentID, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {selector: this.data('targetPanel'),pjax: this.data('pjax')},
|
||||||
url = parentId ? ss.i18n.sprintf(this.data('urlAddpage'), parentId) : this.attr('href');
|
url = parentId ? ss.i18n.sprintf(this.data('urlAddpage'), parentId) : this.attr('href');
|
||||||
|
|
||||||
$('.cms-container').loadPanel(url, null, data);
|
$('.cms-container').loadPanel(url, null, data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user