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
.ofNullable(documentPath)
.map(this::withoutLeadingSlash)
.orElseThrow(
() -> new WebApplicationException(
String.format(
@ -377,4 +378,11 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
.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}.
*/
@POST
@Path("/tasks/${taskIdentifier}/@lock")
@Path("/tasks/{taskIdentifier}/@lock")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String lockTask(
@ -185,7 +185,7 @@ public class DocumentWorkflowController {
* @return A redirect to the {@code returnUrl}.
*/
@POST
@Path("/tasks/${taskIdentifier}/@unlock")
@Path("/tasks/{taskIdentifier}/@unlock")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String unlockTask(
@ -243,7 +243,7 @@ public class DocumentWorkflowController {
* @return A redirect to the {@code returnUrl}.
*/
@POST
@Path("/tasks/${taskIdentifier}/@finish")
@Path("/tasks/{taskIdentifier}/@finish")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String finishTask(

View File

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

View File

@ -70,6 +70,11 @@ public class TaskListEntry {
*/
private boolean locked;
/**
* Is the task locked by the current user?
*/
private boolean lockedByCurrentUser;
public String getTaskUuid() {
return taskUuid;
}
@ -126,4 +131,14 @@ public class TaskListEntry {
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"
method="post">
<input name="returnUrl"
type="hidden"
value="#{CmsArticlePropertiesStep.stepPath}" />
type="hidden"
value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-primary"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.start']}
</button>
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.start']}
</button>
</form>
</c:otherwise>
</c:choose>
<c:if test="#{CmsSelectedDocumentModel.currentTask != null}">
<c:choose>
<c:when test="#{CmsSelectedDocumentModel.currentTask.assignedToCurrentUser and CmsSelectedDocumentModel.currentTask.locked}">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@unlock"
method="post">
<input name="returnUrl"
type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" />
<button class="btn btn-secondary btn-sm"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.release']}
</button>
</form>
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@finish"
method="post">
<input name="returnUrl"
type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" />
<button class="btn btn-secondary btn-sm"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.finish']}
</button>
</form>
<c:when test="#{(CmsSelectedDocumentModel.currentTask.assignedToCurrentUser or CmsSelectedDocumentModel.currentTask.lockedByCurrentUser)and CmsSelectedDocumentModel.currentTask.locked}">
<div class="d-flex">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@unlock"
class="mr-2"
method="post">
<input name="returnUrl"
type="hidden"
value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.release']}
</button>
</form>
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@workflow/tasks/UUID-#{CmsSelectedDocumentModel.currentTask.taskUuid}/@finish"
class="ml-2"
method="post">
<input name="returnUrl"
type="hidden"
value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.finish']}
</button>
</form>
</div>
</c:when>
<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"
method="post">
<input name="returnUrl"
type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" />
value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm"
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.takeover']}
</button>
</form>
</c:when>
<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"
type="hidden"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{authoringStep}" />
value="#{CmsArticlePropertiesStep.stepPath}" />
<button class="btn btn-secondary btn-sm"
type="button">
type="submit">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']}
</button>
</form>