#96 project status added
This commit is contained in:
parent
f079e34a57
commit
255692d6ea
@ -46,4 +46,9 @@ public class ProjectController {
|
||||
modelMap.put("projectDto", new ProjectDto());
|
||||
}
|
||||
}
|
||||
|
||||
@ModelAttribute("allStatuses")
|
||||
public List<Project.ProjectStatus> getProjectStatuses() {
|
||||
return projectService.getProjectStatuses();
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,31 @@ import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class Project extends BaseEntity {
|
||||
public enum ProjectStatus {
|
||||
APPLICATION("Заявка"),
|
||||
ON_COMPETITION("Отправлен на конкурс"),
|
||||
SUCCESSFUL_PASSAGE("Успешное прохождение"),
|
||||
IN_WORK("В работе"),
|
||||
COMPLETED("Завершен"),
|
||||
FAILED("Провалены сроки");
|
||||
|
||||
private String statusName;
|
||||
|
||||
ProjectStatus(String statusName) {
|
||||
this.statusName = statusName;
|
||||
}
|
||||
|
||||
public String getStatusName() {
|
||||
return statusName;
|
||||
}
|
||||
}
|
||||
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private ProjectStatus status = ProjectStatus.APPLICATION;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "project_id")
|
||||
private List<Deadline> deadlines = new ArrayList<>();
|
||||
@ -26,6 +47,14 @@ public class Project extends BaseEntity {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public ProjectStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ProjectStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<Deadline> getDeadlines() {
|
||||
return deadlines;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public class ProjectDto {
|
||||
|
||||
@NotEmpty
|
||||
private String title;
|
||||
private Project.ProjectStatus status;
|
||||
private List<Deadline> deadlines = new ArrayList<>();
|
||||
|
||||
public ProjectDto() {
|
||||
@ -25,9 +26,11 @@ public class ProjectDto {
|
||||
@JsonCreator
|
||||
public ProjectDto(@JsonProperty("id") Integer id,
|
||||
@JsonProperty("title") String title,
|
||||
@JsonProperty("status") Project.ProjectStatus status,
|
||||
@JsonProperty("deadlines") List<Deadline> deadlines) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
this.deadlines = deadlines;
|
||||
}
|
||||
|
||||
@ -35,6 +38,7 @@ public class ProjectDto {
|
||||
public ProjectDto(Project project) {
|
||||
this.id = project.getId();
|
||||
this.title = project.getTitle();
|
||||
this.status = project.getStatus();
|
||||
this.deadlines = project.getDeadlines();
|
||||
}
|
||||
|
||||
@ -54,6 +58,14 @@ public class ProjectDto {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Project.ProjectStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Project.ProjectStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<Deadline> getDeadlines() {
|
||||
return deadlines;
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ public class ProjectService {
|
||||
return new ProjectDto(projectRepository.findOne(id));
|
||||
}
|
||||
|
||||
public List<Project.ProjectStatus> getProjectStatuses() {
|
||||
return Arrays.asList(Project.ProjectStatus.values());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Project create(ProjectDto projectDto) {
|
||||
Project newProject = copyFromDto(new Project(), projectDto);
|
||||
|
@ -33,6 +33,15 @@
|
||||
class="alert alert-danger">Incorrect title</p>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="status">Статус:</label>
|
||||
<select class="form-control" th:field="*{status}" id="status">
|
||||
<option th:each="status : ${allStatuses}" th:value="${status}"
|
||||
th:text="${status.statusName}">Status
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user