#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.ConferenceDto;
import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.model.ConferenceFilterDto;
import ru.ulstu.conference.service.ConferenceService; import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.paper.model.PaperDto;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid; import javax.validation.Valid;
@ -27,8 +26,8 @@ public class ConferenceController {
private final ConferenceService conferenceService; private final ConferenceService conferenceService;
public ConferenceController(ConferenceService paperService) { public ConferenceController(ConferenceService conferenceService) {
this.conferenceService = paperService; this.conferenceService = conferenceService;
} }
@GetMapping("/conferences") @GetMapping("/conferences")
@ -42,7 +41,7 @@ public class ConferenceController {
if (id != null && id > 0) { if (id != null && id > 0) {
modelMap.put("conferenceDto", conferenceService.findOneDto(id)); modelMap.put("conferenceDto", conferenceService.findOneDto(id));
} else { } else {
modelMap.put("conferenceDto", new PaperDto()); modelMap.put("conferenceDto", new ConferenceDto());
} }
} }
@ -53,10 +52,12 @@ public class ConferenceController {
errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); errors.rejectValue("deadlines", "errorCode", "Не может быть пустым");
} }
if (errors.hasErrors()) { if (errors.hasErrors()) {
System.out.println("я здесь 2");
return "/conferences/conference"; return "/conferences/conference";
} }
conferenceService.save(conferenceDto); conferenceService.save(conferenceDto);
return "redirect:/conferences/conferences"; return "redirect:/conferences/conferences";
} }
private void filterEmptyDeadlines(ConferenceDto conferenceDto) { 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.Paper;
@ -41,11 +42,13 @@ public class Conference extends BaseEntity {
@Column(name = "begin_date") @Column(name = "begin_date")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date beginDate = new Date(); @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date beginDate;
@Column(name = "end_date")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date endDate = new Date(); @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "conference_id", unique = true) @JoinColumn(name = "conference_id", unique = true)

View File

@ -28,36 +28,44 @@
<div class="form-group"> <div class="form-group">
<label for="title">Название:</label> <label for="title">Название:</label>
<input class="form-control" id="title" type="text" <input class="form-control" th:field="*{title}" id="title" type="text"
placeholder="Название конференции"/> placeholder="Название конференции"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="url">URL:</label> <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 адрес"/> placeholder="URL адрес"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="description">Описание:</label> <label for="description">Описание:</label>
<textarea class="form-control" rows="8" id="description"> <textarea class="form-control" rows="8" th:field="*{description}" id="description">
</textarea> </textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="deadlines">Дедлайны:</label> <label for="deadlines">Дедлайны:</label>
<div class="deadline-list form-control list-group" id="deadlines"> <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" <input class="deadline-text col-md list-group-item" type="text"
placeholder="Текст дедлайна"/> placeholder="Описание"
<input class="list-group-item" type="date"/> 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" <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> </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"> <div class="form-group d-flex justify-content-end">
<input type="submit" id="add-deadline" name="add-deadline" <input type="submit" id="add-deadline" name="add-deadline"
@ -72,11 +80,13 @@
<div class="row" id="dates"> <div class="row" id="dates">
<div class="d-flex col justify-content-between dates-panel"> <div class="d-flex col justify-content-between dates-panel">
<div class="date"> <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>
<div class="date"> <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> </div>
</div> </div>