Resolve "Добавление дедлайна для конференции" #176

Merged
VladimirZarayskiy merged 1 commits from 61-adding-deadline into dev 5 years ago

@ -22,7 +22,6 @@ 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.hasErrors;
@Controller()
@ -56,7 +55,8 @@ public class ConferenceController {
if (conferenceDto.getDeadlines().isEmpty()) {
errors.rejectValue("deadlines", "errorCode", "Не может быть пустым");
}
hasErrors(errors, CONFERENCE_PAGE);
if (errors.hasErrors())
return CONFERENCE_PAGE;
conferenceService.save(conferenceDto);
return String.format(REDIRECT_TO, CONFERENCES_PAGE);
@ -65,7 +65,8 @@ public class ConferenceController {
@PostMapping(value = "/conference", params = "addDeadline")
public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) {
filterEmptyDeadlines(conferenceDto);
hasErrors(errors, CONFERENCE_PAGE);
if (errors.hasErrors())
return CONFERENCE_PAGE;
conferenceDto.getDeadlines().add(new Deadline());
return CONFERENCE_PAGE;
}

@ -30,6 +30,9 @@
<label for="title">Название:</label>
<input class="form-control" th:field="*{title}" id="title" type="text"
placeholder="Название конференции"/>
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
@ -61,11 +64,12 @@
$('#deadlines${rowStat.index}\\.date').val('');
$('#addDeadline').click();|"/>
</div>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
<div class="form-group d-flex justify-content-end">
<input type="submit" id="addDeadline" name="addDeadline"

Loading…
Cancel
Save