Skip to content

Commit

Permalink
Merge pull request #4774 from effective-webwork/preset-duplicate-titles
Browse files Browse the repository at this point in the history
Preset titles of duplicated templates and projects
  • Loading branch information
Kathrin-Huber authored Oct 20, 2021
2 parents 1a752ed + 9cca3b4 commit c38954c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private List<TemplateDTO> 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());
Expand Down
6 changes: 3 additions & 3 deletions Kitodo/src/main/webapp/pages/projectEdit.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
</script>
<h3 id="headerText">
<h:outputText value="#{msgs.editProject} (#{ProjectForm.project.title})"
rendered="#{not empty ProjectForm.project.title}"/>
rendered="#{ProjectForm.project.id ne null}"/>
<h:outputText value="#{msgs.newProject}"
rendered="#{empty ProjectForm.project.title and empty ProjectForm.project.folders}"/>
rendered="#{ProjectForm.project.id eq null and empty ProjectForm.project.title}"/>
<h:outputText value="#{msgs.duplicateProject}"
rendered="#{empty ProjectForm.project.title and not empty ProjectForm.project.folders}"/>
rendered="#{ProjectForm.project.id eq null and not empty ProjectForm.project.title}"/>
</h3>
<p:commandButton id="save"
widgetVar="save"
Expand Down
6 changes: 3 additions & 3 deletions Kitodo/src/main/webapp/pages/templateEdit.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

<!--@elvariable id="isCreateMode" type="boolean"-->
<ui:param name="isCreateMode"
value="#{TemplateForm.template.title eq '' and empty TemplateForm.template.docket and SecurityAccessController.hasAuthorityToAddTemplate()}"/>
value="#{TemplateForm.template.id eq null and empty TemplateForm.template.title and SecurityAccessController.hasAuthorityToAddTemplate()}"/>
<!--@elvariable id="isDuplicateMode" type="boolean"-->
<ui:param name="isDuplicateMode"
value="#{TemplateForm.template.title eq '' and not empty TemplateForm.template.docket and SecurityAccessController.hasAuthorityToAddTemplate()}"/>
value="#{TemplateForm.template.id eq null and not empty TemplateForm.template.title and SecurityAccessController.hasAuthorityToAddTemplate()}"/>
<!--@elvariable id="isEditMode" type="boolean"-->
<ui:param name="isEditMode"
value="#{not TemplateForm.currentTemplateInUse and TemplateForm.template.title ne '' and not empty TemplateForm.template.docket and SecurityAccessController.hasAuthorityToEditTemplate()}"/>
value="#{TemplateForm.template.id ne null and not TemplateForm.currentTemplateInUse and SecurityAccessController.hasAuthorityToEditTemplate()}"/>
<!--@elvariable id="isViewMode" type="boolean"-->
<ui:param name="isViewMode"
value="#{not isEditMode and not isDuplicateMode and not isCreateMode and SecurityAccessController.hasAuthorityToViewTemplate()}"/>
Expand Down

0 comments on commit c38954c

Please sign in to comment.