ENHANCEMENT: Added page location fields in the behaviour tab, as an alternative to drag and drop

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@75815 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-05-01 03:02:48 +00:00
parent a0f7e9f1a7
commit 2414eb30cc
3 changed files with 39 additions and 5 deletions

View File

@ -593,6 +593,7 @@ JS;
// HACK: This should be turned into something more general // HACK: This should be turned into something more general
$originalClass = $record->ClassName; $originalClass = $record->ClassName;
$originalStatus = $record->Status; $originalStatus = $record->Status;
$originalParentID = $record->ParentID;
$record->HasBrokenLink = 0; $record->HasBrokenLink = 0;
$record->HasBrokenFile = 0; $record->HasBrokenFile = 0;
@ -660,6 +661,10 @@ JS;
$message .= sprintf(_t('LeftAndMain.STATUSTO'," Status changed to '%s'"),$record->Status); $message .= sprintf(_t('LeftAndMain.STATUSTO'," Status changed to '%s'"),$record->Status);
} }
if($originalParentID != $record->ParentID) {
FormResponse::add("if(\$('sitetree').setNodeParentID) \$('sitetree').setNodeParentID($record->ID, $record->ParentID);");
}
$record->write(); $record->write();
if( ($record->class != 'VirtualPage') && $originalURLSegment != $record->URLSegment) { if( ($record->class != 'VirtualPage') && $originalURLSegment != $record->URLSegment) {

View File

@ -85,14 +85,34 @@ Behaviour.register({
onchange: function() { onchange: function() {
alert('The page type will be updated after the page is saved'); alert('The page type will be updated after the page is saved');
} }
} },
});
Behaviour.register({
'#Form_EditForm' : { '#Form_EditForm' : {
changeDetection_fieldsToIgnore : { changeDetection_fieldsToIgnore : {
'restricted-chars[Form_EditForm_URLSegment]' : true, 'restricted-chars[Form_EditForm_URLSegment]' : true,
'Sort' : true 'Sort' : true
} }
},
// ParentType / ParentID field combination
'#Form_EditForm_ParentType' : {
initialize : function() {
$('Form_EditForm_ParentType_root').onclick = this.rootClick.bind(this);
$('Form_EditForm_ParentType_subpage').onclick = this.showHide;
this.showHide();
},
rootClick : function() {
$('Form_EditForm_ParentID').setValue(0);
this.showHide();
},
showHide : function() {
if($('Form_EditForm_ParentType_root').checked) {
Element.hide('ParentID');
} else {
Element.show('ParentID');
}
}
} }
}); });

View File

@ -102,6 +102,15 @@ TreeAPI.prototype = {
}); });
}, },
/**
* Set the parent ID of a tree node
*/
setNodeParentID: function (idx, parentID) {
var treeNode = this.getTreeNodeByIdx(idx);
var parentNode = this.getTreeNodeByIdx(parentID);
parentNode.appendTreeNode(treeNode);
},
setCurrentByIdx : function(idx) { setCurrentByIdx : function(idx) {
if(this.selected) { if(this.selected) {
var i,item; var i,item;