Several bugfixes for the workflow widget

pull/10/head
Jens Pelzetter 2021-05-03 20:40:06 +02:00
parent 2be640f8d4
commit d6a0874654
6 changed files with 70 additions and 35 deletions

View File

@ -243,6 +243,7 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
); );
final String docPath = Optional final String docPath = Optional
.ofNullable(documentPath) .ofNullable(documentPath)
.map(this::withoutLeadingSlash)
.orElseThrow( .orElseThrow(
() -> new WebApplicationException( () -> new WebApplicationException(
String.format( String.format(
@ -377,4 +378,11 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
.orElse(""); .orElse("");
} }
private String withoutLeadingSlash(final String path) {
if (path.startsWith("/")) {
return path.substring(1);
} else {
return path;
}
}
} }

View File

@ -128,7 +128,7 @@ public class DocumentWorkflowController {
* @return A redirect to the {@code returnUrl}. * @return A redirect to the {@code returnUrl}.
*/ */
@POST @POST
@Path("/tasks/${taskIdentifier}/@lock") @Path("/tasks/{taskIdentifier}/@lock")
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String lockTask( public String lockTask(
@ -185,7 +185,7 @@ public class DocumentWorkflowController {
* @return A redirect to the {@code returnUrl}. * @return A redirect to the {@code returnUrl}.
*/ */
@POST @POST
@Path("/tasks/${taskIdentifier}/@unlock") @Path("/tasks/{taskIdentifier}/@unlock")
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String unlockTask( public String unlockTask(
@ -243,7 +243,7 @@ public class DocumentWorkflowController {
* @return A redirect to the {@code returnUrl}. * @return A redirect to the {@code returnUrl}.
*/ */
@POST @POST
@Path("/tasks/${taskIdentifier}/@finish") @Path("/tasks/{taskIdentifier}/@finish")
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String finishTask( public String finishTask(

View File

@ -298,6 +298,12 @@ public class SelectedDocumentModel {
.orElse(false) .orElse(false)
); );
entry.setLocked(task.isLocked()); entry.setLocked(task.isLocked());
entry.setLockedByCurrentUser(
shiro
.getUser()
.map(user -> Objects.equals(user, task.getLockingUser()))
.orElse(false)
);
return entry; return entry;
} }

View File

@ -69,6 +69,11 @@ public class TaskListEntry {
* Is the task locked? * Is the task locked?
*/ */
private boolean locked; private boolean locked;
/**
* Is the task locked by the current user?
*/
private boolean lockedByCurrentUser;
public String getTaskUuid() { public String getTaskUuid() {
return taskUuid; return taskUuid;
@ -126,4 +131,14 @@ public class TaskListEntry {
this.locked = locked; this.locked = locked;
} }
public boolean isLockedByCurrentUser() {
return lockedByCurrentUser;
}
public void setLockedByCurrentUser(final boolean lockedByCurrentUser) {
this.lockedByCurrentUser = lockedByCurrentUser;
}
} }

View File

@ -45,59 +45,65 @@
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/@start" <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/@start"
method="post"> method="post">
<input name="returnUrl" <input name="returnUrl"
type="hidden" type="hidden"
value="#{CmsArticlePropertiesStep.stepPath}" /> value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-primary" <button class="btn btn-primary"
type="submit"> type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.start']} #{CmsAdminMessages['contentsection.document.authoring.workflow.start']}
</button> </button>
</form> </form>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<c:if test="#{CmsSelectedDocumentModel.currentTask != null}"> <c:if test="#{CmsSelectedDocumentModel.currentTask != null}">
<c:choose> <c:choose>
<c:when test="#{CmsSelectedDocumentModel.currentTask.assignedToCurrentUser and CmsSelectedDocumentModel.currentTask.locked}"> <c:when test="#{(CmsSelectedDocumentModel.currentTask.assignedToCurrentUser or CmsSelectedDocumentModel.currentTask.lockedByCurrentUser)and CmsSelectedDocumentModel.currentTask.locked}">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@unlock" <div class="d-flex">
method="post"> <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@unlock"
<input name="returnUrl" class="mr-2"
type="hidden" method="post">
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" /> <input name="returnUrl"
<button class="btn btn-secondary btn-sm" type="hidden"
type="submit"> value="#{CmsArticlePropertiesStep.stepPath}" />
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.release']} <button class="btn btn-secondary btn-sm"
</button> type="submit">
</form> #{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.release']}
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@finish" </button>
method="post"> </form>
<input name="returnUrl" <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@finish"
type="hidden" class="ml-2"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" /> method="post">
<button class="btn btn-secondary btn-sm" <input name="returnUrl"
type="submit"> type="hidden"
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.finish']} value="#{CmsArticlePropertiesStep.stepPath}" />
</button> <button class="btn btn-secondary btn-sm"
</form> type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.finish']}
</button>
</form>
</div>
</c:when> </c:when>
<c:when test="#{CmsSelectedDocumentModel.currentTask.locked and CmsSelectedDocumentModel.canChangeWorkflow}"> <c:when test="#{CmsSelectedDocumentModel.currentTask.locked and CmsSelectedDocumentModel.canChangeWorkflow}">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@lock" <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@lock"
method="post"> method="post">
<input name="returnUrl" <input name="returnUrl"
type="hidden" type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" /> value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm" <button class="btn btn-secondary btn-sm"
type="submit"> type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.takeover']} #{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.takeover']}
</button> </button>
</form> </form>
</c:when> </c:when>
<c:when test="#{CmsSelectedDocumentModel.currentTask.assignedToCurrentUser or CmsSelectedDocumentModel.canChangeWorkflow}"> <c:when test="#{CmsSelectedDocumentModel.currentTask.assignedToCurrentUser or CmsSelectedDocumentModel.canChangeWorkflow}">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@lock"> <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@lock"
method="post">
<input name="returnUrl" <input name="returnUrl"
type="hidden" type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" /> value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm" <button class="btn btn-secondary btn-sm"
type="button"> type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']} #{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']}
</button> </button>
</form> </form>

View File

@ -220,7 +220,7 @@ public class AssignableTaskManager implements Serializable {
return query.getResultList(); return query.getResultList();
} }
/** /**
* Finishes a {@link AssignableTask}. * Finishes a {@link AssignableTask}.
* *