#65 added delete method of article, fixed copyFromDto method

This commit is contained in:
Nightblade73 2019-04-16 14:18:49 +04:00
parent 3facc0c26e
commit 81d07645c2
3 changed files with 18 additions and 3 deletions

View File

@ -94,6 +94,16 @@ public class ConferenceController {
return CONFERENCE_PAGE; return CONFERENCE_PAGE;
} }
@PostMapping(value = "/conference", params = "removePaper")
public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors,
@RequestParam(value = "removePaper") Integer paperIndex) throws IOException {
if (errors.hasErrors()) {
return CONFERENCE_PAGE;
}
conferenceService.removePaper(conferenceDto, paperIndex);
return CONFERENCE_PAGE;
}
public List<Paper> getNotSelectPapers(List<Integer> paperIds) { public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
return conferenceService.getConferencePapers(paperIds); return conferenceService.getConferencePapers(paperIds);
} }

View File

@ -83,6 +83,11 @@ public class ConferenceService {
conferenceDto.getDeadlines().remove((int) deadlineIndex); conferenceDto.getDeadlines().remove((int) deadlineIndex);
} }
public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException {
Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex);
conferenceDto.getNotSelectedPapers().add(removedPaper);
}
public List<Paper> getConferencePapers(List<Integer> paperIds) { public List<Paper> getConferencePapers(List<Integer> paperIds) {
return paperService.findAllNotSelect(paperIds); return paperService.findAllNotSelect(paperIds);
} }
@ -94,6 +99,7 @@ public class ConferenceService {
conference.setPing(0); conference.setPing(0);
conference.setBeginDate(conferenceDto.getBeginDate()); conference.setBeginDate(conferenceDto.getBeginDate());
conference.setEndDate(conferenceDto.getEndDate()); conference.setEndDate(conferenceDto.getEndDate());
conference.setPapers(conferenceDto.getPapers());
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) { if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
conferenceDto.getPaperIds().forEach(paperId -> conferenceDto.getPaperIds().forEach(paperId ->

View File

@ -60,8 +60,7 @@
<input class="list-group-item" type="date" name="deadline" <input class="list-group-item" type="date" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/> th:field="*{deadlines[__${rowStat.index}__].date}"/>
<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}"/>
/>
</div> </div>
</div> </div>
</div> </div>
@ -146,7 +145,7 @@
<img class="icon-paper" src="/img/conference/paper.png"/> <img class="icon-paper" src="/img/conference/paper.png"/>
</a> </a>
<input type="submit" class="icon icon-delete grey-border" <input type="submit" class="icon icon-delete grey-border"
alt="Удалить"/> alt="Удалить" name="removePaper" th:value="${rowStat.index}"/>
</div> </div>
</div> </div>
</div> </div>