Some bugfixes

Former-commit-id: 95af9a5f45798e949634b352b3a264353012714b
pull/10/head
Jens Pelzetter 2021-03-08 21:04:36 +01:00
parent e3df86ca21
commit 69f246f8a1
7 changed files with 49 additions and 12 deletions

View File

@ -11,6 +11,7 @@ import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.workflow.CircularTaskDependencyException; import org.libreccm.workflow.CircularTaskDependencyException;
import org.libreccm.workflow.Task; import org.libreccm.workflow.Task;
import org.libreccm.workflow.TaskDependency;
import org.libreccm.workflow.TaskManager; import org.libreccm.workflow.TaskManager;
import org.libreccm.workflow.TaskRepository; import org.libreccm.workflow.TaskRepository;
import org.libreccm.workflow.Workflow; import org.libreccm.workflow.Workflow;
@ -19,6 +20,7 @@ import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionManager; import org.librecms.contentsection.ContentSectionManager;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional; import java.util.Optional;
@ -757,7 +759,6 @@ public class ConfigurationWorkflowController {
} }
final Task task = taskResult.get(); final Task task = taskResult.get();
taskManager.removeTask(workflow, task); taskManager.removeTask(workflow, task);
taskRepo.delete(task);
return String.format( return String.format(
"redirect:/%s/configuration/workflows/%s", "redirect:/%s/configuration/workflows/%s",
@ -1291,6 +1292,7 @@ public class ConfigurationWorkflowController {
workflow.getDescription() workflow.getDescription()
) )
); );
model.setHasTasks(!workflow.getTasks().isEmpty());
model.setName( model.setName(
globalizationHelper.getValueFromLocalizedString(workflow.getName()) globalizationHelper.getValueFromLocalizedString(workflow.getName())
); );
@ -1309,6 +1311,10 @@ public class ConfigurationWorkflowController {
task.getDescription() task.getDescription()
) )
); );
model.setHasDependencies(
!task.getBlockedTasks().isEmpty()
|| !task.getBlockingTasks().isEmpty()
);
model.setLabel( model.setLabel(
globalizationHelper.getValueFromLocalizedString( globalizationHelper.getValueFromLocalizedString(
task.getLabel() task.getLabel()

View File

@ -24,6 +24,8 @@ public class WorkflowTaskTemplateListModel {
private String label; private String label;
private String description; private String description;
private boolean hasDependencies;
public long getTaskId() { public long getTaskId() {
return taskId; return taskId;
@ -57,4 +59,14 @@ public class WorkflowTaskTemplateListModel {
this.description = description; this.description = description;
} }
public boolean getHasDependencies() {
return hasDependencies;
}
public void setHasDependencies(final boolean hasDependencies) {
this.hasDependencies = hasDependencies;
}
} }

View File

@ -19,6 +19,8 @@ public class WorkflowTemplateListModel {
private String description; private String description;
private boolean hasTasks;
public long getWorkflowId() { public long getWorkflowId() {
return workflowId; return workflowId;
} }
@ -51,4 +53,12 @@ public class WorkflowTemplateListModel {
this.description = description; this.description = description;
} }
public boolean getHasTasks() {
return hasTasks;
}
public void setHasTasks(boolean hasTasks) {
this.hasTasks = hasTasks;
}
} }

View File

@ -229,15 +229,17 @@
</div> </div>
</td> </td>
<td class="del-col"> <td class="del-col">
<libreccm:deleteDialog <c:if test="#{!task.hasDependencies}">
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/configuration/workflows/UUID-#{SelectedWorkflowTemplateModel.uuid}/tasks/UUID-#{task.uuid}/@remove" <libreccm:deleteDialog
buttonText="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.button.label']}" actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/configuration/workflows/UUID-#{SelectedWorkflowTemplateModel.uuid}/tasks/UUID-#{task.uuid}/@remove"
cancelLabel="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.close']}" buttonText="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.button.label']}"
confirmLabel="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.confirm']}" cancelLabel="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.close']}"
dialogId="task-#{task.taskId}-remove-dialog" confirmLabel="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.confirm']}"
dialogTitle="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.title']}" dialogId="task-#{task.taskId}-remove-dialog"
message="#{CmsAdminMessages.getMessage('contentsection.configuration.workflow.tasks.remove.dialog.message', [ContentSectionModel.sectionName, SelectedWorkflowTemplateModel.displayName, task.label])}" dialogTitle="#{CmsAdminMessages['contentsection.configuration.workflow.tasks.remove.dialog.title']}"
/> message="#{CmsAdminMessages.getMessage('contentsection.configuration.workflow.tasks.remove.dialog.message', [ContentSectionModel.sectionName, SelectedWorkflowTemplateModel.displayName, task.label])}"
/>
</c:if>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>

View File

@ -159,6 +159,7 @@
</div> </div>
</td> </td>
<td class="del-col"> <td class="del-col">
<c:if test="#{!workflowTemplate.hasTasks}">
<libreccm:deleteDialog <libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/configuration/workflows/UUID-#{workflowTemplate.uuid}/@delete" actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/configuration/workflows/UUID-#{workflowTemplate.uuid}/@delete"
buttonText="#{CmsAdminMessages['contentsection.configuration.workflows.delete_button.label']}" buttonText="#{CmsAdminMessages['contentsection.configuration.workflows.delete_button.label']}"
@ -168,6 +169,7 @@
dialogTitle="#{CmsAdminMessages['contentsection.configuration.workflows.delete_dialog.title']}" dialogTitle="#{CmsAdminMessages['contentsection.configuration.workflows.delete_dialog.title']}"
message="#{CmsAdminMessages.getMessage('contentsection.configuration.workflows.delete_dialog.message', [ContentSectionModel.sectionName, workflowTemplate.name])}" message="#{CmsAdminMessages.getMessage('contentsection.configuration.workflows.delete_dialog.message', [ContentSectionModel.sectionName, workflowTemplate.name])}"
/> />
</c:if>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>

View File

@ -117,7 +117,7 @@ table.contentsection-roles-table {
table.lifecycles-table, table.lifecycles-table,
table.workflows-table, table.workflows-table,
table.workflow-tasks-table { table.wor{
td.info-col { td.info-col {
width: 3em; width: 3em;
} }

View File

@ -24,9 +24,12 @@ import org.libreccm.core.CcmObject;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import javax.transaction.Transactional;
/** /**
* Repository for {@link Workflow}s. * Repository for {@link Workflow}s.
* *
@ -36,7 +39,7 @@ import java.util.UUID;
public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow> { public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow> {
private static final long serialVersionUID = -8811728904958517569L; private static final long serialVersionUID = -8811728904958517569L;
@Override @Override
public Class<Workflow> getEntityClass() { public Class<Workflow> getEntityClass() {
return Workflow.class; return Workflow.class;
@ -62,6 +65,8 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
super.initNewEntity(workflow); super.initNewEntity(workflow);
workflow.setUuid(UUID.randomUUID().toString()); workflow.setUuid(UUID.randomUUID().toString());
} }
/** /**
* Find a {@link Workflow} by its UUID. * Find a {@link Workflow} by its UUID.