mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX Fixed "add page" action when invoked through tree context menu (and removed URL hardcoding in JS) (fixes #7155)
This commit is contained in:
parent
8c1651ec59
commit
98a0331a48
@ -157,12 +157,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
|
||||
}
|
||||
|
||||
public function LinkPageEdit() {
|
||||
if($id = $this->currentPageID()) {
|
||||
return $this->LinkWithSearch(
|
||||
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
|
||||
);
|
||||
}
|
||||
public function LinkPageEdit($id = null) {
|
||||
if(!$id) $id = $this->currentPageID();
|
||||
return $this->LinkWithSearch(
|
||||
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
|
||||
);
|
||||
}
|
||||
|
||||
public function LinkPageSettings() {
|
||||
|
@ -16,18 +16,6 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
* @return Form
|
||||
*/
|
||||
function AddForm() {
|
||||
// If request send from rightclick-submenu, directly add Page
|
||||
if(($pageType = $this->request->getVar('Type')) && ($parentID = $this->request->getVar('ParentID'))) {
|
||||
$data = array(
|
||||
"PageType" => (string)$pageType,
|
||||
"ParentID" => $parentID,
|
||||
"ParentModeField" => "child"
|
||||
);
|
||||
$this->doAdd($data, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$record = $this->currentPage();
|
||||
|
||||
$pageTypes = array();
|
||||
|
@ -3,8 +3,7 @@
|
||||
$.entwine('ss', function($){
|
||||
$('.cms-tree').entwine({
|
||||
getTreeConfig: function() {
|
||||
var config = this._super();
|
||||
var hints = this.getHints();
|
||||
var self = this, config = this._super(), hints = this.getHints();
|
||||
config.plugins.push('contextmenu');
|
||||
config.contextmenu = {
|
||||
'items': function(node) {
|
||||
@ -19,8 +18,9 @@
|
||||
'label': '<span class="jstree-pageicon"></span>' + val.ssname,
|
||||
'_class': 'class-' + val.ssclass,
|
||||
'action': function(obj) {
|
||||
// TODO Fix hardcoding of link
|
||||
$('.cms-container').loadPanel('admin/pages/add/?ParentID=' + id + '&Type=' + val.ssclass);
|
||||
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||
self.data('urlAddpage'), id, val.ssclass
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -30,8 +30,9 @@
|
||||
'edit': {
|
||||
'label': ss.i18n._t('Tree.EditPage'),
|
||||
'action': function(obj) {
|
||||
// TODO Fix hardcoding of link
|
||||
$('.cms-container').loadPanel('admin/pages/add/show/' + obj.data('id'));
|
||||
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||
self.data('urlEditpage'), obj.data('id')
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -40,8 +41,9 @@
|
||||
menuitems['addsubpage'] = {
|
||||
'label': ss.i18n._t('Tree.AddSubPage'),
|
||||
'action': function(obj) {
|
||||
// TODO Fix hardcoding of link
|
||||
$('.cms-container').loadPanel('admin/pages/add/?ParentID=' + obj.data('id'));
|
||||
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||
self.data('urlAddpage'), id, 'Page'
|
||||
));
|
||||
},
|
||||
'submenu': allowedChildren
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
|
||||
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-addpage="{$LinkPageAdd}AddForm/?action_doAdd=1&ParentID=%s&PageType=%s&SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-hints="$SiteTreeHints">
|
||||
$SiteTreeAsUL
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user