#55 added html side, don't work, because can't parse date, like in deadlines

This commit is contained in:
Nightblade73 2019-04-05 18:01:43 +04:00
parent 67bfad22f9
commit eb524d49d0
3 changed files with 31 additions and 17 deletions

View File

@ -11,7 +11,6 @@ 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.paper.model.PaperDto;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
@ -27,8 +26,8 @@ public class ConferenceController {
private final ConferenceService conferenceService;
public ConferenceController(ConferenceService paperService) {
this.conferenceService = paperService;
public ConferenceController(ConferenceService conferenceService) {
this.conferenceService = conferenceService;
}
@GetMapping("/conferences")
@ -42,7 +41,7 @@ public class ConferenceController {
if (id != null && id > 0) {
modelMap.put("conferenceDto", conferenceService.findOneDto(id));
} else {
modelMap.put("conferenceDto", new PaperDto());
modelMap.put("conferenceDto", new ConferenceDto());
}
}
@ -53,10 +52,12 @@ public class ConferenceController {
errors.rejectValue("deadlines", "errorCode", "Не может быть пустым");
}
if (errors.hasErrors()) {
System.out.println("я здесь 2");
return "/conferences/conference";
}
conferenceService.save(conferenceDto);
return "redirect:/conferences/conferences";
}
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {

View File

@ -3,6 +3,7 @@ package ru.ulstu.conference.model;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
@ -41,11 +42,13 @@ public class Conference extends BaseEntity {
@Column(name = "begin_date")
@Temporal(TemporalType.TIMESTAMP)
private Date beginDate = new Date();
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date beginDate;
@Column(name = "end_date")
@Temporal(TemporalType.TIMESTAMP)
private Date endDate = new Date();
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "conference_id", unique = true)

View File

@ -28,36 +28,44 @@
<div class="form-group">
<label for="title">Название:</label>
<input class="form-control" id="title" type="text"
<input class="form-control" th:field="*{title}" id="title" type="text"
placeholder="Название конференции"/>
</div>
<div class="form-group">
<label for="url">URL:</label>
<input class="form-control" id="url" type="text"
<input class="form-control" th:field="*{url}" id="url" type="text"
placeholder="URL адрес"/>
</div>
<div class="form-group">
<label for="description">Описание:</label>
<textarea class="form-control" rows="8" id="description">
<textarea class="form-control" rows="8" th:field="*{description}" id="description">
</textarea>
</div>
<div class="form-group">
<label for="deadlines">Дедлайны:</label>
<div class="deadline-list form-control list-group" id="deadlines">
<div class="deadline d-flex p-0 list-group-item list-group-horizontal">
<div class="deadline d-flex p-0 list-group-item list-group-horizontal"
th:each="deadline, rowStat : *{deadlines}">
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<input class="deadline-text col-md list-group-item" type="text"
placeholder="Текст дедлайна"/>
<input class="list-group-item" type="date"/>
placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/>
<input class="list-group-item" type="date" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/>
<img class="icon icon-delete grey-border" src="/img/conference/delete.png"
alt="Удалить"/>
alt="Удалить"
th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');
$('#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>
<div class="form-group d-flex justify-content-end">
<input type="submit" id="add-deadline" name="add-deadline"
@ -72,11 +80,13 @@
<div class="row" id="dates">
<div class="d-flex col justify-content-between dates-panel">
<div class="date">
<input class="grey-border form-control" type="date" id="date-begin"/>
<input class="grey-border form-control" type="date"
th:field="*{beginDate}" id="begin-date"/>
</div>
<div class="date">
<input class="grey-border form-control" type="date" id="date-end"/>
<input class="grey-border form-control" type="date"
th:field="*{endDate}" id="end-date"/>
</div>
</div>
</div>