From 9cca3b49b9f55c16764dfab43c58bed78e83603b Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Tue, 19 Oct 2021 17:31:16 +0200 Subject: [PATCH] Preset titles of duplicated templates and projects --- .../main/java/org/kitodo/production/forms/ProjectForm.java | 1 + .../main/java/org/kitodo/production/forms/TemplateForm.java | 1 + .../org/kitodo/production/services/data/ProjectService.java | 3 ++- .../kitodo/production/services/data/TemplateService.java | 2 +- Kitodo/src/main/webapp/pages/projectEdit.xhtml | 6 +++--- Kitodo/src/main/webapp/pages/templateEdit.xhtml | 6 +++--- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java index e6c9812834e..ed72ec26c47 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java @@ -210,6 +210,7 @@ public String duplicate(Integer itemId) { try { this.baseProject = ServiceManager.getProjectService().getById(itemId); this.project = ServiceManager.getProjectService().duplicateProject(baseProject); + this.setSaveDisabled(false); return projectEditPath + "&referer=projects"; } catch (DAOException e) { Helper.setErrorMessage(ERROR_DUPLICATE, new Object[] {ObjectType.PROJECT.getTranslationSingular() }, logger, diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java index adb0099eab0..c7b5afab482 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java @@ -111,6 +111,7 @@ public String duplicate(Integer itemId) { this.template = ServiceManager.getTemplateService().duplicateTemplate(baseTemplate); this.assignedProjects.clear(); this.assignedProjects.addAll(template.getProjects()); + this.setSaveDisabled(false); return templateEditPath; } catch (DAOException e) { Helper.setErrorMessage(ERROR_DUPLICATE, new Object[] {ObjectType.TEMPLATE.getTranslationSingular() }, diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java index 4c9edbb2e3d..413379b7312 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java @@ -45,6 +45,7 @@ import org.kitodo.production.dto.ClientDTO; import org.kitodo.production.dto.ProjectDTO; import org.kitodo.production.dto.TemplateDTO; +import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.ClientSearchService; import org.primefaces.model.SortOrder; @@ -258,7 +259,7 @@ public boolean isProjectComplete(Project project) { public Project duplicateProject(Project baseProject) { Project duplicatedProject = new Project(); - // project title is intentionally not duplicated + duplicatedProject.setTitle(baseProject.getTitle() + "_" + Helper.generateRandomString(3)); duplicatedProject.setClient(baseProject.getClient()); duplicatedProject.setStartDate(baseProject.getStartDate()); duplicatedProject.setEndDate(baseProject.getEndDate()); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java index aca54bdfafe..aa88144ec02 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java @@ -160,7 +160,7 @@ private List findAvailableForAssignToUser(Integer projectId) throws public Template duplicateTemplate(Template baseTemplate) { Template duplicatedTemplate = new Template(); - // Template _title_ should explicitly _not_ be duplicated! + duplicatedTemplate.setTitle(baseTemplate.getTitle() + "_" + Helper.generateRandomString(3)); duplicatedTemplate.setCreationDate(new Date()); duplicatedTemplate.setClient(baseTemplate.getClient()); duplicatedTemplate.setDocket(baseTemplate.getDocket()); diff --git a/Kitodo/src/main/webapp/pages/projectEdit.xhtml b/Kitodo/src/main/webapp/pages/projectEdit.xhtml index 20d06b46936..de5df3cf050 100644 --- a/Kitodo/src/main/webapp/pages/projectEdit.xhtml +++ b/Kitodo/src/main/webapp/pages/projectEdit.xhtml @@ -33,11 +33,11 @@

+ rendered="#{ProjectForm.project.id ne null}"/> + rendered="#{ProjectForm.project.id eq null and empty ProjectForm.project.title}"/> + rendered="#{ProjectForm.project.id eq null and not empty ProjectForm.project.title}"/>

+ value="#{TemplateForm.template.id eq null and empty TemplateForm.template.title and SecurityAccessController.hasAuthorityToAddTemplate()}"/> + value="#{TemplateForm.template.id eq null and not empty TemplateForm.template.title and SecurityAccessController.hasAuthorityToAddTemplate()}"/> + value="#{TemplateForm.template.id ne null and not TemplateForm.currentTemplateInUse and SecurityAccessController.hasAuthorityToEditTemplate()}"/>