mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Create Space action implemented in the MySpaces portlet. Other portlet UI improvement and fixes.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5776 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,9 +66,9 @@
|
||||
<div class="spaceAction spaceActionCreateSpace" title="Create a new Space" onclick="MySpaces.createSpace(this);">Create Space</div>
|
||||
<div class="spaceCreateSpacePanel">
|
||||
<table cellspacing="2" cellpadding="2" border="0">
|
||||
<tr><td>Name:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-name"></td></tr>
|
||||
<tr><td>Title:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-title"></td></tr>
|
||||
<tr><td>Description:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-description"></td></tr>
|
||||
<tr><td>Name:</td><td><input style="margin:4px" type="text" size="32" maxlength="1024" id="space-name"></td></tr>
|
||||
<tr><td>Title:</td><td><input style="margin:4px" type="text" size="32" maxlength="1024" id="space-title"></td></tr>
|
||||
<tr><td>Description:</td><td><input style="margin:4px" type="text" size="32" maxlength="1024" id="space-description"></td></tr>
|
||||
</table>
|
||||
<input style="margin:4px" type="button" value="OK" onclick='MySpaces.createSpaceOK(this, "${path?url?replace("'","_%_")}");'>
|
||||
<input style="margin:4px" type="button" value="Cancel" onclick="MySpaces.closePanel(this);">
|
||||
@@ -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;
|
||||
|
@@ -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<tokenCount; i++)
|
||||
{
|
||||
elements[i] = t.nextToken();
|
||||
}
|
||||
|
||||
NodeRef containerRef = BaseServlet.resolveWebDAVPath(fc, elements, false);
|
||||
|
||||
NodeRef containerRef = pathToNodeRef(fc, currentPath);
|
||||
if (containerRef != null)
|
||||
{
|
||||
// Try and extract metadata from the file
|
||||
@@ -209,4 +199,17 @@ public class FileUploadBean
|
||||
XMLUtil.print(result, out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
static NodeRef pathToNodeRef(FacesContext fc, String path)
|
||||
{
|
||||
// convert cm:name based path to a NodeRef
|
||||
StringTokenizer t = new StringTokenizer(path, "/");
|
||||
int tokenCount = t.countTokens();
|
||||
String[] elements = new String[tokenCount];
|
||||
for (int i=0; i<tokenCount; i++)
|
||||
{
|
||||
elements[i] = t.nextToken();
|
||||
}
|
||||
return BaseServlet.resolveWebDAVPath(fc, elements, false);
|
||||
}
|
||||
}
|
||||
|
97
source/java/org/alfresco/web/bean/ajax/MySpacesBean.java
Normal file
97
source/java/org/alfresco/web/bean/ajax/MySpacesBean.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
package org.alfresco.web.bean.ajax;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
|
||||
import org.alfresco.filesys.server.filesys.FileExistsException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.ajax.InvokeCommand;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean backing the ajax requests from the MySpaces portlet webscript.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class MySpacesBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(MySpacesBean.class);
|
||||
|
||||
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
|
||||
public void createSpace() throws Exception
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
ResponseWriter out = fc.getResponseWriter();
|
||||
|
||||
Map<String, String> 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();
|
||||
}
|
||||
}
|
@@ -3608,6 +3608,15 @@
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<description>
|
||||
Bean backing ajax calls for the MySpaces portlet
|
||||
</description>
|
||||
<managed-bean-name>MySpacesBean</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.ajax.MySpacesBean</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<description>
|
||||
Bean that returns manages the tree data for the navigator component
|
||||
|
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user