#55 added method in controller

This commit is contained in:
Nightblade73 2019-04-08 22:04:30 +04:00
parent 518f587eed
commit 689a7799e3
3 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.conference.model.ConferenceDto;
import ru.ulstu.conference.model.ConferenceFilterDto;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.deadline.model.Deadline;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
@ -61,6 +62,14 @@ public class ConferenceController {
}
@PostMapping(value = "/conference", params = "addDeadline")
public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) {
filterEmptyDeadlines(conferenceDto);
hasErrors(errors, CONFERENCE_PAGE);
conferenceDto.getDeadlines().add(new Deadline());
return CONFERENCE_PAGE;
}
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream()
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))

View File

@ -68,7 +68,7 @@
class="alert alert-danger">Incorrect title</p>
<div class="form-group d-flex justify-content-end">
<input type="submit" id="add-deadline" name="add-deadline"
<input type="submit" id="addDeadline" name="addDeadline"
class="btn btn-primary"
value="Добавить дедлайн"/>
</div>

View File

@ -21,7 +21,7 @@
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./conference?id=0" class="btn btn-light toolbar-button">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
Добавить конференцию</a>
Новая конференцию</a>
</div>
</div>