From 61ce2c67f31c5282a313ff638278db88ce1c75eb Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 14 Mar 2006 17:32:11 +0000 Subject: [PATCH] . Improvements to the UI for email template selection in the Rule/Action dialogs - Also allows preview of an email template so the user has an idea what they have selected . Much improved screen layout and better default for Invite Users notification dialogs - as above, after design session with Linton this morning git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2545 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 11 +- .../web/bean/wizard/BaseActionWizard.java | 66 +++++++++- .../web/bean/wizard/InviteUsersWizard.java | 113 +++++++++++------- .../jsp/wizard/create-action/action-email.jsp | 81 +++++++------ .../wizard/invite-content-users/notify.jsp | 43 +++---- source/web/jsp/wizard/invite-users/notify.jsp | 43 +++---- .../web/jsp/wizard/new-rule/action-email.jsp | 81 +++++++------ 7 files changed, 266 insertions(+), 172 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 6ba8856be8..b358b04810 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -675,9 +675,7 @@ action_copy=Copy to action_extract_metadata=Extract metadata from content action_move=Move to action_mail=Send email to -action_mail_message_text=Enter message text -action_mail_template_text=Or select an email template for the message body -action_mail_template=Template +action_mail_template=Use Template action_check_in=Check in content as ''{0}'' with comment ''{1}'' action_check_out=Check out content to action_set_property_value=Sets property @@ -689,7 +687,12 @@ encoding=Encoding encoding_utf8=UTF-8 rule_type=Rule Type rule_background_info=If this option is selected the rule will execute in the background so the results may not appear immediately. -selected_recipients=Select email recipients +select_recipients=Search for email recipients by Name or Group +selected_recipients=Selected email recipients +message_recipients=Message Recipients +email_message=Email message +insert_template=Insert Template +discard_template=Discard Template # New Space Wizard messages new_space_title=New Space Wizard diff --git a/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java b/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java index 842a41dde7..839e7f4fe0 100644 --- a/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java @@ -17,6 +17,7 @@ package org.alfresco.web.bean.wizard; import java.io.Serializable; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -50,6 +51,8 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AuthorityService; @@ -62,6 +65,7 @@ import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; +import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIGenericPicker; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -104,6 +108,7 @@ public abstract class BaseActionWizard extends AbstractWizardBean // new rule/action wizard specific properties protected boolean multiActionMode = false; protected String action; + protected String usingTemplate = null; protected ActionService actionService; protected DictionaryService dictionaryService; @@ -144,6 +149,7 @@ public abstract class BaseActionWizard extends AbstractWizardBean this.actionDescriptions = null; this.emailRecipientsDataModel = null; this.emailRecipients = new ArrayList(4); + this.usingTemplate = null; this.currentActionProperties = new HashMap(3); @@ -367,10 +373,9 @@ public abstract class BaseActionWizard extends AbstractWizardBean actionParams.put(MailActionExecuter.PARAM_FROM, from); // add the template if one was selected by the user - String template = (String)this.currentActionProperties.get(PROP_TEMPLATE); - if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false) + if (this.usingTemplate != null) { - actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), template)); + actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), this.usingTemplate)); } } else if (this.action.equals(ImporterActionExecuter.NAME)) @@ -517,6 +522,7 @@ public abstract class BaseActionWizard extends AbstractWizardBean if (templateRef != null) { this.currentActionProperties.put(PROP_TEMPLATE, templateRef.getId()); + this.usingTemplate = templateRef.getId(); } } else if (this.action.equals(ImporterActionExecuter.NAME)) @@ -1026,6 +1032,22 @@ public abstract class BaseActionWizard extends AbstractWizardBean return this.users; } + /** + * @return Returns if a template has been inserted by a user for email body. + */ + public String getUsingTemplate() + { + return this.usingTemplate; + } + + /** + * @param usingTemplate Template that has been inserted by a user for the email body. + */ + public void setUsingTemplate(String usingTemplate) + { + this.usingTemplate = usingTemplate; + } + // ------------------------------------------------------------------------------ // Action event handlers @@ -1093,6 +1115,44 @@ public abstract class BaseActionWizard extends AbstractWizardBean this.emailRecipients.remove(wrapper); } + /** + * Action handler called to insert a template as the email body + */ + public void insertTemplate(ActionEvent event) + { + String template = (String)this.currentActionProperties.get(PROP_TEMPLATE); + if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false) + { + // get the content of the template so the user can get a basic preview of it + try + { + NodeRef templateRef = new NodeRef(Repository.getStoreRef(), template); + ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService(); + ContentReader reader = cs.getReader(templateRef, ContentModel.PROP_CONTENT); + if (reader != null && reader.exists()) + { + this.currentActionProperties.put(PROP_MESSAGE, reader.getContentString()); + + usingTemplate = template; + } + } + catch (Throwable err) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); + } + } + } + + /** + * Action handler called to discard the template from the email body + */ + public void discardTemplate(ActionEvent event) + { + this.currentActionProperties.put(PROP_MESSAGE, ""); + usingTemplate = null; + } + // ------------------------------------------------------------------------------ // Inner classes diff --git a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java index 80fd96f85e..fd1429a728 100644 --- a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java @@ -34,6 +34,8 @@ import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.security.AuthorityService; @@ -100,9 +102,9 @@ public abstract class InviteUsersWizard extends AbstractWizardBean private String notify = NOTIFY_YES; private String subject = null; private String body = null; - private String internalSubject = null; private String automaticText = null; private String template = null; + private String usingTemplate = null; /** * @return a cached list of available permissions for the type being dealt with @@ -171,8 +173,8 @@ public abstract class InviteUsersWizard extends AbstractWizardBean subject = ""; body = ""; automaticText = ""; - internalSubject = null; template = null; + usingTemplate = null; } /** @@ -191,12 +193,6 @@ public abstract class InviteUsersWizard extends AbstractWizardBean tx = Repository.getUserTransaction(context); tx.begin(); - String subject = this.subject; - if (subject == null || subject.length() == 0) - { - subject = this.internalSubject; - } - User user = Application.getCurrentUser(context); String from = (String)this.nodeService.getProperty(user.getPerson(), ContentModel.PROP_EMAIL); if (from == null || from.length() == 0) @@ -287,22 +283,11 @@ public abstract class InviteUsersWizard extends AbstractWizardBean if (to != null && to.length() != 0) { - FacesContext fc = FacesContext.getCurrentInstance(); - - String body; - if (this.template == null || this.template.equals(TemplateSupportBean.NO_SELECTION) == true) + String body = this.body; + if (this.usingTemplate != null) { - String msgRole = Application.getMessage(fc, MSG_INVITED_ROLE); - String roleMessage = MessageFormat.format(msgRole, new Object[] {roleText}); + FacesContext fc = FacesContext.getCurrentInstance(); - body = this.internalSubject + "\r\n\r\n" + roleMessage + "\r\n\r\n";// + url + "\r\n\r\n"; - if (this.body != null && this.body.length() != 0) - { - body += this.body; - } - } - else - { // use template service to format the email ServiceRegistry services = Repository.getServiceRegistry(fc); Map model = DefaultModelHelper.buildDefaultModel( @@ -310,13 +295,13 @@ public abstract class InviteUsersWizard extends AbstractWizardBean model.put("role", roleText); model.put("space", new TemplateNode(node, Repository.getServiceRegistry(fc), null)); - NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template); + NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.usingTemplate); body = services.getTemplateService().processTemplate("freemarker", templateRef.toString(), model); } SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(to); - simpleMailMessage.setSubject(subject); + simpleMailMessage.setSubject(this.subject); simpleMailMessage.setText(body); simpleMailMessage.setFrom(from); @@ -555,6 +540,43 @@ public abstract class InviteUsersWizard extends AbstractWizardBean return roles; } + /** + * Action handler called to insert a template as the email body + */ + public void insertTemplate(ActionEvent event) + { + if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false) + { + // get the content of the template so the user can get a basic preview of it + try + { + NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template); + ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService(); + ContentReader reader = cs.getReader(templateRef, ContentModel.PROP_CONTENT); + if (reader != null && reader.exists()) + { + this.body = reader.getContentString(); + + this.usingTemplate = this.template; + } + } + catch (Throwable err) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); + } + } + } + + /** + * Action handler called to discard the template from the email body + */ + public void discardTemplate(ActionEvent event) + { + this.body = this.automaticText; + usingTemplate = null; + } + /** * @return Returns the notify listbox selection. */ @@ -570,22 +592,6 @@ public abstract class InviteUsersWizard extends AbstractWizardBean { this.notify = notify; } - - /** - * @return Returns the automaticText. - */ - public String getAutomaticText() - { - return this.automaticText; - } - - /** - * @param automaticText The automaticText to set. - */ - public void setAutomaticText(String automaticText) - { - this.automaticText = automaticText; - } /** * @return Returns the email body text. @@ -634,6 +640,22 @@ public abstract class InviteUsersWizard extends AbstractWizardBean { this.template = template; } + + /** + * @return Returns if a template has been inserted by a user for email body. + */ + public String getUsingTemplate() + { + return this.usingTemplate; + } + + /** + * @param usingTemplate Template that has been inserted by a user for the email body. + */ + public void setUsingTemplate(String usingTemplate) + { + this.usingTemplate = usingTemplate; + } /** * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription() @@ -725,7 +747,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean { FacesContext context = FacesContext.getCurrentInstance(); - // prepare automatic text for email and screen + // prepare automatic text for email and display StringBuilder buf = new StringBuilder(256); String personName = Application.getCurrentUser(context).getFullName(getNodeService()); @@ -736,9 +758,11 @@ public abstract class InviteUsersWizard extends AbstractWizardBean path + '/' + node.getName(), personName}) ); - this.internalSubject = buf.toString(); + // default the subject line to an informative message + this.subject = buf.toString(); - buf.append("
"); + // add the rest of the automatic body text + buf.append("\r\n\r\n"); String msgRole = Application.getMessage(context, MSG_INVITED_ROLE); String roleText; @@ -755,6 +779,9 @@ public abstract class InviteUsersWizard extends AbstractWizardBean buf.append(roleText); this.automaticText = buf.toString(); + + // default the body content to this text + this.body = this.automaticText; } return outcome; diff --git a/source/web/jsp/wizard/create-action/action-email.jsp b/source/web/jsp/wizard/create-action/action-email.jsp index 4fc2a9523f..2537e96721 100644 --- a/source/web/jsp/wizard/create-action/action-email.jsp +++ b/source/web/jsp/wizard/create-action/action-email.jsp @@ -140,51 +140,22 @@ + <%-- Select the email receipients --%> + + 1. - : - -  * - - - - - - - : - - - - - - - - : - - <%-- Templates drop-down selector --%> - - - - - - - - - - - <%-- Picker to select Users/Groups --%> - + <%-- Generic Picker to select Users/Groups --%> + + 2. - : - + + <%-- Enter the message subject and body --%> + + + + : + +  * + + + + + + + + + + + + +
: + <%-- Templates drop-down selector --%> + + + +
+ + + + + : + + + + + diff --git a/source/web/jsp/wizard/invite-content-users/notify.jsp b/source/web/jsp/wizard/invite-content-users/notify.jsp index 9d51686c15..daf88c4a7f 100644 --- a/source/web/jsp/wizard/invite-content-users/notify.jsp +++ b/source/web/jsp/wizard/invite-content-users/notify.jsp @@ -129,46 +129,39 @@ + <%-- Enter the message subject and body --%> + - : + : - +  * - - - : - - - - - - - - + + - <%-- template selector --%> - - - + diff --git a/source/web/jsp/wizard/invite-users/notify.jsp b/source/web/jsp/wizard/invite-users/notify.jsp index 6d2305c325..02046b0fa8 100644 --- a/source/web/jsp/wizard/invite-users/notify.jsp +++ b/source/web/jsp/wizard/invite-users/notify.jsp @@ -129,46 +129,39 @@ + <%-- Enter the message subject and body --%> + - + - - - - - - -
+ + - + +
: - : - - + <%-- Templates drop-down selector --%> + + +
:: - <%-- Email templates drop-down selector --%> - - - +
:: - +  *
: - -
- - + + - <%-- template selector --%> - - - + diff --git a/source/web/jsp/wizard/new-rule/action-email.jsp b/source/web/jsp/wizard/new-rule/action-email.jsp index 15a01c4856..d9f2a3ee00 100644 --- a/source/web/jsp/wizard/new-rule/action-email.jsp +++ b/source/web/jsp/wizard/new-rule/action-email.jsp @@ -126,51 +126,22 @@ + <%-- Select the email receipients --%> + + - - - - - - - - - - - - - - - - - - - - - - <%-- Picker to select Users/Groups --%> - + - - + <%-- Enter the message subject and body --%> + + + + + + + + + + + + + + + + +
+ + - + +
: - : - - + <%-- Templates drop-down selector --%> + + +
:: - <%-- Email templates drop-down selector --%> - - - +
1.
: -  * -
: - -
: - <%-- Templates drop-down selector --%> - - - -
+ <%-- Generic Picker to select Users/Groups --%> +
2.
: +
: +  * +
+ + + + + + +
: + <%-- Templates drop-down selector --%> + + + +
+
: + +
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>