#96 edit project page

This commit is contained in:
Васин Антон 2019-04-18 10:32:43 +03:00
parent e85c814f70
commit b722687050
4 changed files with 134 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package ru.ulstu.project.model;
import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.grant.model.Grant;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@ -37,12 +38,19 @@ public class Project extends BaseEntity {
private ProjectStatus status = ProjectStatus.APPLICATION;
@NotNull
private String comment;
private String description;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "project_id")
private List<Deadline> deadlines = new ArrayList<>();
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "grant_id")
private Grant grant;
@NotNull
private String repository;
public String getTitle() {
return title;
}
@ -59,12 +67,28 @@ public class Project extends BaseEntity {
this.status = status;
}
public String getComment() {
return comment;
public String getDescription() {
return description;
}
public void setComment(String comment) {
this.comment = comment;
public void setDescription(String description) {
this.description = description;
}
public Grant getGrant() {
return grant;
}
public void setGrant(Grant grant) {
this.grant = grant;
}
public String getRepository() {
return repository;
}
public void setRepository(String repository) {
this.repository = repository;
}
public List<Deadline> getDeadlines() {

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.grant.model.GrantDto;
import java.util.ArrayList;
import java.util.List;
@ -14,8 +15,10 @@ public class ProjectDto {
@NotEmpty
private String title;
private Project.ProjectStatus status;
private String comment;
private String description;
private List<Deadline> deadlines = new ArrayList<>();
private GrantDto grant;
private String repository;
public ProjectDto() {
}
@ -28,12 +31,16 @@ public class ProjectDto {
public ProjectDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("status") Project.ProjectStatus status,
@JsonProperty("comment") String comment,
@JsonProperty("description") String description,
@JsonProperty("grant") GrantDto grant,
@JsonProperty("repository") String repository,
@JsonProperty("deadlines") List<Deadline> deadlines) {
this.id = id;
this.title = title;
this.status = status;
this.comment = comment;
this.description = description;
this.grant = grant;
this.repository = repository;
this.deadlines = deadlines;
}
@ -42,7 +49,9 @@ public class ProjectDto {
this.id = project.getId();
this.title = project.getTitle();
this.status = project.getStatus();
this.comment = project.getComment();
this.description = project.getDescription();
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
this.repository = project.getRepository();
this.deadlines = project.getDeadlines();
}
@ -70,12 +79,28 @@ public class ProjectDto {
this.status = status;
}
public String getComment() {
return comment;
public String getDescription() {
return description;
}
public void setComment(String comment) {
this.comment = comment;
public void setDescription(String description) {
this.description = description;
}
public GrantDto getGrant() {
return grant;
}
public void setGrant(GrantDto grant) {
this.grant = grant;
}
public String getRepository() {
return repository;
}
public void setRepository(String repository) {
this.repository = repository;
}
public List<Deadline> getDeadlines() {

View File

@ -9,7 +9,7 @@
<span th:replace="projects/fragments/projectStatusFragment :: projectStatus(projectStatus=${project.status})"/>
<a th:href="@{'project?id='+${project.id}}">
<span class="h6" th:text="${project.title}"/>
<span class="text-muted" th:text="${project.comment}"/>
<span class="text-muted" th:text="${project.description}"/>
</a>
<input class="id-class" type="hidden" th:value="${project.id}"/>
</div>

View File

@ -44,9 +44,59 @@
</div>
<div class="form-group">
<label for="comment">Комментарий:</label>
<textarea class="form-control" rows="3" id="comment"
th:field="*{comment}"></textarea>
<label for="description">Описание:</label>
<textarea class="form-control" rows="3" id="description"
th:field="*{description}"></textarea>
</div>
<div class="form-group">
<label for="createGrant">Добавить грант:</label>
<div th:if="*{grant} == null">
<input type="submit" id="createGrant" name="createGrant" class="btn btn-primary"
value="Добавить грант"/>
</div>
<input type = "hidden" th:field="*{grant.id}"/>
</div>
<div class="form-group">
<label for="repository">Ссылка на репозиторий:</label>
<input class="form-control" id="repository" type="text"
placeholder="http://"
th:field="*{repository}"/>
<p th:if="${#fields.hasErrors('repository')}" th:errors="*{repository}"
class="alert alert-danger">Incorrect repository link</p>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label>Дедлайны показателей:</label>
<div class="row">
<input type="hidden"/>
<div class="col-6">
<input type="date" class="form-control" name="deadline"/>
</div>
<div class="col-4">
<input class="form-control" type="text" placeholder="Описание"/>
</div>
<div class="col-2">
<a class="btn btn-danger float-right"><span
aria-hidden="true"><i class="fa fa-times"/></span>
</a>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
</div>
<div class="form-group">
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary" value="Добавить
дедлайн"/>
</div>
<div class="form-group">
<label for="loader">Загрузить файл:</label>
<div id="loader">
</div>
</div>
</div>
@ -68,6 +118,24 @@
</div>
</div>
</section>
<script type="text/javascript" src="/js/file-loader.js"></script>
<script>
/*<![CDATA[*/
$(document).ready(function () {
new FileLoader({
div: "loader",
url: urlFileUpload,
maxSize: 2,
extensions: ["doc", "docx", "xls", "jpg", "png", "pdf", "txt"],
callback: function (response) {
showFeedbackMessage("Файл успешно загружен");
console.debug(response);
}
});
$('.selectpicker').selectpicker();
});
/*]]>*/
</script>
</div>
</body>
</html>