Merged V3.1 to HEAD

13371: Fix for ETHREEOH-1371, ETHREEOH-1373, ETHREEOH-1374.
          Rule comparator now correctly deals with MLTEXT datatype fields such as name/title/description.
   13372: Fix for ETHREEOH-1291.
          Fixes the general issue that "decodeURI()" should not be used to decode javascript encoded strings -unless- you specifically want to ignore certain characters, "unescape()" should be used instead.
   13373: Fix for ETHREEOH-1284. Clean up of generated javascript for UIDataPager component - also moved to include file for performance and ease of modification.
   13384: Fix for ETHREEOH-1459.
          Sweep through and clean up of the Edit Online/Offline editing and Checkin/Checkout process as per latest wireframes.
          A number of minor fixes to JSF action evaluators and related JSPs also.
          Icons updated as per wires.
   13396: Fix for ETHREEOH-1424. Web-framework script connector now generates an Accept-Language header based on current user locale by default for remote calls.
   13404: Missing paging controls added to task and workflow dialogs (part of ETHREEOH-1410).

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13596 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-03-12 12:04:24 +00:00
parent 2152123239
commit c172eba346
39 changed files with 259 additions and 310 deletions

View File

@@ -42,7 +42,8 @@ public class CancelCheckoutDocEvaluator extends BaseActionEvaluator
*/
public boolean evaluate(Node node)
{
return (node.hasPermission(PermissionService.CANCEL_CHECK_OUT) &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY));
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
}
}

View File

@@ -30,18 +30,16 @@ import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Cancel editing document.
*
*/
public class CancelEditingDocEvaluator extends BaseActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasPermission(PermissionService.CANCEL_CHECK_OUT) &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY));
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
}

View File

@@ -42,7 +42,8 @@ public class CheckinDocEvaluator extends BaseActionEvaluator
*/
public boolean evaluate(Node node)
{
return (node.hasPermission(PermissionService.CHECK_IN) &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true);
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CHECK_IN));
}
}
}

View File

@@ -30,7 +30,6 @@ import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Done editing document.
*
*/
public class DoneEditingDocEvaluator extends BaseActionEvaluator
{
@@ -39,7 +38,8 @@ public class DoneEditingDocEvaluator extends BaseActionEvaluator
*/
public boolean evaluate(Node node)
{
return (node.hasPermission(PermissionService.CHECK_IN) &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true);
return (node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.hasPermission(PermissionService.CHECK_IN));
}
}

View File

@@ -50,7 +50,8 @@ public class ForumsCheckinDocEvaluator extends BaseActionEvaluator
{
boolean allow = false;
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null)
{
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{

View File

@@ -24,8 +24,6 @@
*/
package org.alfresco.web.action.evaluator;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
@@ -51,12 +49,11 @@ public class UpdateDocEvaluator extends BaseActionEvaluator
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
Map<String, Object> props = node.getProperties();
boolean isOfflineEditing = props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOfflineDialog.OFFLINE_EDITING);
boolean isOfflineEditing =
(EditOfflineDialog.OFFLINE_EDITING.equals(node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE)));
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.isWorkingCopyOwner() == true && !isOfflineEditing) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false));
((node.isWorkingCopyOwner() && !isOfflineEditing) ||
(!node.isLocked() && !node.hasAspect(ContentModel.ASPECT_WORKING_COPY)));
}
}
}

View File

@@ -24,8 +24,6 @@
*/
package org.alfresco.web.action.evaluator;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.coci.EditOfflineDialog;
@@ -33,20 +31,16 @@ import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Upload new version
*
*/
public class UploadNewVersionEvaluator extends BaseActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
Map<String, Object> props = node.getProperties();
return (node.hasPermission(PermissionService.CHECK_IN) && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true &&
props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOfflineDialog.OFFLINE_EDITING));
}
}
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
EditOfflineDialog.OFFLINE_EDITING.equals(node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE)) &&
node.hasPermission(PermissionService.CHECK_IN));
}
}

View File

@@ -35,7 +35,7 @@ import org.apache.commons.logging.LogFactory;
public class CancelEditingDialog extends CheckinCheckoutDialog
{
public static final String LBL_CANCEL_EDITING = "cancel_editing";
public static final String MSG_CANCEL_EDITING = "cancel_editing";
public static final String MSG_CANCEL_EDITING_FOR = "cancel_editing_for";
private static Log logger = LogFactory.getLog(CheckinCheckoutDialog.class);
@@ -62,7 +62,7 @@ public class CancelEditingDialog extends CheckinCheckoutDialog
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), LBL_CANCEL_EDITING);
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CANCEL_EDITING);
}
/**

View File

@@ -47,13 +47,13 @@ import org.alfresco.web.ui.common.Utils;
*/
public class DoneEditingDialog extends CheckinCheckoutDialog
{
private final static String MSG_DONE = "done";
private static final String MSG_CHECK_IN = "check_in";
private final static String MSG_OK = "ok";
private static final String MSG_DONE_EDITING = "done_editing";
private final static String MSG_MISSING_ORIGINAL_NODE = "missing_original_node";
private final static String DIALOG_NAME = AlfrescoNavigationHandler.DIALOG_PREFIX + "doneEditingFile";
/**
* this flag indicates occurrence when source node isn't versionable, but working copy yet is versionable
*/
@@ -95,7 +95,7 @@ public class DoneEditingDialog extends CheckinCheckoutDialog
/**
* @return Returns true if source node for selected working copy founded
*/
public boolean isSourceFounded()
public boolean isSourceFound()
{
return (sourceNodeRef != null);
}
@@ -132,28 +132,30 @@ public class DoneEditingDialog extends CheckinCheckoutDialog
{
sourceNodeRef = getSourceNodeRef(node.getNodeRef());
if (sourceNodeRef != null)
{
sourceVersionable = getNodeService().hasAspect(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
}
}
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DONE);
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_OK);
}
@Override
public boolean getFinishButtonDisabled()
{
return !isSourceFounded();
return !isSourceFound();
}
@Override
public String getContainerTitle()
{
if (isSourceFounded())
if (isSourceFound())
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CHECK_IN) + " '" + getNodeService().getProperty(sourceNodeRef, ContentModel.PROP_NAME) + "'";
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DONE_EDITING) + " '" + getNodeService().getProperty(sourceNodeRef, ContentModel.PROP_NAME) + "'";
}
else
{
@@ -183,7 +185,7 @@ public class DoneEditingDialog extends CheckinCheckoutDialog
*/
private String getCurrentVersionLabel()
{
if (isSourceFounded())
if (isSourceFound())
{
Version curVersion = property.getVersionQueryService().getCurrentVersion(sourceNodeRef);
return curVersion.getVersionLabel();

View File

@@ -38,14 +38,12 @@ import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.web.app.Application;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.WebResources;
import org.springframework.util.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Kevin Roast
@@ -96,6 +94,10 @@ public class UIDataPager extends UICommand
return;
}
final String formClientId = Utils.getParentForm(context, this).getClientId(context);
final String pageInputId = getPageInputId();
final String hiddenFieldName = getHiddenFieldName();
ResponseWriter out = context.getResponseWriter();
ResourceBundle bundle = Application.getBundle(context);
StringBuilder buf = new StringBuilder(512);
@@ -130,15 +132,15 @@ public class UIDataPager extends UICommand
imageVericalAlign = "middle";
imageStyle = "margin-top:0px;";
inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
inputPageNumber.append("onkeydown=\"").append(generateIE6InputOnkeydownScript()).append("\" ");
inputPageNumber.append("id=\"").append(getPageInputId()).append("\" />");
inputPageNumber.append("onkeydown=\"").append(generateIE6InputOnkeydownScript(pageInputId, formClientId, hiddenFieldName)).append("\" ");
inputPageNumber.append("id=\"").append(pageInputId).append("\" />");
}
else
{
inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
inputPageNumber.append("onkeyup=\"").append(generateInputOnkeyupScript()).append("\" ");
inputPageNumber.append("onkeyup=\"").append(generateInputOnkeyupScript(pageInputId, formClientId, hiddenFieldName)).append("\" ");
inputPageNumber.append("onkeydown=\"").append(generateInputOnkeydownScript()).append("\" ");
inputPageNumber.append("id=\"").append(getPageInputId()).append("\" />");
inputPageNumber.append("id=\"").append(pageInputId).append("\" />");
}
}
@@ -170,7 +172,7 @@ public class UIDataPager extends UICommand
if (currentPage != 0)
{
buf.append("<a href='#' onclick=\"");
buf.append(generateEventScript(0));
buf.append(generateEventScript(0, hiddenFieldName));
buf.append("\">");
buf.append(Utils.buildImageTag(context, WebResources.IMAGE_FIRSTPAGE, 16, 16, bundle.getString(FIRST_PAGE), null, imageVericalAlign, imageStyle));
buf.append("</a>");
@@ -186,7 +188,7 @@ public class UIDataPager extends UICommand
if (currentPage != 0)
{
buf.append("<a href='#' onclick=\"");
buf.append(generateEventScript(currentPage - 1));
buf.append(generateEventScript(currentPage - 1, hiddenFieldName));
buf.append("\">");
buf.append(Utils.buildImageTag(context, WebResources.IMAGE_PREVIOUSPAGE, 16, 16, bundle.getString(PREVIOUS_PAGE), null, imageVericalAlign, imageStyle));
buf.append("</a>");
@@ -232,7 +234,7 @@ public class UIDataPager extends UICommand
if ((dataContainer.getCurrentPage() < dataContainer.getPageCount() - 1) == true)
{
buf.append("<a href='#' onclick=\"");
buf.append(generateEventScript(currentPage + 1));
buf.append(generateEventScript(currentPage + 1, hiddenFieldName));
buf.append("\">");
buf.append(Utils.buildImageTag(context, WebResources.IMAGE_NEXTPAGE, 16, 16, bundle.getString(NEXT_PAGE), null, imageVericalAlign, imageStyle));
buf.append("</a>");
@@ -248,7 +250,7 @@ public class UIDataPager extends UICommand
if ((dataContainer.getCurrentPage() < dataContainer.getPageCount() - 1) == true)
{
buf.append("<a href='#' onclick=\"");
buf.append(generateEventScript(dataContainer.getPageCount() - 1));
buf.append(generateEventScript(dataContainer.getPageCount() - 1, hiddenFieldName));
buf.append("\">");
buf.append(Utils.buildImageTag(context, WebResources.IMAGE_LASTPAGE, 16, 16, bundle.getString(LAST_PAGE), null, imageVericalAlign, imageStyle));
buf.append("</a>");
@@ -266,17 +268,17 @@ public class UIDataPager extends UICommand
private void createClicableDigitForPage(int num, StringBuilder buf)
{
buf.append("<a href='#' onclick=\"")
.append(generateEventScript(num))
.append("\">")
.append(num + 1)
.append("</a>&nbsp;");
.append(generateEventScript(num, getHiddenFieldName()))
.append("\">")
.append(num + 1)
.append("</a>&nbsp;");
}
private void createDigitForPage(int num, StringBuilder buf)
{
buf.append("<b>")
.append(num + 1)
.append("</b>&nbsp;");
.append(num + 1)
.append("</b>&nbsp;");
}
private void encodeType0(StringBuilder buf, int currentPage, int pageCount)
@@ -555,9 +557,9 @@ public class UIDataPager extends UICommand
*
* @param page page index to generate script to jump too
*/
private String generateEventScript(int page)
private String generateEventScript(int page, String hiddenFieldName)
{
return Utils.generateFormSubmit(getFacesContext(), this, getHiddenFieldName(), Integer.toString(page));
return Utils.generateFormSubmit(getFacesContext(), this, hiddenFieldName, Integer.toString(page));
}
/**
@@ -579,31 +581,16 @@ public class UIDataPager extends UICommand
*
* @return JavaScript code
*/
private String generateInputOnkeyupScript()
private String generateInputOnkeyupScript(String pageInputId, String formClientId, String hiddenFieldName)
{
final String formClientId = Utils.getParentForm(getFacesContext(), this).getClientId(getFacesContext());
final StringBuilder script = new StringBuilder(128);
script.append("function validateAndSubmit(e)");
script.append("{");
script.append(" var keycode;");
script.append(" if (window.event) keycode = window.event.keyCode;");
script.append(" else if (e) keycode = e.which;");
script.append(" if (keycode == 13)");
script.append(" {");
script.append(" var inputControl = $('").append(getPageInputId()).append("');");
script.append(" var dialogForm = $('dialog');");
script.append(" if (dialogForm) {dialogForm.removeProperty('onsubmit');}");
script.append(" var val = parseInt(inputControl.value);");
script.append(" if (val == 'NaN' || document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("']==undefined)");
script.append(" { inputControl.value = 1; return false; }");
script.append(" else");
script.append(" { val = (val-1)>=0 ? val-1 : 0; ");
script.append(" document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("'].value=val;");
script.append(" document.forms['").append(formClientId).append("'].submit(); return false;");
script.append(" }");
script.append(" }");
script.append(" return true;");
script.append("}; return validateAndSubmit(event);");
script.append("return validateAndSubmit(event,'")
.append(getPageInputId())
.append("','")
.append(formClientId)
.append("','")
.append(hiddenFieldName)
.append("');");
return script.toString();
}
@@ -614,21 +601,7 @@ public class UIDataPager extends UICommand
*/
private String generateInputOnkeydownScript()
{
final StringBuilder script = new StringBuilder(128);
script.append("function onlyDigits(e)");
script.append("{");
script.append(" var keycode;");
script.append(" if (window.event) keycode = window.event.keyCode;");
script.append(" else if (e) keycode = e.which;");
script.append(" var keychar = String.fromCharCode(keycode);");
script.append(" var numcheck = /\\d/;");
script.append(" var dialogForm = $('dialog');");
script.append(" if (dialogForm && keycode==13) { ");
script.append(" dialogForm.setProperty('onsubmit','return false;')");
script.append(" }");
script.append(" return keycode==13 || keycode==8 || keycode==37 || keycode==39 || keycode==46 || (keycode>=96 && keycode<=105) || numcheck.test(keychar);");
script.append("}; return onlyDigits(event);");
return script.toString();
return "return onlyDigits(event);";
}
/**
@@ -636,31 +609,16 @@ public class UIDataPager extends UICommand
* It handles only digits and some 'useful' keys.
* @return JavaScript code
*/
private String generateIE6InputOnkeydownScript()
private String generateIE6InputOnkeydownScript(String pageInputId, String formClientId, String hiddenFieldName)
{
final String formClientId = Utils.getParentForm(getFacesContext(), this).getClientId(getFacesContext());
final StringBuilder script = new StringBuilder(128);
script.append("function onlyDigits(e)");
script.append("{");
script.append(" var keycode;");
script.append(" if (window.event) keycode = window.event.keyCode;");
script.append(" else if (e) keycode = e.which;");
script.append(" var keychar = String.fromCharCode(keycode);");
script.append(" var numcheck = /\\d/;");
script.append(" if (keycode == 13)");
script.append(" {");
script.append(" var inputControl = $('").append(getPageInputId()).append("');");
script.append(" var val = parseInt(inputControl.value);");
script.append(" if (val == 'NaN' || document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("']==undefined)");
script.append(" { inputControl.value = 1; return false; }");
script.append(" else");
script.append(" { val = (val-1)>=0 ? val-1 : 0; ");
script.append(" document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("'].value=val;");
script.append(" document.forms['").append(formClientId).append("'].submit(); return false;");
script.append(" }");
script.append(" }");
script.append(" return keycode==13 || keycode==8 || keycode==37 || keycode==39 || keycode==46 || (keycode>=96 && keycode<=105) || numcheck.test(keychar);");
script.append("}; return onlyDigits(event);");
script.append("return onlyDigitsIE6(event,'")
.append(getPageInputId())
.append("','")
.append(formClientId)
.append("','")
.append(hiddenFieldName)
.append("');");
return script.toString();
}

View File

@@ -61,8 +61,6 @@ public class PageTag extends TagSupport
"/scripts/menu.js",
// webdav javascript
"/scripts/webdav.js",
// functionality for window.onload
"/scripts/onload.js",
// base yahoo file
"/scripts/ajax/yahoo/yahoo/yahoo-min.js",
// io handling (AJAX)