From b4a2a8086ddd3f3301716ce6971512939e2cd521 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 12 Apr 2019 15:51:06 +0400 Subject: [PATCH] #62 remove verification of empty deadline list --- .../conference/controller/ConferenceController.java | 9 +++------ .../java/ru/ulstu/conference/model/ConferenceDto.java | 10 ++-------- .../resources/templates/conferences/conference.html | 4 +--- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 006a1de..750d46d 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -19,9 +19,7 @@ import java.io.IOException; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.core.controller.Navigation.CONFERENCES_PAGE; -import static ru.ulstu.core.controller.Navigation.CONFERENCE_PAGE; -import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; +import static ru.ulstu.core.controller.Navigation.*; @Controller() @@ -52,9 +50,6 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "save") public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); - if (conferenceDto.getDeadlines().isEmpty()) { - errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); - } if (errors.hasErrors()) return CONFERENCE_PAGE; conferenceService.save(conferenceDto); @@ -69,6 +64,8 @@ public class ConferenceController { return CONFERENCE_PAGE; conferenceDto.getDeadlines().add(new Deadline()); return CONFERENCE_PAGE; + + } private void filterEmptyDeadlines(ConferenceDto conferenceDto) { diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index 277e783..eb67d39 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -11,11 +11,7 @@ import ru.ulstu.user.model.UserDto; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import static ru.ulstu.core.util.StreamApiUtils.convert; @@ -36,7 +32,6 @@ public class ConferenceDto { @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDate = new Date(); - @NotEmpty private List deadlines = new ArrayList<>(); private Set userIds = new HashSet<>(); private Set paperIds = new HashSet<>(); @@ -45,8 +40,7 @@ public class ConferenceDto { private Integer filterUserId; public ConferenceDto() { - deadlines.add(new Deadline()); - } + } @JsonCreator public ConferenceDto(@JsonProperty("id") Integer id, diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index cbc0019..08083a5 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -60,9 +60,7 @@ th:field="*{deadlines[__${rowStat.index}__].date}"/> Удалить + th:onclick="|$(this).parent().remove();|"/>