#70 added checking empty fields of deadline, fix bug on EventDto

This commit is contained in:
Nightblade73 2019-04-27 09:45:47 +04:00
parent dbcdb96dbf
commit e178cd1639
3 changed files with 13 additions and 3 deletions

View File

@ -78,6 +78,12 @@ public class ConferenceController {
@PostMapping(value = "/conference", params = "save") @PostMapping(value = "/conference", params = "save")
public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
filterEmptyDeadlines(conferenceDto); filterEmptyDeadlines(conferenceDto);
for (Deadline deadline : conferenceDto.getDeadlines()) {
if (deadline.getDate() == null || deadline.getDescription().isEmpty()) {
errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены");
return CONFERENCE_PAGE;
}
}
if (errors.hasErrors()) { if (errors.hasErrors()) {
return CONFERENCE_PAGE; return CONFERENCE_PAGE;
} }

View File

@ -62,9 +62,13 @@ public class EventDto {
this.createDate = event.getCreateDate(); this.createDate = event.getCreateDate();
this.updateDate = event.getUpdateDate(); this.updateDate = event.getUpdateDate();
this.description = event.getDescription(); this.description = event.getDescription();
this.paperDto = new PaperDto(event.getPaper());
this.recipients = convert(event.getRecipients(), UserDto::new); this.recipients = convert(event.getRecipients(), UserDto::new);
this.conferenceDto = new ConferenceDto(event.getConference()); if (paperDto != null) {
this.paperDto = new PaperDto(event.getPaper());
}
if (conferenceDto != null) {
this.conferenceDto = new ConferenceDto(event.getConference());
}
} }
public Integer getId() { public Integer getId() {

View File

@ -150,10 +150,10 @@
</a> </a>
<a class="paper-name" <a class="paper-name"
th:unless="*{papers[__${rowStat.index}__].id !=null}"> th:unless="*{papers[__${rowStat.index}__].id !=null}">
<span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=*{papers[__${rowStat.index}__].status})"/>
<span th:text="*{papers[__${rowStat.index}__].title}"> <span th:text="*{papers[__${rowStat.index}__].title}">
Имя статьи Имя статьи
</span> </span>
<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="Удалить" name="removePaper" th:value="${rowStat.index}"/> alt="Удалить" name="removePaper" th:value="${rowStat.index}"/>