add UploadNewVersionDialog

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8177 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Logneon
2008-02-05 11:47:32 +00:00
parent 2f5b69ea58
commit 01f710efe4
5 changed files with 276 additions and 1 deletions

View File

@@ -284,6 +284,8 @@ today=Today
reset=Reset reset=Reset
label=Label label=Label
edit_doc_offline=Edit offline edit_doc_offline=Edit offline
upload_new_version=Upload new version
done_editing_file=I am done editing this file
# Properties # Properties
username=User Name username=User Name

View File

@@ -225,6 +225,22 @@
<param name="id">#{actionContext.id}</param> <param name="id">#{actionContext.id}</param>
</params> </params>
</action> </action>
<!-- Upload new version of document-->
<action id="upload_new_version">
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.UpdateDocEvaluator</evaluator>
<label-id>upload_new_version</label-id>
<image>/images/icons/update.gif</image>
<action-listener>#{CheckinCheckoutDialog.setupContentAction}</action-listener>
<action>dialog:uploadVersion</action>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- 'Approve' workflow step for document --> <!-- 'Approve' workflow step for document -->
<action id="approve_doc"> <action id="approve_doc">
@@ -928,6 +944,7 @@
<show-link>false</show-link> <show-link>false</show-link>
<style-class>inlineAction</style-class> <style-class>inlineAction</style-class>
<action idref="upload_new_version" />
<action idref="edit_doc_offline" /> <action idref="edit_doc_offline" />
<action idref="edit_doc_http" /> <action idref="edit_doc_http" />
<action idref="edit_doc_webdav" /> <action idref="edit_doc_webdav" />

View File

@@ -550,7 +550,10 @@
<dialog name="manageContentUsers" page="/jsp/roles/manage-content-users.jsp" managed-bean="ContentUsersBean" <dialog name="manageContentUsers" page="/jsp/roles/manage-content-users.jsp" managed-bean="ContentUsersBean"
icon="/images/icons/users_large.gif" title-id="manage_content_users" description-id="manage_content_users_description" show-ok-button="false" icon="/images/icons/users_large.gif" title-id="manage_content_users" description-id="manage_content_users_description" show-ok-button="false"
actions-config-id="invite_content_user_menu" error-message-id="empty_message"/> actions-config-id="invite_content_user_menu" error-message-id="empty_message"/>
<dialog name="uploadVersion" page="/jsp/content/upload-new-version.jsp" managed-bean="UploadNewVersionDialog"
icon="/images/icons/update_large.gif" title-id="upload_new_version_of" />
</dialogs> </dialogs>
</config> </config>

View File

@@ -0,0 +1,98 @@
package org.alfresco.web.bean.coci;
import java.io.Serializable;
import java.util.Map;
import java.util.StringTokenizer;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
public class UploadNewVersionDialog extends CheckinCheckoutDialog
{
private final static String MSG_DONE = "done";
private final static String MSG_UPLOAD_NEW_VERSION = "upload_new_version";
private final static String MSG_OF = "of";
private boolean finishedEditing;
public void setFinishedEditing(boolean finished)
{
this.finishedEditing = finished;
}
public boolean isFinishedEditing()
{
return finishedEditing;
}
/**
* @return Returns label for new version with major changes
*/
public String getMajorNewVersionLabel()
{
String label = getCurrentVersionLabel();
StringTokenizer st = new StringTokenizer(label, ".");
return (Integer.valueOf(st.nextToken()) + 1) + ".0";
}
/**
* @return Returns label for new version with minor changes
*/
public String getMinorNewVersionLabel()
{
String label = getCurrentVersionLabel();
StringTokenizer st = new StringTokenizer(label, ".");
return st.nextToken() + "." + (Integer.valueOf(st.nextToken()) + 1);
}
/**
* @return version label for source node for working copy.
*/
private String getCurrentVersionLabel()
{
NodeRef workingCopyNodeRef = property.getDocument().getNodeRef();
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
{
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
NodeRef nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
Version curVersion = property.getVersionQueryService().getCurrentVersion(nodeRef);
return curVersion.getVersionLabel();
}
return null;
}
@Override
public boolean getFinishButtonDisabled()
{
return property.getFile() == null;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DONE);
}
@Override
public String getContainerTitle()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPLOAD_NEW_VERSION) + " " + Application.getMessage(FacesContext.getCurrentInstance(), MSG_OF) + " '"
+ property.getDocument().getName() + "'";
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
property.setKeepCheckedOut(!finishedEditing);
return checkinFileOK(context, outcome);
}
}

View File

@@ -0,0 +1,155 @@
<%--
* 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"
--%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a"%>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r"%>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator"%>
<%@ page import="org.alfresco.web.bean.coci.UploadNewVersionDialog"%>
<%@ page import="org.alfresco.web.app.servlet.FacesHelper"%>
<%@ page import="javax.faces.context.FacesContext"%>
<%@ page buffer="32kb" contentType="text/html;charset=UTF-8"%>
<%
boolean fileUploaded = false;
UploadNewVersionDialog dialog = (UploadNewVersionDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "UploadNewVersionDialog");
if (dialog != null && dialog.getFileName() != null)
{
fileUploaded = true;
}
%>
<f:verbatim>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/validation.js"> </script>
<%
if (fileUploaded)
{
PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc");
out.write("<img alt='' align='absmiddle' src='");
out.write(request.getContextPath());
out.write("/images/icons/info_icon.gif' />&nbsp;&nbsp;");
out.write(dialog.getFileUploadSuccessMsg());
PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner");
out.write("<div style='padding:2px;'></div>");
}
%>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
</f:verbatim>
<a:booleanEvaluator value="#{empty DialogManager.bean.fileName}" ><f:verbatim>
<tr>
<td class="wizardSectionHeading"></f:verbatim><h:outputText value="#{msg.local_copy_location}" /><f:verbatim></td>
</tr>
<tr>
<td></f:verbatim>
<h:panelGrid id="upload_panel" columns="2" cellpadding="2" cellspacing="2" border="0" width="100%" columnClasses="panelGridLabelColumn,panelGridValueColumn" >
<h:outputText value="#{msg.locate_content_upload}" style="padding-left:8px"/>
<f:verbatim/>
<h:outputText id="out_schema" value="#{msg.file_location}:" style="padding-left:8px" />
<h:column id="upload_empty" rendered="#{empty DialogManager.bean.fileName}">
<r:upload id="uploader" value="#{DialogManager.bean.fileName}" framework="dialog"/>
</h:column>
<h:column id="upload_not_empty" rendered="#{!empty DialogManager.bean.fileName}">
<h:outputText id="upload_name" value="#{DialogManager.bean.fileName}" style="padding-right:8px"/>
<a:actionLink id="upload_remove" image="/images/icons/delete.gif" value="#{msg.remove}" action="#{DialogManager.bean.removeUploadedFile}" showLink="false"/>
</h:column>
</h:panelGrid>
<f:verbatim>
</td>
</tr>
</f:verbatim>
</a:booleanEvaluator>
<f:verbatim>
<tr>
<td>
</f:verbatim>
<a:booleanEvaluator value="#{DialogManager.bean.versionable && !empty DialogManager.bean.fileName}" >
<f:verbatim>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr>
<td class="wizardSectionHeading"> </f:verbatim>
<h:outputText value="#{msg.version_info}" /> <f:verbatim>
</td>
</tr>
<tr>
<td> </f:verbatim>
<h:outputText value="#{msg.new_version_has}" escape="false" /> <f:verbatim>
</td>
</tr>
<tr>
<td> </f:verbatim>
<h:selectOneRadio id="vvvv" value="#{CCProperties.minorChange}" required="true" layout="pageDirection" rendered="#{DialogManager.bean.versionable && !empty DialogManager.bean.fileName}">
<f:selectItem itemValue="#{true}" itemLabel="#{msg.minor_changes} (#{DialogManager.bean.minorNewVersionLabel})" />
<f:selectItem itemValue="#{false}" itemLabel="#{msg.major_changes} (#{DialogManager.bean.majorNewVersionLabel})" />
</h:selectOneRadio>
<h:message for="vvvv"></h:message>
<f:verbatim>
</span> <br/>
</td>
</tr>
<tr>
<td> </f:verbatim>
<h:outputText value="#{msg.version_notes}" /> <f:verbatim>
</td>
</tr>
<tr>
<td> </f:verbatim>
<h:inputTextarea value="#{CCProperties.versionNotes}" rows="4" cols="50" /> <f:verbatim>
</span></td>
</tr>
<tr>
<td class="paddingRow"></td>
</tr>
</table> </f:verbatim>
</a:booleanEvaluator>
<f:verbatim>
</td>
</tr>
</f:verbatim>
<a:booleanEvaluator value="#{!empty DialogManager.bean.fileName}">
<f:verbatim>
<tr>
<td class="wizardSectionHeading"></f:verbatim><h:outputText value="#{msg.other_options}" /><f:verbatim></td>
</tr>
<tr>
<td>
</f:verbatim>
<h:selectBooleanCheckbox value="#{DialogManager.bean.finishedEditing}"/> <h:outputText value="#{msg.done_editing_file}"/>
<f:verbatim>
</td>
</tr>
</f:verbatim>
</a:booleanEvaluator>
<f:verbatim>
</table>
</f:verbatim>