show status

pull/149/head
Anton Romanov 6 years ago
parent dfe44ab842
commit 3d4a7b09f3

@ -3,19 +3,17 @@ package ru.ulstu.paper.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestMapping;
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.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperFilterDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.service.PaperService;
import javax.validation.Valid;
@ -55,15 +53,15 @@ public class PaperController {
return "redirect:/papers/papers";
}
@DeleteMapping("/{paper-id}")
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) throws IOException {
@GetMapping("/delete/{paper-id}")
public String delete(@PathVariable("paper-id") Integer paperId) throws IOException {
paperService.delete(paperId);
return new Response<>(true);
return "redirect:/papers/papers";
}
@GetMapping("/statuses")
public Response<List<PaperStatusDto>> getPaperStatuses() {
return new Response<>(paperService.getPaperStatuses());
@ModelAttribute("allStatuses")
public List<Paper.PaperStatus> getPaperStatuses() {
return paperService.getPaperStatuses();
}
@PostMapping("/filter")

@ -19,7 +19,6 @@ import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Entity
@ -32,17 +31,26 @@ public class Paper extends BaseEntity implements UserContainer {
COMPLETED("Завершена"),
FAILED("Провалены сроки");
private String name;
private String statusName;
PaperStatus(String name) {
this.name = name;
this.statusName = name;
}
public String getName() {
return name;
public String getStatusName() {
return statusName;
}
}
/*public enum PaperStatus {
ATTENTION,
ON_PREPARATION,
ON_REVIEW,
DRAFT,
COMPLETED,
FAILED;
}*/
@NotBlank
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.PaperDto;
import ru.ulstu.paper.model.PaperFilterDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.repository.PaperRepository;
import ru.ulstu.user.model.User;
import ru.ulstu.user.service.UserService;
@ -111,8 +110,8 @@ public class PaperService {
paperRepository.delete(paper);
}
public List<PaperStatusDto> getPaperStatuses() {
return convert(Arrays.asList(Paper.PaperStatus.values()), PaperStatusDto::new);
public List<Paper.PaperStatus> getPaperStatuses() {
return Arrays.asList(Paper.PaperStatus.values());
}
@Transactional

@ -31,10 +31,9 @@
</span>
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
<input class="id-class" type="hidden" th:value="${paper.id}"/>
<span class="remove-paper pull-right d-none"
onclick="deletePaper($(this), '#paper-list', '.paper-row');">
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}">
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</a>
</div>
</div>

@ -41,8 +41,8 @@
<div class="form-group">
<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>
</div>

@ -58,7 +58,7 @@
<script type="text/javascript">
/*<![CDATA[*/
/* $(document).ready(function () {
$(document).ready(function () {
$(".paper-row").mouseenter(function (event) {
var paperRow = $(event.target).closest(".paper-row");
$(paperRow).css("background-color", "#f8f9fa");
@ -70,7 +70,7 @@
$(paperRow).css("background-color", "white");
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
});
});*/
});
/*]]>*/
</script>

Loading…
Cancel
Save