Resolve "Удалить статью" #182

Merged
VladimirZarayskiy merged 1 commits from 65-undock-article into dev 2019-04-16 15:13:23 +04:00
3 changed files with 18 additions and 3 deletions
Showing only changes of commit 81d07645c2 - Show all commits

View File

@ -94,6 +94,16 @@ public class ConferenceController {
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) {
return conferenceService.getConferencePapers(paperIds);
}

View File

@ -83,6 +83,11 @@ public class ConferenceService {
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) {
return paperService.findAllNotSelect(paperIds);
}
@ -94,6 +99,7 @@ public class ConferenceService {
conference.setPing(0);
conference.setBeginDate(conferenceDto.getBeginDate());
conference.setEndDate(conferenceDto.getEndDate());
conference.setPapers(conferenceDto.getPapers());
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
conferenceDto.getPaperIds().forEach(paperId ->

View File

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