Resolve "Ping конференции в списке конференций" #196
@ -68,7 +68,15 @@ public class ConferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/conferences", params = "deleteConference")
|
@PostMapping(value = "/conferences", params = "deleteConference")
|
||||||
public String delete(@RequestParam("deleteConference") Integer conferenceId) throws IOException {
|
public String delete(@Valid ConferenceFilterDto conferenceFilterDto,
|
||||||
|
@RequestParam("deleteConference") Integer conferenceId,
|
||||||
|
Errors errors,
|
||||||
|
ModelMap modelMap) throws IOException {
|
||||||
|
if (true) {
|
||||||
|
errors.reject("relationExist", "Статья прикреплена к конференции");
|
||||||
|
filterConferences(conferenceFilterDto, modelMap);
|
||||||
|
return CONFERENCES_PAGE;
|
||||||
|
}
|
||||||
conferenceService.delete(conferenceId);
|
conferenceService.delete(conferenceId);
|
||||||
return String.format(REDIRECT_TO, CONFERENCES_PAGE);
|
return String.format(REDIRECT_TO, CONFERENCES_PAGE);
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,14 @@ public class ConferenceFilterDto {
|
|||||||
public ConferenceFilterDto() {
|
public ConferenceFilterDto() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos, Integer filterUserId, Integer year) {
|
public ConferenceFilterDto(List<ConferenceDto> conferences, Integer filterUserId, Integer year) {
|
||||||
this.conferences = conferenceDtos;
|
this.conferences = conferences;
|
||||||
this.filterUserId = filterUserId;
|
this.filterUserId = filterUserId;
|
||||||
this.year = year;
|
this.year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos) {
|
public ConferenceFilterDto(List<ConferenceDto> conferences) {
|
||||||
this(conferenceDtos, null, null);
|
this(conferences, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ConferenceDto> getConferences() {
|
public List<ConferenceDto> getConferences() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.ulstu.paper.controller;
|
package ru.ulstu.paper.controller;
|
||||||
|
|
||||||
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@ -95,8 +96,15 @@ public class PaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/delete/{paper-id}")
|
@GetMapping("/delete/{paper-id}")
|
||||||
public String delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
public String delete(@Valid PaperFilterDto paperFilterDto,
|
||||||
|
@PathVariable("paper-id") Integer paperId,
|
||||||
|
Errors errors) throws IOException {
|
||||||
|
try {
|
||||||
paperService.delete(paperId);
|
paperService.delete(paperId);
|
||||||
|
} catch (DataIntegrityViolationException e) {
|
||||||
|
errors.reject("relationExist", "Статья прикреплена к конференции");
|
||||||
|
return "/papers/papers";
|
||||||
|
}
|
||||||
return "redirect:/papers/papers";
|
return "redirect:/papers/papers";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div layout:fragment="content">
|
<div layout:fragment="content">
|
||||||
<form id="conferences-form" method="post">
|
<form id="conferences-form" method="post" th:action="@{'/conferences/conferences'}"
|
||||||
|
th:object="${filteredConferences}">
|
||||||
|
|
||||||
<section id="conferences">
|
<section id="conferences">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row" id="conference-list">
|
<div class="row" id="conference-list">
|
||||||
@ -18,10 +20,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
|
||||||
|
<p th:each="err : ${#fields.errors('*')}" th:text="${err}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9 col-sm-12">
|
<div class="col-md-9 col-sm-12">
|
||||||
<!--<input type="hidden" th:field="${filteredConferences}"/>-->
|
<th:block th:each="conference : *{conferences}">
|
||||||
<th:block th:each="conference : ${filteredConferences.conferences}">
|
|
||||||
<div th:replace="conferences/fragments/confLineFragment :: confLine(conference=${conference})"/>
|
<div th:replace="conferences/fragments/confLineFragment :: confLine(conference=${conference})"/>
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="container" layout:fragment="content">
|
<div class="container" layout:fragment="content">
|
||||||
<form id="papers-form" method="post" th:action="@{'/papers/papers'}">
|
<form id="papers-form" method="post" th:action="@{'/papers/papers'}"
|
||||||
|
th:object="${filteredPapers}">
|
||||||
<input th:type="hidden" name="paperDeleteId" id="paperDeleteId"/>
|
<input th:type="hidden" name="paperDeleteId" id="paperDeleteId"/>
|
||||||
<section id="papers">
|
<section id="papers">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -17,7 +18,11 @@
|
|||||||
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
|
||||||
|
<p th:each="err : ${#fields.errors('*')}" th:text="${err}"></p>
|
||||||
|
</div>
|
||||||
<div class="col-md-9 col-sm-12">
|
<div class="col-md-9 col-sm-12">
|
||||||
<th:block th:each="paper : ${filteredPapers.papers}">
|
<th:block th:each="paper : ${filteredPapers.papers}">
|
||||||
<div th:replace="papers/fragments/paperLineFragment :: paperLine(paper=${paper})"/>
|
<div th:replace="papers/fragments/paperLineFragment :: paperLine(paper=${paper})"/>
|
||||||
@ -43,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div th:replace="fragments/noRecordsFragment :: noRecords(entities=${filteredPapers.papers}, noRecordsMessage=' одной статьи', url='paper')"/>
|
<!--<div th:replace="fragments/noRecordsFragment :: noRecords(entities=${filteredPapers.papers}, noRecordsMessage=' одной статьи', url='paper')"/>-->
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user