show status
This commit is contained in:
parent
dfe44ab842
commit
3d4a7b09f3
@ -3,19 +3,17 @@ package ru.ulstu.paper.controller;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperFilterDto;
|
import ru.ulstu.paper.model.PaperFilterDto;
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -55,15 +53,15 @@ public class PaperController {
|
|||||||
return "redirect:/papers/papers";
|
return "redirect:/papers/papers";
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{paper-id}")
|
@GetMapping("/delete/{paper-id}")
|
||||||
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
public String delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
||||||
paperService.delete(paperId);
|
paperService.delete(paperId);
|
||||||
return new Response<>(true);
|
return "redirect:/papers/papers";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/statuses")
|
@ModelAttribute("allStatuses")
|
||||||
public Response<List<PaperStatusDto>> getPaperStatuses() {
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
||||||
return new Response<>(paperService.getPaperStatuses());
|
return paperService.getPaperStatuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/filter")
|
@PostMapping("/filter")
|
||||||
|
@ -19,7 +19,6 @@ import javax.persistence.TemporalType;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -32,17 +31,26 @@ public class Paper extends BaseEntity implements UserContainer {
|
|||||||
COMPLETED("Завершена"),
|
COMPLETED("Завершена"),
|
||||||
FAILED("Провалены сроки");
|
FAILED("Провалены сроки");
|
||||||
|
|
||||||
private String name;
|
private String statusName;
|
||||||
|
|
||||||
PaperStatus(String name) {
|
PaperStatus(String name) {
|
||||||
this.name = name;
|
this.statusName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getStatusName() {
|
||||||
return name;
|
return statusName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public enum PaperStatus {
|
||||||
|
ATTENTION,
|
||||||
|
ON_PREPARATION,
|
||||||
|
ON_REVIEW,
|
||||||
|
DRAFT,
|
||||||
|
COMPLETED,
|
||||||
|
FAILED;
|
||||||
|
}*/
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package ru.ulstu.paper.model;
|
|
||||||
|
|
||||||
public class PaperStatusDto {
|
|
||||||
private final String id;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public PaperStatusDto(Paper.PaperStatus status) {
|
|
||||||
this.id = status.name();
|
|
||||||
this.name = status.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,6 @@ import ru.ulstu.file.service.FileService;
|
|||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperFilterDto;
|
import ru.ulstu.paper.model.PaperFilterDto;
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
|
||||||
import ru.ulstu.paper.repository.PaperRepository;
|
import ru.ulstu.paper.repository.PaperRepository;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
@ -111,8 +110,8 @@ public class PaperService {
|
|||||||
paperRepository.delete(paper);
|
paperRepository.delete(paper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperStatusDto> getPaperStatuses() {
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
||||||
return convert(Arrays.asList(Paper.PaperStatus.values()), PaperStatusDto::new);
|
return Arrays.asList(Paper.PaperStatus.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
</span>
|
</span>
|
||||||
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
||||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||||
<span class="remove-paper pull-right d-none"
|
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}">
|
||||||
onclick="deletePaper($(this), '#paper-list', '.paper-row');">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
</span>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="status">Статус:</label>
|
<label for="status">Статус:</label>
|
||||||
<select class="form-control" id="status">
|
<select class="form-control" th:field="*{status}" id="status">
|
||||||
|
<option th:each="status : ${allStatuses}" th:value="${status}" th:text="${status.statusName}">Status</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/*<![CDATA[*/
|
/*<![CDATA[*/
|
||||||
/* $(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(".paper-row").mouseenter(function (event) {
|
$(".paper-row").mouseenter(function (event) {
|
||||||
var paperRow = $(event.target).closest(".paper-row");
|
var paperRow = $(event.target).closest(".paper-row");
|
||||||
$(paperRow).css("background-color", "#f8f9fa");
|
$(paperRow).css("background-color", "#f8f9fa");
|
||||||
@ -70,7 +70,7 @@
|
|||||||
$(paperRow).css("background-color", "white");
|
$(paperRow).css("background-color", "white");
|
||||||
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
|
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
|
||||||
});
|
});
|
||||||
});*/
|
});
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user