#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 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 ru.ulstu.grant.model.Grant;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -37,12 +38,19 @@ public class Project extends BaseEntity {
private ProjectStatus status = ProjectStatus.APPLICATION; private ProjectStatus status = ProjectStatus.APPLICATION;
@NotNull @NotNull
private String comment; private String description;
@OneToMany(cascade = CascadeType.ALL) @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "project_id") @JoinColumn(name = "project_id")
private List<Deadline> deadlines = new ArrayList<>(); private List<Deadline> deadlines = new ArrayList<>();
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "grant_id")
private Grant grant;
@NotNull
private String repository;
public String getTitle() { public String getTitle() {
return title; return title;
} }
@ -59,12 +67,28 @@ public class Project extends BaseEntity {
this.status = status; this.status = status;
} }
public String getComment() { public String getDescription() {
return comment; return description;
} }
public void setComment(String comment) { public void setDescription(String description) {
this.comment = comment; 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() { public List<Deadline> getDeadlines() {

View File

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

View File

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

View File

@ -44,9 +44,59 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="comment">Комментарий:</label> <label for="description">Описание:</label>
<textarea class="form-control" rows="3" id="comment" <textarea class="form-control" rows="3" id="description"
th:field="*{comment}"></textarea> 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>
</div> </div>
@ -68,6 +118,24 @@
</div> </div>
</div> </div>
</section> </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> </div>
</body> </body>
</html> </html>