#96 edit project blank page

This commit is contained in:
Васин Антон 2019-04-17 13:50:22 +03:00
parent 487aa578a7
commit ca3e87a8c5
6 changed files with 63 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.service.ProjectService;
@ -36,4 +37,13 @@ public class ProjectController {
public void getProjects(ModelMap modelMap) {
modelMap.put("projects", projectService.findAllDto());
}
@GetMapping("/project")
public void getProject(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) {
modelMap.put("projectDto", projectService.findOneDto(id));
} else {
modelMap.put("projectDto", new ProjectDto());
}
}
}

View File

@ -4,10 +4,7 @@ import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

View File

@ -13,7 +13,6 @@ public class ProjectDto {
@NotEmpty
private String title;
private List<Deadline> deadlines = new ArrayList<>();
public ProjectDto() {

View File

@ -8,6 +8,7 @@ import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.repository.ProjectRepository;
import java.util.Arrays;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
@ -36,6 +37,10 @@ public class ProjectService {
return projects;
}
public ProjectDto findOneDto(Integer id) {
return new ProjectDto(projectRepository.findOne(id));
}
@Transactional
public Project create(ProjectDto projectDto) {
Project newProject = copyFromDto(new Project(), projectDto);

View File

@ -16,7 +16,7 @@
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="javascript:void(0)" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
<a href="./project?id=0" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
aria-hidden="true"></i>
Добавить проект</a>

View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
</head>
<body>
<div class="container" layout:fragment="content">
<section id="paper">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Редактирование проекта</h2>
<div th:replace="projects/fragments/projectNavigationFragment"/>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<form id="project-form" method="post" th:action="@{'/projects/project?id='+ *{id == null ? '' : id} + ''}"
th:object="${projectDto}">
<div class="row">
<div class="clearfix"></div>
<div class="col-lg-12">
<div class="form-group">
<button id="sendMessageButton" name="save" class="btn btn-success text-uppercase"
type="submit">
Сохранить
</button>
<button id="cancelButton" class="btn btn-default text-uppercase" href="/projects/projects">
Отмена
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
</div>
</body>
</html>