. Multi-select actions added to User Sandbox component

- stub implementation of Submit All, Revert All
. Available Content Forms panel added to User Sandbox component
 - shows forms assigned to the web project (configured in the Web Project wizard)
. Fix to RenderingEngineTemplateImpl refactor that was causing a null-ptr exception in the web project wizard

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4353 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-11-14 12:14:03 +00:00
parent cb5a882837
commit 42be18790d
8 changed files with 205 additions and 33 deletions

View File

@@ -852,8 +852,11 @@ user_sandboxes=User Sandboxes
sandbox_preview=Preview Website
sandbox_create=Create New Content
sandbox_browse=Browse Website
sandbox_revert=Undo
sandbox_revertall=Undo All
sandbox_submitall=Submit All
sandbox_submitselected=Submit Selected
sandbox_revertselected=Undo Selected
sandbox_icon=Browse Website
import_website_content=Import Website Content
title_browse_sandbox=Browse Sandbox
@@ -864,15 +867,19 @@ website_browse_folders=Browse Folders
website_browse_files=Browse Files
creator=Creator
modified_items=Modified Items
content_forms=Available Content Forms
store_created_on=Created On
store_created_by=Created By
store_working_users=There are {0} user(s) working on this web project.
avm_node_deleted=Deleted
revert=Revert
submit=Submit
submit_success=Successfully submitted item: {0}
submitall_success=Successfully submitted sandbox for user: {0}
folder_preview=Preview Folder
file_preview=Preview File
selected=Selected
create_form_content=Create Content
# Website actions and dialog messages
title_import_content=Import Content into Website

View File

@@ -85,6 +85,19 @@
</params>
</action>
<!-- Revert AVM node -->
<action id="revert">
<permissions>
<permission allow="true">Read</permission>
</permissions>
<label-id>revert</label-id>
<image>/images/icons/revert.gif</image>
<action-listener>#{AVMBrowseBean.revertNode}</action-listener>
<params>
<param name="id">#{actionContext.path}</param>
</params>
</action>
<!-- Preview folder -->
<action id="preview_folder">
<label-id>folder_preview</label-id>
@@ -199,6 +212,7 @@
<action idref="edit_file" />
<action idref="update_file" />
<action idref="submit" />
<action idref="revert" />
<action idref="preview_file" />
<action idref="file_details" />
<action idref="delete_file" />
@@ -208,6 +222,7 @@
<action-group id="avm_folder_modified">
<show-link>false</show-link>
<action idref="submit" />
<action idref="revert" />
<action idref="preview_folder" />
<action idref="folder_details" />
<action idref="delete_folder" />
@@ -217,6 +232,7 @@
<action-group id="avm_deleted_modified">
<show-link>false</show-link>
<action idref="submit" />
<action idref="revert" />
</action-group>
<!-- Actions for the Create menu in the sandbox browse screen -->

View File

@@ -727,23 +727,6 @@ public class AVMBrowseBean implements IContextListener
tx = Repository.getUserTransaction(context, false);
tx.begin();
// NodeRef nodeRef = getAvmActionNode().getNodeRef();
// String name = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
// NodeRef workflowPackage = this.workflowService.createPackage(null);
// ChildAssociationRef childRef =
// this.nodeService.createNode(workflowPackage, ContentModel.ASSOC_CONTAINS,
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
// name), ContentModel.TYPE_CMOBJECT);
// Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
// aspectProperties.put(ContentModel.PROP_NODE_REF, nodeRef);
// NodeRef childNodeRef = childRef.getChildRef();
// this.nodeService.addAspect(childNodeRef, ContentModel.ASPECT_REFERENCES_NODE, aspectProperties);
//
// Map<String, Serializable> actionParams = new HashMap<String, Serializable>();
// actionParams.put(StartAVMWorkflowAction.PARAM_WORKFLOW_NAME, "jbpm$wcmwf:submit");
// Action action = this.actionService.createAction(ACTION_AVM_WORKFLOW, actionParams);
// this.actionService.executeAction(action, workflowPackage);
Action action = this.actionService.createAction(ACTION_AVM_SUBMIT);
this.actionService.executeAction(action, getAvmActionNode().getNodeRef());
@@ -807,6 +790,9 @@ public class AVMBrowseBean implements IContextListener
}
}
/**
* Submit items selected using multi-select
*/
public void submitSelected(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
@@ -815,6 +801,61 @@ public class AVMBrowseBean implements IContextListener
String username = params.get("username");
List<AVMNodeDescriptor> selected = this.userSandboxes.getSelectedNodes(username);
if (selected != null)
{
UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, false);
tx.begin();
for (AVMNodeDescriptor node : selected)
{
Action action = this.actionService.createAction(ACTION_AVM_SUBMIT);
this.actionService.executeAction(action, AVMNodeConverter.ToNodeRef(-1, node.getPath()));
}
// commit the transaction
tx.commit();
// if we get here, all was well - output friendly status message to the user
// TODO: different message once the submit screen is available
String msg = MessageFormat.format(Application.getMessage(
context, MSG_SUBMITALL_SUCCESS), username);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
String formId = Utils.getParentForm(context, event.getComponent()).getClientId(context);
context.addMessage(formId + ':' + COMPONENT_SANDBOXESPANEL, facesMsg);
}
catch (Throwable err)
{
err.printStackTrace(System.err);
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
}
/**
* Undo changes to a single node
*/
public void revertNode(ActionEvent event)
{
}
/**
* Undo changes to the entire sandbox
*/
public void revertAll(ActionEvent event)
{
}
/**
* Undo changes to items selected using multi-select
*/
public void revertSelected(ActionEvent event)
{
}

View File

@@ -75,7 +75,7 @@ public class RenderingEngineTemplateImpl
{
return (String)
this.nodeService.getProperty(this.nodeRef,
ContentModel.PROP_TITLE);
ContentModel.PROP_NAME);
}
public String getDescription()

View File

@@ -79,9 +79,11 @@ public class UIUserSandboxes extends SelfRenderingComponent
private static final String COMPONENT_ACTIONS = "org.alfresco.faces.Actions";
private static final String ACT_PANEL = "_panel";
private static final String ACT_MODIFIED_PANEL = "_items";
private static final String ACT_FORMS_PANEL = "_forms";
private static final String MSG_MODIFIED_ITEMS = "modified_items";
private static final String MSG_CONTENT_FORMS = "content_forms";
private static final String MSG_SIZE = "size";
private static final String MSG_CREATED = "created_date";
private static final String MSG_USERNAME = "username";
@@ -90,6 +92,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
private static final String MSG_MODIFIED = "modified_date";
private static final String MSG_ACTIONS = "actions";
private static final String MSG_DELETED_ITEM = "avm_node_deleted";
private static final String MSG_SELECTED = "selected";
private static final String SPACE_ICON = "/images/icons/" + BrowseBean.SPACE_SMALL_DEFAULT + ".gif";
@@ -109,6 +112,9 @@ public class UIUserSandboxes extends SelfRenderingComponent
private String[] checkedItems = null;
/** transient list of available web forms */
private List<NodeRef> forms = null;
// ------------------------------------------------------------------------------
// Component implementation
@@ -172,9 +178,14 @@ public class UIUserSandboxes extends SelfRenderingComponent
Map requestMap = context.getExternalContext().getRequestParameterMap();
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
// detect if a panel has been expanded/collapsed
String fieldId = getClientId(context) + ACT_PANEL;
// detect if Modified Items or Available Content Forms panel has been expanded/collapsed
String fieldId = getClientId(context) + ACT_FORMS_PANEL;
String value = (String)requestMap.get(fieldId);
if (value == null || value.length() == 0)
{
fieldId = getClientId(context) + ACT_MODIFIED_PANEL;
value = (String)requestMap.get(fieldId);
}
if (value != null && value.length() != 0)
{
// expand/collapse the specified users panel
@@ -210,6 +221,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
this.rowToUserLookup.clear();
this.userToRowLookup.clear();
this.userNodes.clear();
this.forms = null;
ResourceBundle bundle = Application.getBundle(context);
AVMService avmService = getAVMService(context);
@@ -310,6 +322,11 @@ public class UIUserSandboxes extends SelfRenderingComponent
"#{AVMBrowseBean.submitAll}", null, null));
out.write("&nbsp;");
Utils.encodeRecursive(context, aquireAction(
context, mainStore, username, "sandbox_revertall", "/images/icons/revert.gif",
"#{AVMBrowseBean.revertAll}", null, null));
out.write("&nbsp;");
Utils.encodeRecursive(context, aquireAction(
context, mainStore, username, "sandbox_browse", "/images/icons/space_small.gif",
"#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null));
@@ -318,21 +335,42 @@ public class UIUserSandboxes extends SelfRenderingComponent
// modified items panel
out.write("<tr><td></td><td colspan=2>");
String panelImage = WebResources.IMAGE_COLLAPSED;
if (this.expandedPanels.contains(username))
if (this.expandedPanels.contains(username + ACT_MODIFIED_PANEL))
{
panelImage = WebResources.IMAGE_EXPANDED;
}
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
Utils.generateFormSubmit(context, this, getClientId(context) + ACT_PANEL, username)));
Utils.generateFormSubmit(context, this, getClientId(context) + ACT_MODIFIED_PANEL, username + ACT_MODIFIED_PANEL)));
out.write("&nbsp;<b>");
out.write(bundle.getString(MSG_MODIFIED_ITEMS));
out.write("</b>");
if (this.expandedPanels.contains(username))
if (this.expandedPanels.contains(username + ACT_MODIFIED_PANEL))
{
out.write("<div style='padding:2px'></div>");
// list the modified docs for this sandbox user
renderUserFiles(context, out, username, index, storeRoot);
renderUserFiles(context, out, username, storeRoot, index);
}
out.write("</td></tr>");
// content forms panel
out.write("<tr style='padding-top:4px'><td></td><td colspan=2>");
panelImage = WebResources.IMAGE_COLLAPSED;
if (this.expandedPanels.contains(username + ACT_FORMS_PANEL))
{
panelImage = WebResources.IMAGE_EXPANDED;
}
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
Utils.generateFormSubmit(context, this, getClientId(context) + ACT_FORMS_PANEL, username + ACT_FORMS_PANEL)));
out.write("&nbsp;<b>");
out.write(bundle.getString(MSG_CONTENT_FORMS));
out.write("</b>");
if (this.expandedPanels.contains(username + ACT_FORMS_PANEL))
{
out.write("<div style='padding:2px'></div>");
// list the content forms for this sandbox user
renderContentForms(context, out, websiteRef, username, storeRoot);
}
out.write("</td></tr></table>");
@@ -370,7 +408,8 @@ public class UIUserSandboxes extends SelfRenderingComponent
*
* @throws IOException
*/
private void renderUserFiles(FacesContext fc, ResponseWriter out, String username, int index, String storeRoot)
private void renderUserFiles(
FacesContext fc, ResponseWriter out, String username, String storeRoot, int index)
throws IOException
{
AVMSyncService avmSyncService = getAVMSyncService(fc);
@@ -406,7 +445,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
this.userNodes.put(username, nodes);
// output the table of modified items
out.write("<table class='modifiedItemsList' cellspacing=2 cellpadding=2 border=0 width=100%>");
out.write("<table class='modifiedItemsList' cellspacing=2 cellpadding=1 border=0 width=100%>");
// header row
out.write("<tr align=left><th>");
@@ -415,8 +454,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write(Integer.toString(index));
out.write("' onclick='");
out.write("javascript:_sb_select(this);");
out.write("'></th>");
out.write("</th><th width=16></th><th>");
out.write("'></th><th width=16></th><th>");
out.write(bundle.getString(MSG_NAME));
out.write("</th><th>");
out.write(bundle.getString(MSG_CREATED));
@@ -565,10 +603,17 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write("</td></tr>");
}
// output multi-select actions for this user
out.write("<tr><td colspan=8>");
out.write(bundle.getString(MSG_SELECTED));
out.write(":&nbsp;");
Utils.encodeRecursive(fc, aquireAction(
fc, userStorePrefix, username, "sandbox_submitselected", "/images/icons/submit.gif",
"#{AVMBrowseBean.submitSelected}", null, null));
out.write("&nbsp;");
Utils.encodeRecursive(fc, aquireAction(
fc, userStorePrefix, username, "sandbox_revertselected", "/images/icons/revert.gif",
"#{AVMBrowseBean.revertSelected}", null, null));
out.write("</td></tr>");
// end table
@@ -580,6 +625,69 @@ public class UIUserSandboxes extends SelfRenderingComponent
}
}
/**
* Render the list of content forms available for this sandbox.
*
* @param fc FacesContext
* @param out ResponseWriter
*
* @throws IOException
*/
private void renderContentForms(
FacesContext fc, ResponseWriter out, NodeRef websiteRef, String username, String storeRoot)
throws IOException
{
NodeService nodeService = getNodeService(fc);
String userStorePrefix = AVMConstants.buildAVMUserMainStoreName(storeRoot, username);
// only need to collect the list of forms once per render
// TODO: execute permission evaluations on a per user basis against each form?
if (this.forms == null)
{
List<ChildAssociationRef> webFormRefs = nodeService.getChildAssocs(
websiteRef, ContentModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
this.forms = new ArrayList<NodeRef>(webFormRefs.size());
for (ChildAssociationRef ref : webFormRefs)
{
this.forms.add(ref.getChildRef());
}
}
if (this.forms.size() != 0)
{
ResourceBundle bundle = Application.getBundle(fc);
// output the table of available forms
out.write("<table class='modifiedItemsList' cellspacing=2 cellpadding=1 border=0 width=100%>");
// header row
out.write("<tr align=left><th>");
out.write(bundle.getString(MSG_NAME));
out.write("</th><th>");
out.write(bundle.getString(MSG_DESCRIPTION));
out.write("</th><th>");
out.write(bundle.getString(MSG_ACTIONS));
out.write("</th></tr>");
for (NodeRef formRef : this.forms)
{
out.write("<tr><td>");
String title = (String)nodeService.getProperty(formRef, ContentModel.PROP_TITLE);
out.write(title != null ? title : "");
out.write("</td><td>");
String desc = (String)nodeService.getProperty(formRef, ContentModel.PROP_DESCRIPTION);
out.write(desc != null ? desc : "");
out.write("</td><td>");
// actions
Utils.encodeRecursive(fc, aquireAction(
fc, userStorePrefix, username, "create_form_content", "/images/icons/new_content.gif",
null, "wizard:createWebContent", null));
out.write("</td></tr>");
}
out.write("</table>");
}
}
/**
* @return Byte size converter
*/

View File

@@ -576,8 +576,8 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl
.modifiedItemsList
{
background-color: #EEEEEE;
background-color: #f8f8f8;
border-width: 1px;
border-style: dashed;
border-color: #AAAAAA;
border-style: solid;
border-color: #DDDDDD;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB