show authors
This commit is contained in:
parent
c88ce3ac37
commit
dc5abe1508
@ -37,6 +37,11 @@ public class PaperController {
|
||||
modelMap.put("papers", paperService.findAllDto());
|
||||
}
|
||||
|
||||
@GetMapping("/dashboard")
|
||||
public void getDashboard(ModelMap modelMap) {
|
||||
modelMap.put("papers", paperService.findAllDto());
|
||||
}
|
||||
|
||||
@GetMapping("/paper")
|
||||
public void getPapers(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||
if (id != null && id > 0) {
|
||||
|
@ -4,12 +4,14 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import ru.ulstu.deadline.model.DeadlineDto;
|
||||
import ru.ulstu.user.model.UserDto;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
@ -29,7 +31,8 @@ public class PaperDto {
|
||||
private Integer fileId;
|
||||
private String fileName;
|
||||
private Date fileCreateDate;
|
||||
private Set<Integer> authors;
|
||||
private Set<Integer> authorIds;
|
||||
private Set<UserDto> authors;
|
||||
|
||||
public PaperDto() {
|
||||
deadlines.add(new DeadlineDto());
|
||||
@ -45,7 +48,8 @@ public class PaperDto {
|
||||
@JsonProperty("comment") String comment,
|
||||
@JsonProperty("locked") Boolean locked,
|
||||
@JsonProperty("tmpFileName") String tmpFileName,
|
||||
@JsonProperty("authors") Set<Integer> authors) {
|
||||
@JsonProperty("authorIds") Set<Integer> authorIds,
|
||||
@JsonProperty("authors") Set<UserDto> authors) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
@ -74,110 +78,126 @@ public class PaperDto {
|
||||
this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId();
|
||||
this.fileName = paper.getFileData() == null ? null : paper.getFileData().getName();
|
||||
this.fileCreateDate = paper.getFileData() == null ? null : paper.getFileData().getCreateDate();
|
||||
this.authors = convert(paper.getAuthors(), user -> user.getId());
|
||||
this.authorIds = convert(paper.getAuthors(), user -> user.getId());
|
||||
this.authors = convert(paper.getAuthors(), UserDto::new);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public Paper.PaperStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public List<DeadlineDto> getDeadlines() {
|
||||
return deadlines;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public Boolean getLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public String getTmpFileName() {
|
||||
return tmpFileName;
|
||||
}
|
||||
|
||||
public Integer getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public Date getFileCreateDate() {
|
||||
return fileCreateDate;
|
||||
}
|
||||
|
||||
public Set<Integer> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Paper.PaperStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Paper.PaperStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public List<DeadlineDto> getDeadlines() {
|
||||
return deadlines;
|
||||
}
|
||||
|
||||
public void setDeadlines(List<DeadlineDto> deadlines) {
|
||||
this.deadlines = deadlines;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Boolean getLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(Boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public String getTmpFileName() {
|
||||
return tmpFileName;
|
||||
}
|
||||
|
||||
public void setTmpFileName(String tmpFileName) {
|
||||
this.tmpFileName = tmpFileName;
|
||||
}
|
||||
|
||||
public Integer getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(Integer fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public Date getFileCreateDate() {
|
||||
return fileCreateDate;
|
||||
}
|
||||
|
||||
public void setFileCreateDate(Date fileCreateDate) {
|
||||
this.fileCreateDate = fileCreateDate;
|
||||
}
|
||||
|
||||
public void setAuthors(Set<Integer> authors) {
|
||||
public Set<UserDto> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(Set<UserDto> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public void setDeadlines(List<DeadlineDto> deadlines) {
|
||||
this.deadlines = deadlines;
|
||||
public Set<Integer> getAuthorIds() {
|
||||
return authorIds;
|
||||
}
|
||||
|
||||
public void setAuthorIds(Set<Integer> authorIds) {
|
||||
this.authorIds = authorIds;
|
||||
}
|
||||
|
||||
public String getAuthorsString() {
|
||||
return authors
|
||||
.stream()
|
||||
.map(author -> author.getLastName())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ public class PaperService {
|
||||
if (paperDto.getTmpFileName() != null) {
|
||||
paper.setFileData(fileService.createFileFromTmp(paperDto.getTmpFileName()));
|
||||
}
|
||||
if (paperDto.getAuthors() != null && !paperDto.getAuthors().isEmpty()) {
|
||||
paperDto.getAuthors().forEach(authorIds -> paper.getAuthors().add(userService.findById(authorIds)));
|
||||
if (paperDto.getAuthorIds() != null && !paperDto.getAuthorIds().isEmpty()) {
|
||||
paperDto.getAuthorIds().forEach(authorIds -> paper.getAuthors().add(userService.findById(authorIds)));
|
||||
} else {
|
||||
paper.getAuthors().clear();
|
||||
}
|
||||
|
@ -13,10 +13,11 @@
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Статьи</h2>
|
||||
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
||||
|
||||
</div>
|
||||
<div class="row justify-content-center" id="dashboard">
|
||||
|
||||
<th:block th:each="paper : ${papers}">
|
||||
<div th:replace="papers/fragments/paperDashboardFragment :: titleLine(paper=${paper})"/>
|
||||
</th:block>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:fragment="headerfiles">
|
||||
<meta charset="UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<div th:fragment="titleLine (paper)" class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3 dashboard-card">
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<span class="fa-stack fa-1x">
|
||||
<th:block th:switch="${paper.status.name()}">
|
||||
<div th:case="'ATTENTION'">
|
||||
<i class="fa fa-circle fa-stack-2x text-warning"></i>
|
||||
</div>
|
||||
<div th:case="'DRAFT'">
|
||||
<i class="fa fa-circle fa-stack-2x text-draft"></i>
|
||||
</div>
|
||||
<div th:case="'ON_PREPARATION'">
|
||||
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||
</div>
|
||||
<div th:case="'ON_REVIEW'">
|
||||
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||
</div>
|
||||
<div th:case="'COMPLETED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-success"></i>
|
||||
</div>
|
||||
<div th:case="'FAILED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-failed"></i>
|
||||
</div>
|
||||
</th:block>
|
||||
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col col-10 text-right">
|
||||
<h7 class="service-heading" th:text="${paper.title}"> title</h7>
|
||||
<p class="text-muted" th:text="${paper.authorsString}">authors</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -29,7 +29,10 @@
|
||||
</th:block>
|
||||
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
||||
<a th:href="@{'paper?id='+${paper.id}}">
|
||||
<span class="h6" th:text="${paper.title}"/>
|
||||
<span class="text-muted" th:text="${paper.authorsString}"/>
|
||||
</a>
|
||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}"
|
||||
data-confirm="Удалить статью?">
|
||||
|
@ -101,12 +101,12 @@
|
||||
<label>Редактировать авторов статьи:</label>
|
||||
<select class="selectpicker form-control" multiple="true" data-live-search="true"
|
||||
title="-- Выберите авторов --"
|
||||
th:field="*{authors}">
|
||||
th:field="*{authorIds}">
|
||||
<option th:each="author: ${allAuthors}" th:value="${author.id}"
|
||||
th:text="${author.firstName}">Status
|
||||
th:text="${author.lastName}">Status
|
||||
</option>
|
||||
</select>
|
||||
<p th:if="${#fields.hasErrors('authors')}" th:errors="*{authors}"
|
||||
<p th:if="${#fields.hasErrors('authorIds')}" th:errors="*{authorIds}"
|
||||
class="alert alert-danger">Incorrect title</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user