#1703 - Folder dropdown doesn't refresh after adding a folder

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@44661 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2007-11-12 21:47:45 +00:00
parent 4ff41983d3
commit b166122aa7
2 changed files with 20 additions and 18 deletions

View File

@ -549,9 +549,11 @@ JS;
$p->write();
return $this->returnItemToUser($p);
if(isset($_REQUEST['returnID'])) {
return $p->ID;
} else {
return $this->returnItemToUser($p);
}
}
/**

View File

@ -11,10 +11,10 @@ TinyMCEImageEnhancement.prototype = {
},
addListeners: function() {
$('Form_EditorToolbarImageForm_FolderID').value = "";
Event.observe($('AddFolder'),'click',this.onAddFolder.bind(this));
Event.observe($('FolderOk'),'click',this.onFolderOk.bind(this));
$('Form_EditorToolbarImageForm_FolderID').value = "";
Event.observe($('AddFolder'),'click',this.onAddFolder.bind(this));
Event.observe($('FolderOk'),'click',this.onFolderOk.bind(this));
Event.observe($('FolderCancel'),'click',this.onFolderCancel.bind(this));
Event.observe($('UploadFiles'),'click',this.onUpload.bind(this));
},
@ -62,7 +62,7 @@ TinyMCEImageEnhancement.prototype = {
var folderName = $('NewFolderName').value;
var options = {
method: 'post',
postBody: 'ParentID=' + this.getParentID() + '&ajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
postBody: 'ParentID=' + this.getParentID() + '&ajax=1&returnID=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
onSuccess: this.onFolderGetSuccess.bind(this),
onFailure: function(transport) {
errorMessage('Error: Folder not added', transport);
@ -78,9 +78,7 @@ TinyMCEImageEnhancement.prototype = {
*/
onFolderGetSuccess: function(transport) {
var t1 = transport.responseText.indexOf('TreeNode(');
var t2 = transport.responseText.indexOf(',');
var folderID = transport.responseText.substring(t1 + 9,t2);
var folderID = transport.responseText;
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth();
@ -89,7 +87,8 @@ TinyMCEImageEnhancement.prototype = {
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 == 1 ? '0' + date.getSeconds() : date.getSeconds();
var currentDate = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
var folderName = $('NewFolderName').value;
var folderName = $('NewFolderName').value;
this.folderID = folderID;
var options = {
method: 'post',
postBody: 'Created=' + currentDate + '&Name=' + folderName + '&ClassName=Folder&ID=' + folderID + '&ajax=1&action_save=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
@ -107,11 +106,12 @@ TinyMCEImageEnhancement.prototype = {
onFolderAddSuccess: function(transport) {
statusMessage('Creating new folder');
document.getElementsBySelector("div.TreeDropdownField.single")[2].itemTree = null;
$('TreeDropdownField_Form_EditorToolbarImageForm_FolderID').itemTree = null;
$('TreeDropdownField_Form_EditorToolbarImageForm_FolderID').setValue(this.folderID);
$('NewFolderName').value = '';
Element.show('AddFolder');
Element.hide('NewFolderName','FolderOk','FolderCancel');
this.removeIE6Hack();
this.removeIE6Hack();
},
/**
@ -136,7 +136,7 @@ TinyMCEImageEnhancement.prototype = {
{
fileTypes : '*.jpeg;*.jpg;*.jpe;*.png;*.gif;',
fileTypesDescription : 'Image files',
fileUploadLimit : '100',
fileUploadLimit : '100',
securityID : $('SecurityID').value,
beginUploadOnQueue : true,
buildUI : this.addListeners.bind(this),
@ -225,7 +225,7 @@ TinyMCEImageEnhancement.prototype = {
applyIE6Hack: function() {
if(BrowserDetect.browser == 'Explorer') {
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles'),$('PipeSeparator')];
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles')];
$A(elements).each(function(element) {
element.style.position = "relative";
element.style.top = "-3px";
@ -235,7 +235,7 @@ TinyMCEImageEnhancement.prototype = {
removeIE6Hack: function() {
if(BrowserDetect.browser == 'Explorer') {
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles'),$('PipeSeparator')];
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles')];
$A(elements).each(function(element) {
element.style.position = "";
});
@ -251,4 +251,4 @@ TinyMCEImageEnhancement.prototype = {
return $('Form_EditorToolbarImageForm_FolderID').value == '' ? 'root' : $('Form_EditorToolbarImageForm_FolderID').value;
}
}
tinyMCEImageEnhancement = new TinyMCEImageEnhancement();
tinyMCEImageEnhancement = new TinyMCEImageEnhancement();