Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz880442 - Allow project maintainers to delete a Document.
Browse files Browse the repository at this point in the history
Document is only made obsolete, same as with the REST service.
  • Loading branch information
Carlos Munoz committed Nov 27, 2012
1 parent 1a6d8aa commit 25a24cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Expand Up @@ -198,6 +198,14 @@ public TranslationStatistics getTransUnitForDocument(HDocument doc)
}
}

@Restrict("#{projectIterationFilesAction.documentRemovalAllowed}")
public void deleteDocument( HDocument doc )
{
doc = documentDAO.getById( doc.getId() ); // refresh the instance
doc.setObsolete(true);
documentDAO.makePersistent(doc);
}

@Restrict("#{projectIterationFilesAction.fileUploadAllowed}")
public String uploadTranslationFile()
{
Expand Down Expand Up @@ -410,6 +418,12 @@ public boolean isDocumentUploadAllowed()
return isIterationActive() && identity != null && identity.hasPermission("import-template", projectIteration);
}

public boolean isDocumentRemovalAllowed()
{
// currently same permissions as uploading a document
return this.isDocumentUploadAllowed();
}

public List<HDocument> getIterationDocuments()
{
return iterationDocuments;
Expand Down
2 changes: 2 additions & 0 deletions zanata-war/src/main/resources/messages.properties
Expand Up @@ -319,8 +319,10 @@ jsf.iteration.CopyTrans.Help.ignore=This condition will not be taken into accoun
jsf.iteration.CopyTrans.Help.approve=Translation will be reused and marked as Approved if it has not been rejected or marked as fuzzy already.
jsf.iteration.CopyTrans.NoDocuments=There are no documents in this project version.
jsf.iteration.CopyTrans.Started=Translation copy started.
jsf.iteration.files.ConfirmDocDeletion=Are you sure you want to remove this Source Document?
jsf.iteration.files.ConfirmDownloadAllFiles=Your download will be prepared and may take a few minutes to complete. Is this ok?
jsf.iteration.files.ContentType=Content Type
jsf.iteration.files.DocumentDeleted=Document succesfully deleted.
jsf.iteration.files.DocumentPath=Document Path
jsf.iteration.files.dotpo=.po
jsf.iteration.files.dotpot=.pot
Expand Down
10 changes: 9 additions & 1 deletion zanata-war/src/main/webapp/WEB-INF/pages.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<pages xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd"
no-conversation-view-id="/home.xhtml" login-view-id="/account/login.xhtml">

<page view-id="*">
Expand Down Expand Up @@ -631,6 +631,14 @@
<action execute="#{breadcrumbs.addLocation('/project/view/'.concat(projectIterationFilesAction.projectSlug), projectIterationFilesAction.projectSlug)}"/>
<action execute="#{breadcrumbs.addLocation('/iteration/view/'.concat(projectIterationFilesAction.projectSlug).concat('/').concat(projectIterationFilesAction.iterationSlug), projectIterationFilesAction.iterationSlug)}"/>
<action execute="#{breadcrumbs.addLocation('', messages['jsf.SourceDocuments'])}"/>

<navigation from-action="#{projectIterationFilesAction.deleteDocument(doc)}">
<redirect view-id="/iteration/source_files.xhtml">
<message severity="INFO">#{messages['jsf.iteration.files.DocumentDeleted']}</message>
<param name="project" value="#{projectIterationFilesAction.projectSlug}"/>
<param name="iteration" value="#{projectIterationFilesAction.iterationSlug}"/>
</redirect>
</navigation>
</page>

<page view-id="/iteration/files.xhtml">
Expand Down
9 changes: 9 additions & 0 deletions zanata-war/src/main/webapp/iteration/source_files.xhtml
Expand Up @@ -103,6 +103,15 @@
</a>
</rich:column>

<rich:column rendered="#{projectIterationFilesAction.documentRemovalAllowed}" styleClass="centered">
<f:facet name="header">
#{messages['jsf.Actions']}
</f:facet>
<h:commandButton value="#{messages['jsf.Delete']}"
action="#{projectIterationFilesAction.deleteDocument(doc)}"
onclick="return confirm('#{messages['jsf.iteration.files.ConfirmDocDeletion']}')"/>
</rich:column>

<!-- TODO show stats for document across locales -->

</rich:dataTable>
Expand Down

0 comments on commit 25a24cf

Please sign in to comment.