#96 edit project blank page
This commit is contained in:
parent
487aa578a7
commit
ca3e87a8c5
@ -5,6 +5,7 @@ import org.springframework.ui.ModelMap;
|
|||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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;
|
||||||
@ -36,4 +37,13 @@ public class ProjectController {
|
|||||||
public void getProjects(ModelMap modelMap) {
|
public void getProjects(ModelMap modelMap) {
|
||||||
modelMap.put("projects", projectService.findAllDto());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,7 @@ import org.hibernate.validator.constraints.NotBlank;
|
|||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ public class ProjectDto {
|
|||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
private List<Deadline> deadlines = new ArrayList<>();
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
|
||||||
public ProjectDto() {
|
public ProjectDto() {
|
||||||
|
@ -8,6 +8,7 @@ import ru.ulstu.project.model.Project;
|
|||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.project.model.ProjectDto;
|
||||||
import ru.ulstu.project.repository.ProjectRepository;
|
import ru.ulstu.project.repository.ProjectRepository;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
@ -36,6 +37,10 @@ public class ProjectService {
|
|||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectDto findOneDto(Integer id) {
|
||||||
|
return new ProjectDto(projectRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Project create(ProjectDto projectDto) {
|
public Project create(ProjectDto projectDto) {
|
||||||
Project newProject = copyFromDto(new Project(), projectDto);
|
Project newProject = copyFromDto(new Project(), projectDto);
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
<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>
|
aria-hidden="true"></i>
|
||||||
Добавить проект</a>
|
Добавить проект</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
45
src/main/resources/templates/projects/project.html
Normal file
45
src/main/resources/templates/projects/project.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user