diff --git a/config/alfresco/templates/webscripts/org/alfresco/portlets/myspaces_get_html.ftl b/config/alfresco/templates/webscripts/org/alfresco/portlets/myspaces_get_html.ftl index e3d0587857..f504f9ff95 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/portlets/myspaces_get_html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/portlets/myspaces_get_html.ftl @@ -66,9 +66,9 @@
Create Space
- - - + + +
Name:
Title:
Description:
Name:
Title:
Description:
@@ -301,7 +301,7 @@ a.spaceBreadcrumbLink:link, a.spaceBreadcrumbLink:visited, a.spaceBreadcrumbLink border: 1px solid #CCD4DB; background-color: #EEF7FB; width: 24em; - height: 11em; + height: 11.4em; padding: 8px; margin: 8px; display: none; diff --git a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java index 55fd3b7f5e..3bbab72b6a 100644 --- a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java +++ b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java @@ -122,17 +122,7 @@ public class FileUploadBean { if (file != null && currentPath != null && currentPath.length() != 0) { - // convert cm:name based path to a NodeRef - StringTokenizer t = new StringTokenizer(currentPath, "/"); - int tokenCount = t.countTokens(); - String[] elements = new String[tokenCount]; - for (int i=0; i requestMap = fc.getExternalContext().getRequestParameterMap(); + String path = (String)requestMap.get("path"); + String name = (String)requestMap.get("name"); + String title = (String)requestMap.get("title"); + String description = (String)requestMap.get("description"); + + if (logger.isDebugEnabled()) + logger.debug("MySpacesBean.createSpace() path=" + path + " name=" + name + + " title=" + title + " description=" + description); + + try + { + if (path != null && name != null) + { + NodeRef containerRef = FileUploadBean.pathToNodeRef(fc, path); + if (containerRef != null) + { + NodeService nodeService = Repository.getServiceRegistry(fc).getNodeService(); + FileFolderService ffService = Repository.getServiceRegistry(fc).getFileFolderService(); + FileInfo folderInfo = ffService.create(containerRef, name, ContentModel.TYPE_FOLDER); + if (logger.isDebugEnabled()) + logger.debug("Created new folder: " + folderInfo.getNodeRef().toString()); + out.write("OK: " + folderInfo.getNodeRef().toString()); + } + } + } + catch (FileExistsException ferr) + { + out.write("ERROR: A file with that name already exists."); + } + catch (Throwable err) + { + out.write("ERROR: " + err.getMessage()); + } + out.close(); + } +} diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 782a3554ea..10c4f495ee 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -3608,6 +3608,15 @@ request + + + Bean backing ajax calls for the MySpaces portlet + + MySpacesBean + org.alfresco.web.bean.ajax.MySpacesBean + request + + Bean that returns manages the tree data for the navigator component diff --git a/source/web/scripts/ajax/myspaces.js b/source/web/scripts/ajax/myspaces.js index ba47ac529e..f8c5a25c8c 100644 --- a/source/web/scripts/ajax/myspaces.js +++ b/source/web/scripts/ajax/myspaces.js @@ -30,7 +30,7 @@ var MySpaces = { }, failure: function(response) { - $('spacePanel').setHTML("Sorry, preview currently unavailable."); + $('spacePanel').setHTML("Sorry, list data currently unavailable."); } } ); @@ -249,6 +249,7 @@ var MySpaces = { var panel = $E(".spaceCreateSpacePanel", $(actionEl).getParent()); panel.setStyle("opacity", 0); panel.setStyle("display", "inline"); + panel.getElementById("space-name").focus(); var anim = new Fx.Styles(panel, {duration: MySpaces.ANIM_LENGTH, transition: Fx.Transitions.linear}); anim.start({'opacity': 1}); }, @@ -258,8 +259,43 @@ var MySpaces = { */ createSpaceOK: function(actionEl, path) { - // TODO: ajax call to create space... - //path = path.replace("_%_", "'"); + // gather the input data + var panel = $(actionEl).getParent(); + var spaceName = panel.getElementById("space-name").value; + var spaceTitle = panel.getElementById("space-title").value; + var spaceDesc = panel.getElementById("space-description").value; + + if (spaceName.length != 0) + { + // ajax call to create space + YAHOO.util.Connect.asyncRequest( + "POST", + getContextPath() + '/ajax/invoke/MySpacesBean.createSpace', + { + success: function(response) + { + if (response.responseText.indexOf("OK:") == 0) + { + MySpaces.refreshList(); + } + else + { + alert("Error during creation of new space: " + response.responseText); + } + MySpaces.closePanel(actionEl); + }, + failure: function(response) + { + alert("Error during creation of new space: " + response.responseText); + MySpaces.closePanel(actionEl); + } + }, + "path=" + path.replace("_%_", "'") + + "&name=" + escape(spaceName) + + "&title=" + escape(spaceTitle) + + "&description=" + escape(spaceDesc) + ); + } }, /** @@ -323,19 +359,27 @@ var MySpaces = { { if (error == null) { - // empty the main panel div and restart by reloading the panel contents - var spacePanel = $('spacePanel'); - spacePanel.setStyle('visibility', 'hidden'); - // show the ajax wait panel - $('spacePanelOverlay').setStyle('visibility', 'visible'); - spacePanel.empty(); - spacePanel.removeEvents('mouseleave'); - MySpaces.start(); + MySpaces.refreshList(); } else { alert("ERROR: " + error); } + }, + + /** + * Refresh the main data list contents within the spacePanel container + */ + refreshList: function() + { + // empty the main panel div and restart by reloading the panel contents + var spacePanel = $('spacePanel'); + spacePanel.setStyle('visibility', 'hidden'); + // show the ajax wait panel + $('spacePanelOverlay').setStyle('visibility', 'visible'); + spacePanel.empty(); + spacePanel.removeEvents('mouseleave'); + MySpaces.start(); } };