#113 delete function
This commit is contained in:
parent
39f44403c1
commit
e32da7c7c2
@ -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()))
|
||||
|
@ -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());
|
||||
|
@ -40,7 +40,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-6 portfolio-item">
|
||||
<a class="portfolio-link" href="./projects/projects">
|
||||
<a class="portfolio-link" href="./projects/dashboard">
|
||||
<div class="portfolio-hover">
|
||||
<div class="portfolio-hover-content">
|
||||
<i class="fa fa-arrow-right fa-3x"></i>
|
||||
|
@ -11,7 +11,6 @@
|
||||
</div>
|
||||
<div class="col col-10 text-right">
|
||||
<h7 class="service-heading" th:text="${project.title}"> title</h7>
|
||||
<p class="text-muted" th:text="${project.statusName}"> status</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<span th:fragment="paperStatus (paperStatus)" class="fa-stack fa-1x">
|
||||
<span th:fragment="projectStatus (projectStatus)" class="fa-stack fa-1x">
|
||||
<th:block th:switch="${projectStatus.name()}">
|
||||
<div th:case="'APPLICATION'">
|
||||
<i class="fa fa-circle fa-stack-2x text-draft"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user