diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java index affdaec..ae09658 100644 --- a/src/main/java/ru/ulstu/project/controller/ProjectController.java +++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java @@ -5,6 +5,7 @@ import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -78,6 +79,12 @@ public class ProjectController { return "/projects/project"; } + @GetMapping("/delete/{project-id}") + public String delete(@PathVariable("project-id") Integer projectId) throws IOException { + projectService.delete(projectId); + return String.format("redirect:%s", "/projects/projects"); + } + private void filterEmptyDeadlines(ProjectDto projectDto) { projectDto.setDeadlines(projectDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index a2827ad..4e03365 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -15,7 +15,6 @@ public class ProjectDto { @NotEmpty private String title; private Project.ProjectStatus status; - private String statusName; private String description; private List deadlines = new ArrayList<>(); private GrantDto grant; @@ -40,7 +39,6 @@ public class ProjectDto { this.id = id; this.title = title; this.status = status; - this.statusName = status.getStatusName(); this.description = description; this.grant = grant; this.repository = repository; @@ -53,7 +51,6 @@ public class ProjectDto { this.id = project.getId(); this.title = project.getTitle(); this.status = project.getStatus(); - this.statusName = project.getStatus().getStatusName(); this.description = project.getDescription(); this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName(); this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant()); @@ -85,14 +82,6 @@ public class ProjectDto { this.status = status; } - public String getStatusName() { - return statusName; - } - - public void setStatusName(String statusName) { - this.statusName = statusName; - } - public String getDescription() { return description; } diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index c34bf42..247624d 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -72,6 +72,15 @@ public class ProjectService { return project; } + @Transactional + public void delete(Integer projectId) throws IOException { + Project project = projectRepository.findOne(projectId); + if (project.getApplication() != null) { + fileService.deleteFile(project.getApplication()); + } + projectRepository.delete(project); + } + private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException { project.setDescription(projectDto.getDescription()); project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus()); diff --git a/src/main/resources/public/js/projects.js b/src/main/resources/public/js/projects.js new file mode 100644 index 0000000..5867c50 --- /dev/null +++ b/src/main/resources/public/js/projects.js @@ -0,0 +1,42 @@ +/*\n' + + ' \n' + + ' '); + } + $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); + $('#dataConfirmOK').attr('href', href); + $('#dataConfirmModal').modal({show:true}); + return false; + }); +}); +/*]]>*/ \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index f821549..6bb134e 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -40,7 +40,7 @@
- +
diff --git a/src/main/resources/templates/projects/fragments/projectDashboardFragment.html b/src/main/resources/templates/projects/fragments/projectDashboardFragment.html index 4e6f1e6..027dce7 100644 --- a/src/main/resources/templates/projects/fragments/projectDashboardFragment.html +++ b/src/main/resources/templates/projects/fragments/projectDashboardFragment.html @@ -11,7 +11,6 @@
title -

status

diff --git a/src/main/resources/templates/projects/fragments/projectLineFragment.html b/src/main/resources/templates/projects/fragments/projectLineFragment.html index 3605273..43bdfb9 100644 --- a/src/main/resources/templates/projects/fragments/projectLineFragment.html +++ b/src/main/resources/templates/projects/fragments/projectLineFragment.html @@ -12,6 +12,10 @@ + + + diff --git a/src/main/resources/templates/projects/fragments/projectStatusFragment.html b/src/main/resources/templates/projects/fragments/projectStatusFragment.html index e5da374..d8f29cc 100644 --- a/src/main/resources/templates/projects/fragments/projectStatusFragment.html +++ b/src/main/resources/templates/projects/fragments/projectStatusFragment.html @@ -4,7 +4,7 @@ - +
diff --git a/src/main/resources/templates/projects/projects.html b/src/main/resources/templates/projects/projects.html index fd19383..e70b910 100644 --- a/src/main/resources/templates/projects/projects.html +++ b/src/main/resources/templates/projects/projects.html @@ -27,7 +27,9 @@
+
+