Merge branch '66-attach-exist-article' into 'dev'
Resolve "Прикрепление статьи" Closes #66 See merge request romanov73/ng-tracker!54
This commit is contained in:
commit
0c719d8886
@ -13,10 +13,13 @@ import ru.ulstu.conference.model.ConferenceDto;
|
|||||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||||
import ru.ulstu.conference.service.ConferenceService;
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.springframework.util.StringUtils.isEmpty;
|
import static org.springframework.util.StringUtils.isEmpty;
|
||||||
@ -44,9 +47,13 @@ public class ConferenceController {
|
|||||||
@GetMapping("/conference")
|
@GetMapping("/conference")
|
||||||
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||||
if (id != null && id > 0) {
|
if (id != null && id > 0) {
|
||||||
modelMap.put("conferenceDto", conferenceService.findOneDto(id));
|
ConferenceDto conferenceDto = conferenceService.findOneDto(id);
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
||||||
|
modelMap.put("conferenceDto", conferenceDto);
|
||||||
} else {
|
} else {
|
||||||
modelMap.put("conferenceDto", new ConferenceDto());
|
ConferenceDto conferenceDto = new ConferenceDto();
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
|
||||||
|
modelMap.put("conferenceDto", conferenceDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +94,10 @@ public class ConferenceController {
|
|||||||
return CONFERENCE_PAGE;
|
return CONFERENCE_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
|
||||||
|
return conferenceService.getConferencePapers(paperIds);
|
||||||
|
}
|
||||||
|
|
||||||
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
|
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
|
||||||
conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream()
|
conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream()
|
||||||
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
|
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
|
||||||
|
@ -60,7 +60,7 @@ public class Conference extends BaseEntity {
|
|||||||
@JoinTable(name = "paper_conference",
|
@JoinTable(name = "paper_conference",
|
||||||
joinColumns = {@JoinColumn(name = "conference_id")},
|
joinColumns = {@JoinColumn(name = "conference_id")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
||||||
private Set<Paper> papers = new HashSet<>();
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "users_conference",
|
@JoinTable(name = "users_conference",
|
||||||
@ -124,11 +124,11 @@ public class Conference extends BaseEntity {
|
|||||||
this.deadlines = deadlines;
|
this.deadlines = deadlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Paper> getPapers() {
|
public List<Paper> getPapers() {
|
||||||
return papers;
|
return papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPapers(Set<Paper> papers) {
|
public void setPapers(List<Paper> papers) {
|
||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
@ -39,8 +39,11 @@ public class ConferenceDto {
|
|||||||
private List<Deadline> deadlines = new ArrayList<>();
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||||
private Set<Integer> userIds = new HashSet<>();
|
private Set<Integer> userIds = new HashSet<>();
|
||||||
private Set<Integer> paperIds = new HashSet<>();
|
private List<Integer> paperIds = new ArrayList<>();
|
||||||
private Set<PaperDto> papers = new HashSet<>();
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
private List<Paper> notSelectedPapers = new ArrayList<>();
|
||||||
private Set<UserDto> users = new HashSet<>();
|
private Set<UserDto> users = new HashSet<>();
|
||||||
private Integer filterUserId;
|
private Integer filterUserId;
|
||||||
|
|
||||||
@ -57,9 +60,10 @@ public class ConferenceDto {
|
|||||||
@JsonProperty("endDate") Date endDate,
|
@JsonProperty("endDate") Date endDate,
|
||||||
@JsonProperty("deadlines") List<Deadline> deadlines,
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
@JsonProperty("userIds") Set<Integer> userIds,
|
@JsonProperty("userIds") Set<Integer> userIds,
|
||||||
@JsonProperty("paperIds") Set<Integer> paperIds,
|
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||||
@JsonProperty("users") Set<UserDto> users,
|
@JsonProperty("users") Set<UserDto> users,
|
||||||
@JsonProperty("papers") Set<PaperDto> papers) {
|
@JsonProperty("papers") List<Paper> papers,
|
||||||
|
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -72,6 +76,7 @@ public class ConferenceDto {
|
|||||||
this.paperIds = paperIds;
|
this.paperIds = paperIds;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceDto(Conference conference) {
|
public ConferenceDto(Conference conference) {
|
||||||
@ -86,7 +91,7 @@ public class ConferenceDto {
|
|||||||
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
||||||
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
||||||
this.users = convert(conference.getUsers(), UserDto::new);
|
this.users = convert(conference.getUsers(), UserDto::new);
|
||||||
this.papers = convert(conference.getPapers(), PaperDto::new);
|
this.papers = conference.getPapers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,19 +167,19 @@ public class ConferenceDto {
|
|||||||
this.userIds = userIds;
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getPaperIds() {
|
public List<Integer> getPaperIds() {
|
||||||
return paperIds;
|
return paperIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPaperIds(Set<Integer> paperIds) {
|
public void setPaperIds(List<Integer> paperIds) {
|
||||||
this.paperIds = paperIds;
|
this.paperIds = paperIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<PaperDto> getPapers() {
|
public List<Paper> getPapers() {
|
||||||
return papers;
|
return papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPapers(Set<PaperDto> papers) {
|
public void setPapers(List<Paper> papers) {
|
||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,4 +207,12 @@ public class ConferenceDto {
|
|||||||
this.removedDeadlineIds = removedDeadlineIds;
|
this.removedDeadlineIds = removedDeadlineIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Paper> getNotSelectedPapers() {
|
||||||
|
return notSelectedPapers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotSelectedPapers(List<Paper> notSelectedPapers) {
|
||||||
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import ru.ulstu.conference.model.Conference;
|
|||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,11 +22,14 @@ public class ConferenceService {
|
|||||||
|
|
||||||
private final ConferenceRepository conferenceRepository;
|
private final ConferenceRepository conferenceRepository;
|
||||||
private final DeadlineService deadlineService;
|
private final DeadlineService deadlineService;
|
||||||
|
private final PaperService paperService;
|
||||||
|
|
||||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||||
DeadlineService deadlineService) {
|
DeadlineService deadlineService,
|
||||||
|
PaperService paperService) {
|
||||||
this.conferenceRepository = conferenceRepository;
|
this.conferenceRepository = conferenceRepository;
|
||||||
this.deadlineService = deadlineService;
|
this.deadlineService = deadlineService;
|
||||||
|
this.paperService = paperService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Conference> findAll() {
|
public List<Conference> findAll() {
|
||||||
@ -78,6 +83,10 @@ public class ConferenceService {
|
|||||||
conferenceDto.getDeadlines().remove((int) deadlineIndex);
|
conferenceDto.getDeadlines().remove((int) deadlineIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Paper> getConferencePapers(List<Integer> paperIds) {
|
||||||
|
return paperService.findAllNotSelect(paperIds);
|
||||||
|
}
|
||||||
|
|
||||||
private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
||||||
conference.setTitle(conferenceDto.getTitle());
|
conference.setTitle(conferenceDto.getTitle());
|
||||||
conference.setDescription(conferenceDto.getDescription());
|
conference.setDescription(conferenceDto.getDescription());
|
||||||
@ -86,6 +95,10 @@ public class ConferenceService {
|
|||||||
conference.setBeginDate(conferenceDto.getBeginDate());
|
conference.setBeginDate(conferenceDto.getBeginDate());
|
||||||
conference.setEndDate(conferenceDto.getEndDate());
|
conference.setEndDate(conferenceDto.getEndDate());
|
||||||
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
||||||
|
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
||||||
|
conferenceDto.getPaperIds().forEach(paperId ->
|
||||||
|
conference.getPapers().add(paperService.findEntityById(paperId)));
|
||||||
|
}
|
||||||
return conference;
|
return conference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,4 +12,6 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
|
|||||||
|
|
||||||
@Query("SELECT p FROM Paper p WHERE (:author IS NULL OR :author MEMBER OF p.authors) AND (YEAR(p.createDate) = :year OR :year IS NULL)")
|
@Query("SELECT p FROM Paper p WHERE (:author IS NULL OR :author MEMBER OF p.authors) AND (YEAR(p.createDate) = :year OR :year IS NULL)")
|
||||||
List<Paper> filter(@Param("author") User author, @Param("year") Integer year);
|
List<Paper> filter(@Param("author") User author, @Param("year") Integer year);
|
||||||
|
|
||||||
|
List<Paper> findByIdNotIn(List<Integer> paperIds);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,19 @@ public class PaperService {
|
|||||||
return new PaperDto(paperRepository.findOne(paperId));
|
return new PaperDto(paperRepository.findOne(paperId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Paper findEntityById(Integer paperId) {
|
||||||
|
return paperRepository.findOne(paperId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> findAllNotSelect(List<Integer> paperIds) {
|
||||||
|
if (!paperIds.isEmpty()) {
|
||||||
|
return sortPapers(paperRepository.findByIdNotIn(paperIds));
|
||||||
|
} else {
|
||||||
|
return sortPapers(paperRepository.findAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<User> getPaperAuthors() {
|
public List<User> getPaperAuthors() {
|
||||||
return userService.findAll();
|
return userService.findAll();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ body {
|
|||||||
border-radius: .25rem;
|
border-radius: .25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter-option-inner-inner {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +53,8 @@ body {
|
|||||||
|
|
||||||
.paper {
|
.paper {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
min-height: 40px;
|
||||||
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paper-name {
|
.paper-name {
|
||||||
@ -104,13 +110,14 @@ body {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
@media (max-width: 1199px) and (min-width: 768px){
|
||||||
.paper-control {
|
.paper-control {
|
||||||
display: block!important;
|
display: block!important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
|
|
||||||
.dates-panel {
|
.dates-panel {
|
||||||
display: block!important;
|
display: block!important;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@
|
|||||||
<input type="submit" class="icon icon-delete grey-border"
|
<input type="submit" class="icon icon-delete grey-border"
|
||||||
alt="Удалить" name="removeDeadline" th:value="${rowStat.index}"
|
alt="Удалить" name="removeDeadline" th:value="${rowStat.index}"
|
||||||
/>
|
/>
|
||||||
<!--th:onclick="|$(this).parent().remove();|"-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -136,23 +135,30 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="papers">Статьи:</label>
|
<label for="papers">Статьи:</label>
|
||||||
<div class="paper-list form-control list-group" id="papers">
|
<div class="paper-list form-control list-group" id="papers">
|
||||||
<div class="paper d-flex list-group-item p-0">
|
<input th:type="hidden" th:field="*{papers}"/>
|
||||||
<a class="paper-name" href="/papers/papers">
|
<div class="paper d-flex list-group-item p-0"
|
||||||
<span>
|
th:each="paper, rowStat : *{papers}">
|
||||||
|
<a class="paper-name"
|
||||||
|
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
|
||||||
|
<span th:text="*{papers[__${rowStat.index}__].title}">
|
||||||
Имя статьи
|
Имя статьи
|
||||||
</span>
|
</span>
|
||||||
<img class="icon-paper" src="/img/conference/paper.png"/>
|
<img class="icon-paper" src="/img/conference/paper.png"/>
|
||||||
</a>
|
</a>
|
||||||
<img class="icon grey-border icon-delete" src="/img/conference/delete.png"
|
<input type="submit" class="icon icon-delete grey-border"
|
||||||
alt="Удалить"/>
|
alt="Удалить"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="paper-control form-group d-flex justify-content-end">
|
<div class="paper-control form-group d-flex justify-content-end">
|
||||||
<button id="attach-paper" class="btn btn-primary"
|
<input th:type="hidden" th:field="*{notSelectedPapers}"/>
|
||||||
type="button">
|
<select class="selectpicker form-control" multiple="true" data-live-search="true"
|
||||||
Прикрепить статью
|
title="Прикрепить статью" data-style="btn-primary" data-size="5"
|
||||||
</button>
|
th:field="*{paperIds}">
|
||||||
|
<option th:each="paper: *{notSelectedPapers}" th:value="${paper.id}"
|
||||||
|
th:text="${paper.title}">Status
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<button id="add-paper" class="btn btn-primary"
|
<button id="add-paper" class="btn btn-primary"
|
||||||
type="button">
|
type="button">
|
||||||
Добавить статью
|
Добавить статью
|
||||||
|
Loading…
Reference in New Issue
Block a user