Delete space/document action added to MySpaces portlet.

Fixed subtle issue with ajax request being processed before outer txn was completed - caused refresh issues after Create/Upload/Delete actions.
More ui improvements to MySpaces portlet.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5799 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-05-29 13:57:41 +00:00
parent a3774b123d
commit a484e6737f
6 changed files with 74 additions and 23 deletions

View File

@@ -9,7 +9,7 @@
${c?html?replace('$', '<br>', 'rm')}<#if (c?length >= 512)>...</#if> ${c?html?replace('$', '<br>', 'rm')}<#if (c?length >= 512)>...</#if>
</#if> </#if>
<#elseif isImage> <#elseif isImage>
<center><a href="${url.context}${node.url}" target="new"><img src="${url.context}${node.url}" height=140 border=0></a></center> <center><a href="${url.context}${node.url}" target="new" onclick="event.cancelBubble=true;"><img src="${url.context}${node.url}" height=140 border=0></a></center>
<#elseif node.isContainer> <#elseif node.isContainer>
<#list node.children?sort_by('name') as c> <#list node.children?sort_by('name') as c>
<#--if (c_index >= 25)><div>...</div><#break></#if>--> <#--if (c_index >= 25)><div>...</div><#break></#if>-->
@@ -33,13 +33,13 @@
<td class="spaceAction docActionViewContent">View Content</td> <td class="spaceAction docActionViewContent">View Content</td>
</tr> </tr>
<tr> <tr>
<td class="spaceAction docActionDelete">Delete</td> <td class="spaceAction docActionDelete" onclick='event.cancelBubble=true;MySpaces.deleteItem("${node.name}", "${node.nodeRef}");'>Delete</td>
<td class="spaceAction docActionMoreActions">More Actions...</td> <td class="spaceAction docActionMoreActions">More Actions...</td>
</tr> </tr>
<#else> <#else>
<tr> <tr>
<td class="spaceAction spaceActionEditDetails">Edit Details</td> <td class="spaceAction spaceActionEditDetails">Edit Details</td>
<td class="spaceAction spaceActionDelete">Delete</td> <td class="spaceAction spaceActionDelete" onclick='event.cancelBubble=true;MySpaces.deleteItem("${node.name}", "${node.nodeRef}");'>Delete</td>
</tr> </tr>
<tr> <tr>
<td class="spaceAction spaceActionMoreActions">More Actions...</td> <td class="spaceAction spaceActionMoreActions">More Actions...</td>

View File

@@ -12,9 +12,9 @@
<div class="spaceRow"> <div class="spaceRow">
<div class="spaceIcon"> <div class="spaceIcon">
<#if d.isDocument> <#if d.isDocument>
<a href="${url.context}${d.url}" target="new"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a> <a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a>
<#else> <#else>
<a href="${scripturl("${url.context}/service/myspaces?f=${args.f}&p=${args.p}/${d.name}", false)}"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a> <a href="${scripturl("${url.context}/service/myspaces?f=${args.f}&p=${args.p}/${d.name}", false)}"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border="0" onclick="event.cancelBubble=true;"></a>
</#if> </#if>
<div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.icon64}"></div> <div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.icon64}"></div>
</div> </div>

View File

@@ -197,7 +197,6 @@ public class FileUploadBean
ResponseWriter out = fc.getResponseWriter(); ResponseWriter out = fc.getResponseWriter();
XMLUtil.print(result, out); XMLUtil.print(result, out);
out.close();
} }
static NodeRef pathToNodeRef(FacesContext fc, String path) static NodeRef pathToNodeRef(FacesContext fc, String path)

View File

@@ -105,6 +105,27 @@ public class MySpacesBean
{ {
out.write("ERROR: " + err.getMessage()); out.write("ERROR: " + err.getMessage());
} }
out.close(); }
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void deleteItem() throws Exception
{
FacesContext fc = FacesContext.getCurrentInstance();
ResponseWriter out = fc.getResponseWriter();
Map<String, String> requestMap = fc.getExternalContext().getRequestParameterMap();
String strNodeRef = (String)requestMap.get("noderef");
if (strNodeRef != null && strNodeRef.length() != 0)
{
try
{
Repository.getServiceRegistry(fc).getFileFolderService().delete(new NodeRef(strNodeRef));
out.write("OK: " + strNodeRef);
}
catch (Throwable err)
{
out.write("ERROR: " + err.getMessage());
}
}
} }
} }

View File

@@ -180,7 +180,6 @@ public class FilePickerBean
final ResponseWriter out = facesContext.getResponseWriter(); final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out); XMLUtil.print(result, out);
out.close();
} }
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML) @InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
@@ -272,7 +271,6 @@ public class FilePickerBean
final ResponseWriter out = facesContext.getResponseWriter(); final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out); XMLUtil.print(result, out);
out.close();
} }
private String getCurrentAVMPath() private String getCurrentAVMPath()

View File

@@ -227,7 +227,7 @@ var MySpaces = {
{ {
if (!resource.isLoaded) if (!resource.isLoaded)
{ {
// fire off the ajax request to get the resources for this task // fire off the ajax request to get the preview panel content and actions
YAHOO.util.Connect.asyncRequest( YAHOO.util.Connect.asyncRequest(
"POST", "POST",
getContextPath() + '/ajax/invoke/NodeInfoBean.sendNodeInfo', getContextPath() + '/ajax/invoke/NodeInfoBean.sendNodeInfo',
@@ -513,18 +513,6 @@ var MySpaces = {
} }
}, },
/**
* Cancel button click handler for various pop-up panels
*/
closePopupPanel: function()
{
if (this.popupPanel != null)
{
this.popupPanel.setStyle("display", "none");
this.popupPanel = null;
}
},
/** /**
* Display the Upload File pop-up panel * Display the Upload File pop-up panel
*/ */
@@ -590,6 +578,51 @@ var MySpaces = {
} }
}, },
/**
* Delete a space/document item
*/
deleteItem: function(name, noderef)
{
if (confirm("Are you sure you want to delete: " + name))
{
// ajax call to create space
YAHOO.util.Connect.asyncRequest(
"POST",
getContextPath() + '/ajax/invoke/MySpacesBean.deleteItem',
{
success: function(response)
{
if (response.responseText.indexOf("OK:") == 0)
{
MySpaces.refreshList();
}
else
{
alert("Error during delete of item: " + response.responseText);
}
},
failure: function(response)
{
alert("Error during delete of item: " + response.responseText);
}
},
"noderef=" + noderef
);
}
},
/**
* Cancel button click handler for various pop-up panels
*/
closePopupPanel: function()
{
if (this.popupPanel != null)
{
this.popupPanel.setStyle("display", "none");
this.popupPanel = null;
}
},
/** /**
* Refresh the main data list contents within the spacePanel container * Refresh the main data list contents within the spacePanel container
*/ */