This commit is contained in:
ASH 2019-04-11 00:14:03 +04:00
parent f019806a8e
commit 5eae7305c4
9 changed files with 24 additions and 21 deletions

View File

@ -11,6 +11,7 @@ import ru.ulstu.tags.model.Tag;
import ru.ulstu.tags.model.TagDto; import ru.ulstu.tags.model.TagDto;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import ru.ulstu.students.service.TaskService; import ru.ulstu.students.service.TaskService;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -55,7 +56,7 @@ public class TaskController {
if (taskDto.getDeadlines().isEmpty()) { if (taskDto.getDeadlines().isEmpty()) {
errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); errors.rejectValue("deadlines", "errorCode", "Не может быть пустым");
} }
if(errors.hasErrors()) if (errors.hasErrors())
return TASK_PAGE; return TASK_PAGE;
taskService.save(taskDto); taskService.save(taskDto);
return String.format(REDIRECT_TO, TASKS_PAGE); return String.format(REDIRECT_TO, TASKS_PAGE);
@ -64,7 +65,7 @@ public class TaskController {
@PostMapping(value = "/task", params = "addDeadline") @PostMapping(value = "/task", params = "addDeadline")
public String addDeadline(@Valid TaskDto taskDto, Errors errors) { public String addDeadline(@Valid TaskDto taskDto, Errors errors) {
filterEmptyDeadlines(taskDto); filterEmptyDeadlines(taskDto);
if(errors.hasErrors()) if (errors.hasErrors())
return TASK_PAGE; return TASK_PAGE;
taskDto.getDeadlines().add(new Deadline()); taskDto.getDeadlines().add(new Deadline());
return TASK_PAGE; return TASK_PAGE;

View File

@ -43,7 +43,7 @@ public class TaskDto {
@JsonProperty("status") Task.TaskStatus status, @JsonProperty("status") Task.TaskStatus status,
@JsonProperty("deadlines") List<Deadline> deadlines, @JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("tagIds") Set<Integer> tagIds, @JsonProperty("tagIds") Set<Integer> tagIds,
@JsonProperty("tags") Set<TagDto> tags){ @JsonProperty("tags") Set<TagDto> tags) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.status = status; this.status = status;
@ -142,6 +142,6 @@ public class TaskDto {
return StringUtils.abbreviate(tags return StringUtils.abbreviate(tags
.stream() .stream()
.map(tag -> tag.getTagName()) .map(tag -> tag.getTagName())
.collect(Collectors.joining(", ")), MAX_TAGS_LENGTH ); .collect(Collectors.joining(", ")), MAX_TAGS_LENGTH);
} }
} }

View File

@ -28,7 +28,7 @@ public class TaskService {
private final TagService tagService; private final TagService tagService;
public TaskService(TaskRepository grantRepository, public TaskService(TaskRepository grantRepository,
DeadlineService deadlineService, TagService tagService){ DeadlineService deadlineService, TagService tagService) {
this.taskRepository = grantRepository; this.taskRepository = grantRepository;
this.deadlineService = deadlineService; this.deadlineService = deadlineService;
this.tagService = tagService; this.tagService = tagService;

View File

@ -3,6 +3,6 @@ package ru.ulstu.tags.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.tags.model.TagDto; import ru.ulstu.tags.model.TagDto;
public interface TagRepository extends JpaRepository<TagDto, Integer>{ public interface TagRepository extends JpaRepository<TagDto, Integer> {
} }

View File

@ -5,6 +5,7 @@ import org.springframework.stereotype.Service;
import ru.ulstu.tags.model.TagDto; import ru.ulstu.tags.model.TagDto;
import ru.ulstu.tags.repository.TagRepository; import ru.ulstu.tags.repository.TagRepository;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -6,12 +6,12 @@
<body> <body>
<div th:fragment="taskLine (task)" class="row text-left task-row" style="background-color: white;"> <div th:fragment="taskLine (task)" class="row text-left task-row" style="background-color: white;">
<div class="col"> <div class="col">
<span th:replace="students/fragments/taskStatusFragment :: taskStatus(taskStatus=${task.status})" /> <span th:replace="students/fragments/taskStatusFragment :: taskStatus(taskStatus=${task.status})"/>
<a th:href="@{'task?id='+${task.id}}"> <a th:href="@{'task?id='+${task.id}}">
<span class="h6" th:text="${task.title}"></span> <span class="h6" th:text="${task.title}"></span>
<span class="text-muted" th:text="${task.tagsString}" /> <span class="text-muted" th:text="${task.tagsString}"/>
</a> </a>
<input class="id-class" type="hidden" th:value="${task.id}" /> <input class="id-class" type="hidden" th:value="${task.id}"/>
<a class="remove-task pull-right d-none" th:href="@{'/students/delete/'+${task.id}}" <a class="remove-task pull-right d-none" th:href="@{'/students/delete/'+${task.id}}"
data-confirm="Удалить задачу?"> data-confirm="Удалить задачу?">
<i class="fa fa-trash" aria-hidden="true"></i> <i class="fa fa-trash" aria-hidden="true"></i>

View File

@ -3,7 +3,8 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"> layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head> <head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css"/> <link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css"/>
<link rel="stylesheet" href="../css/tasks.css"/> <link rel="stylesheet" href="../css/tasks.css"/>
</head> </head>
<body> <body>