Merge branch '114-bug-projects-list' into 'dev'

Resolve "Bug: не отображается список проектов"

Closes #114

See merge request romanov73/ng-tracker!72
environments/staging/deployments/37
Anton Romanov 5 years ago
commit 39f44403c1

@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.project.model.Project; import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.service.ProjectService; import ru.ulstu.project.service.ProjectService;
@ -21,7 +20,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springframework.util.StringUtils.isEmpty; import static org.springframework.util.StringUtils.isEmpty;
import static ru.ulstu.core.controller.Navigation.hasErrors;
@Controller() @Controller()
@RequestMapping(value = "/projects") @RequestMapping(value = "/projects")

@ -15,6 +15,7 @@ public class ProjectDto {
@NotEmpty @NotEmpty
private String title; private String title;
private Project.ProjectStatus status; private Project.ProjectStatus status;
private String statusName;
private String description; private String description;
private List<Deadline> deadlines = new ArrayList<>(); private List<Deadline> deadlines = new ArrayList<>();
private GrantDto grant; private GrantDto grant;
@ -39,6 +40,7 @@ public class ProjectDto {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.status = status; this.status = status;
this.statusName = status.getStatusName();
this.description = description; this.description = description;
this.grant = grant; this.grant = grant;
this.repository = repository; this.repository = repository;
@ -51,6 +53,7 @@ public class ProjectDto {
this.id = project.getId(); this.id = project.getId();
this.title = project.getTitle(); this.title = project.getTitle();
this.status = project.getStatus(); this.status = project.getStatus();
this.statusName = project.getStatus().getStatusName();
this.description = project.getDescription(); this.description = project.getDescription();
this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName(); this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName();
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant()); this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
@ -82,6 +85,14 @@ public class ProjectDto {
this.status = status; this.status = status;
} }
public String getStatusName() {
return statusName;
}
public void setStatusName(String statusName) {
this.statusName = statusName;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }

@ -62,6 +62,16 @@ public class ProjectService {
return newProject; return newProject;
} }
@Transactional
public Project update(ProjectDto projectDto) throws IOException {
Project project = projectRepository.findOne(projectDto.getId());
if (projectDto.getApplicationFileName() != null && project.getApplication() != null) {
fileService.deleteFile(project.getApplication());
}
projectRepository.save(copyFromDto(project, projectDto));
return project;
}
private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException { private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException {
project.setDescription(projectDto.getDescription()); project.setDescription(projectDto.getDescription());
project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus()); project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus());
@ -85,10 +95,6 @@ public class ProjectService {
} }
} }
private Project update(ProjectDto projectDto) {
throw new RuntimeException("not implemented yet");
}
public Project findById(Integer id) { public Project findById(Integer id) {
return projectRepository.findOne(id); return projectRepository.findOne(id);
} }

@ -40,7 +40,7 @@
</div> </div>
</div> </div>
<div class="col-md-4 col-sm-6 portfolio-item"> <div class="col-md-4 col-sm-6 portfolio-item">
<a class="portfolio-link" href="./projects/dashboard"> <a class="portfolio-link" href="./projects/projects">
<div class="portfolio-hover"> <div class="portfolio-hover">
<div class="portfolio-hover-content"> <div class="portfolio-hover-content">
<i class="fa fa-arrow-right fa-3x"></i> <i class="fa fa-arrow-right fa-3x"></i>

@ -11,7 +11,7 @@
</div> </div>
<div class="col col-10 text-right"> <div class="col col-10 text-right">
<h7 class="service-heading" th:text="${project.title}"> title</h7> <h7 class="service-heading" th:text="${project.title}"> title</h7>
<p class="text-muted" th:text="${project.status.statusName}"> status</p> <p class="text-muted" th:text="${project.statusName}"> status</p>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save