From 9b697c6f3f7302a4693f71ad4fed76b688b10258 Mon Sep 17 00:00:00 2001 From: ASH Date: Tue, 9 Apr 2019 23:18:39 +0400 Subject: [PATCH 01/20] #74 adding models, controllers and services --- .../ulstu/students/controller/Navigation.java | 16 ++ .../students/controller/TaskController.java | 85 ++++++++++ .../java/ru/ulstu/students/model/Task.java | 113 ++++++++++++++ .../java/ru/ulstu/students/model/TaskDto.java | 147 ++++++++++++++++++ .../students/repository/TaskRepository.java | 7 + .../ulstu/students/service/TaskService.java | 98 ++++++++++++ src/main/java/ru/ulstu/tags/model/Tag.java | 23 +++ src/main/java/ru/ulstu/tags/model/TagDto.java | 43 +++++ .../ulstu/tags/repository/TagRepository.java | 8 + .../ru/ulstu/tags/service/TagService.java | 46 ++++++ .../fragments/taskDashboardFragment.html | 12 +- .../students/fragments/taskLineFragment.html | 14 +- .../fragments/taskStatusFragment.html | 22 +-- .../resources/templates/students/task.html | 45 ++++-- .../resources/templates/students/tasks.html | 14 +- 15 files changed, 636 insertions(+), 57 deletions(-) create mode 100644 src/main/java/ru/ulstu/students/controller/Navigation.java create mode 100644 src/main/java/ru/ulstu/students/controller/TaskController.java create mode 100644 src/main/java/ru/ulstu/students/model/Task.java create mode 100644 src/main/java/ru/ulstu/students/model/TaskDto.java create mode 100644 src/main/java/ru/ulstu/students/repository/TaskRepository.java create mode 100644 src/main/java/ru/ulstu/students/service/TaskService.java create mode 100644 src/main/java/ru/ulstu/tags/model/Tag.java create mode 100644 src/main/java/ru/ulstu/tags/model/TagDto.java create mode 100644 src/main/java/ru/ulstu/tags/repository/TagRepository.java create mode 100644 src/main/java/ru/ulstu/tags/service/TagService.java diff --git a/src/main/java/ru/ulstu/students/controller/Navigation.java b/src/main/java/ru/ulstu/students/controller/Navigation.java new file mode 100644 index 0000000..3804a8b --- /dev/null +++ b/src/main/java/ru/ulstu/students/controller/Navigation.java @@ -0,0 +1,16 @@ +package ru.ulstu.students.controller; + +import org.springframework.validation.Errors; + +public class Navigation { + public static final String REDIRECT_TO = "redirect:%s"; + public static final String TASKS_PAGE = "/students/tasks"; + public static final String TASK_PAGE = "/students/task"; + + public static String hasErrors(Errors errors, String page) { + if (errors.hasErrors()) { + return page; + } + return null; + } +} diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java new file mode 100644 index 0000000..76b2f2b --- /dev/null +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -0,0 +1,85 @@ +package ru.ulstu.students.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.students.model.Task; +import ru.ulstu.students.model.TaskDto; +import ru.ulstu.tags.model.Tag; +import springfox.documentation.annotations.ApiIgnore; +import ru.ulstu.students.service.TaskService; +import javax.validation.Valid; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; + +import static org.springframework.util.StringUtils.isEmpty; +import static ru.ulstu.students.controller.Navigation.*; + +@Controller() +@RequestMapping(value = "/students") +@ApiIgnore +public class TaskController { + + private final TaskService taskService; + + public TaskController(TaskService grantService) { + this.taskService = grantService; + } + + @GetMapping("/tasks") + public void getTasks(ModelMap modelMap) { + modelMap.put("tasks", taskService.findAllDto()); + } + + @GetMapping("/dashboard") + public void getDashboard(ModelMap modelMap) { + modelMap.put("tasks", taskService.findAllDto()); + } + + @GetMapping("/task") + public void getTask(ModelMap modelMap, @RequestParam(value = "id") Integer id) { + if (id != null && id > 0) { + modelMap.put("taskDto", taskService.findOneDto(id)); + } else { + modelMap.put("taskDto", new TaskDto()); + } + } + + @PostMapping(value = "/task", params = "save") + public String save(@Valid TaskDto taskDto, Errors errors) throws IOException { + filterEmptyDeadlines(taskDto); + if (taskDto.getDeadlines().isEmpty()) { + errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); + } + hasErrors(errors, TASK_PAGE); + taskService.save(taskDto); + return String.format(REDIRECT_TO, TASK_PAGE); + } + + @PostMapping(value = "/task", params = "addDeadline") + public String addDeadline(@Valid TaskDto taskDto, Errors errors) { + filterEmptyDeadlines(taskDto); + hasErrors(errors, TASK_PAGE); + taskDto.getDeadlines().add(new Deadline()); + return TASK_PAGE; + } + + @ModelAttribute("allStatuses") + public List getTaskStatuses() { + return taskService.getTaskStatuses(); + } + + @ModelAttribute("allTags") + public List getAllTags() { + return taskService.getTaskTags(); + } + + private void filterEmptyDeadlines(TaskDto taskDto) { + taskDto.setDeadlines(taskDto.getDeadlines().stream() + .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) + .collect(Collectors.toList())); + } +} diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java new file mode 100644 index 0000000..296ddcb --- /dev/null +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -0,0 +1,113 @@ +package ru.ulstu.students.model; + +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.validator.constraints.NotBlank; +import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.tags.model.Tag; + +import javax.persistence.*; +import java.util.*; + +@Entity +public class Task extends BaseEntity { + + public enum TaskStatus { + IN_WORK("В работе"), + COMPLETED("Завершен"), + FAILED("Провалены сроки"), + LOADED_FROM_KIAS("Загружен автоматически"); + + private String statusName; + + TaskStatus(String name) { + this.statusName = name; + } + + public String getStatusName() { + return statusName; + } + } + + @NotBlank + private String title; + + private String description; + + @Enumerated(value = EnumType.STRING) + private ru.ulstu.students.model.Task.TaskStatus status = TaskStatus.IN_WORK; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @JoinColumn(name = "task_id", unique = true) + @Fetch(FetchMode.SUBSELECT) + @OrderBy("date") + private List deadlines = new ArrayList<>(); + + @Column(name = "create_date") + @Temporal(TemporalType.TIMESTAMP) + private Date createDate = new Date(); + + @Column(name = "update_date") + @Temporal(TemporalType.TIMESTAMP) + private Date updateDate = new Date(); + + @ManyToMany(fetch = FetchType.EAGER) + private Set tags = new HashSet<>(); + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public TaskStatus getStatus() { + return status; + } + + public void setStatus(TaskStatus status) { + this.status = status; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } +} diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java new file mode 100644 index 0000000..62e73b4 --- /dev/null +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -0,0 +1,147 @@ +package ru.ulstu.students.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; +import org.hibernate.validator.constraints.NotEmpty; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.tags.model.TagDto; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static ru.ulstu.core.util.StreamApiUtils.convert; + +public class TaskDto { + + private final static int MAX_TAGS_LENGTH = 50; + + private Integer id; + @NotEmpty + private String title; + private String description; + private Task.TaskStatus status; + private List deadlines = new ArrayList<>(); + private Date createDate; + private Date updateDate; + private Set tagIds; + private Set tags; + + public TaskDto() { + deadlines.add(new Deadline()); + } + + @JsonCreator + public TaskDto(@JsonProperty("id") Integer id, + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("createDate") Date createDate, + @JsonProperty("updateDate") Date updateDate, + @JsonProperty("status") Task.TaskStatus status, + @JsonProperty("deadlines") List deadlines, + @JsonProperty("tagIds") Set tagIds, + @JsonProperty("tagIds") Set tags){ + this.id = id; + this.title = title; + this.status = status; + this.deadlines = deadlines; + this.createDate = createDate; + this.updateDate = updateDate; + this.description = description; + this.tags = tags; + } + + public TaskDto(Task task) { + this.id = task.getId(); + this.title = task.getTitle(); + this.status = task.getStatus(); + this.deadlines = task.getDeadlines(); + this.createDate = task.getCreateDate(); + this.updateDate = task.getUpdateDate(); + this.description = task.getDescription(); + this.tagIds = convert(task.getTags(), tag -> tag.getId()); + this.tags = convert(task.getTags(), TagDto::new); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Task.TaskStatus getStatus() { + return status; + } + + public void setStatus(Task.TaskStatus status) { + this.status = status; + } + + public List getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public Set getTagIds() { + return tagIds; + } + + public void setTagIds(Set tagIds) { + this.tagIds = tagIds; + } + + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } + + public String getTagsString() { + return StringUtils.abbreviate(tags + .stream() + .map(tag -> tag.getTagName()) + .collect(Collectors.joining(", ")), MAX_TAGS_LENGTH ); + } +} diff --git a/src/main/java/ru/ulstu/students/repository/TaskRepository.java b/src/main/java/ru/ulstu/students/repository/TaskRepository.java new file mode 100644 index 0000000..6f48d1f --- /dev/null +++ b/src/main/java/ru/ulstu/students/repository/TaskRepository.java @@ -0,0 +1,7 @@ +package ru.ulstu.students.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import ru.ulstu.students.model.Task; + +public interface TaskRepository extends JpaRepository { +} diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java new file mode 100644 index 0000000..c3ac558 --- /dev/null +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -0,0 +1,98 @@ +package ru.ulstu.students.service; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import ru.ulstu.deadline.service.DeadlineService; +import ru.ulstu.students.model.Task; +import ru.ulstu.students.model.TaskDto; +import ru.ulstu.students.repository.TaskRepository; +import ru.ulstu.tags.model.Tag; +import ru.ulstu.tags.service.TagService; + +import java.io.IOException; +import java.util.*; + +import static org.springframework.util.ObjectUtils.isEmpty; +import static ru.ulstu.core.util.StreamApiUtils.convert; +import static ru.ulstu.students.model.Task.TaskStatus.IN_WORK; + +@Service +public class TaskService { + + private final static int MAX_DISPLAY_SIZE = 40; + + private final TaskRepository taskRepository; + private final DeadlineService deadlineService; + private final TagService tagService; + + public TaskService(TaskRepository grantRepository, + DeadlineService deadlineService, TagService tagService){ + this.taskRepository = grantRepository; + this.deadlineService = deadlineService; + this.tagService = tagService; + } + + public List findAll() { + return taskRepository.findAll(); + } + + public List findAllDto() { + List tasks = convert(findAll(), TaskDto::new); + tasks.forEach(taskDto -> taskDto.setTitle(StringUtils.abbreviate(taskDto.getTitle(), MAX_DISPLAY_SIZE))); + return tasks; + } + + public TaskDto findOneDto(Integer id) { + return new TaskDto(taskRepository.findOne(id)); + } + + @Transactional + public Integer create(TaskDto taskDto) throws IOException { + Task newTask = copyFromDto(new Task(), taskDto); + newTask = taskRepository.save(newTask); + return newTask.getId(); + } + + private Task copyFromDto(Task task, TaskDto taskDto) throws IOException { + task.setTitle(taskDto.getTitle()); + task.setDescription(taskDto.getDescription()); + task.setStatus(taskDto.getStatus() == null ? IN_WORK : taskDto.getStatus()); + task.setDeadlines(deadlineService.saveOrCreate(taskDto.getDeadlines())); + task.setCreateDate(task.getCreateDate() == null ? new Date() : task.getCreateDate()); + task.setUpdateDate(new Date()); + task.getTags().clear(); + if (taskDto.getTagIds() != null && !taskDto.getTagIds().isEmpty()) { + taskDto.getTagIds().forEach(tagIds -> task.getTags().add(tagService.findById(tagIds))); + } + return task; + } + + @Transactional + public Integer update(TaskDto taskDto) throws IOException { + Task task = taskRepository.findOne(taskDto.getId()); + taskRepository.save(copyFromDto(task, taskDto)); + return task.getId(); + } + + @Transactional + public void delete(Integer taskId) throws IOException { + Task task = taskRepository.findOne(taskId); + taskRepository.delete(task); + } + + public void save(TaskDto taskDto) throws IOException { + if (isEmpty(taskDto.getId())) { + create(taskDto); + } else { + update(taskDto); + } + } + + public List getTaskStatuses() { + return Arrays.asList(Task.TaskStatus.values()); + } + public List getTaskTags() { + return tagService.findAll(); + } +} diff --git a/src/main/java/ru/ulstu/tags/model/Tag.java b/src/main/java/ru/ulstu/tags/model/Tag.java new file mode 100644 index 0000000..78a6274 --- /dev/null +++ b/src/main/java/ru/ulstu/tags/model/Tag.java @@ -0,0 +1,23 @@ +package ru.ulstu.tags.model; + +import org.hibernate.validator.constraints.NotBlank; +import ru.ulstu.core.model.BaseEntity; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "tag") +public class Tag extends BaseEntity { + + @NotBlank + private String tagName; + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } +} diff --git a/src/main/java/ru/ulstu/tags/model/TagDto.java b/src/main/java/ru/ulstu/tags/model/TagDto.java new file mode 100644 index 0000000..80ce085 --- /dev/null +++ b/src/main/java/ru/ulstu/tags/model/TagDto.java @@ -0,0 +1,43 @@ +package ru.ulstu.tags.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.NotEmpty; + +import javax.validation.constraints.Size; + +public class TagDto { + + private Integer id; + @NotEmpty + @Size(max = 50) + private String tagName; + + @JsonCreator + public TagDto(@JsonProperty("id") Integer id, + @JsonProperty("tagName") String tagName) { + this.id = id; + this.tagName = tagName; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public TagDto(Tag tag) { + this.id = tag.getId(); + this.tagName = tag.getTagName(); + } +} diff --git a/src/main/java/ru/ulstu/tags/repository/TagRepository.java b/src/main/java/ru/ulstu/tags/repository/TagRepository.java new file mode 100644 index 0000000..c0a014e --- /dev/null +++ b/src/main/java/ru/ulstu/tags/repository/TagRepository.java @@ -0,0 +1,8 @@ +package ru.ulstu.tags.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import ru.ulstu.tags.model.Tag; + +public interface TagRepository extends JpaRepository { + +} diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java new file mode 100644 index 0000000..45c10f2 --- /dev/null +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -0,0 +1,46 @@ +package ru.ulstu.tags.service; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import ru.ulstu.tags.model.Tag; +import ru.ulstu.tags.model.TagDto; +import ru.ulstu.tags.repository.TagRepository; + +import java.util.List; + +import static ru.ulstu.core.util.StreamApiUtils.convert; + +@Service +public class TagService { + + private final TagRepository tagRepository; + + + public TagService(TagRepository tagRepository) { + + this.tagRepository = tagRepository; + } + + public List findAll() { + return tagRepository.findAll(); + } + +// public List findAllDto() { +// List tag = convert(findAll(), TagDto::new); +// tags.forEach(tagDto -> tagDto.setTitle(StringUtils.abbreviate(tagDto.getTitle(), MAX_DISPLAY_SIZE))); +// return tags; +// } +// +// public TagDto findOneDto(Integer id) { +// return new TagDto(tagRepository.findOne(id)); +// } + + + public List findByIds(List ids) { + return tagRepository.findAll(ids); + } + public Tag findById(Integer id) { + return tagRepository.findOne(id); + } + +} diff --git a/src/main/resources/templates/students/fragments/taskDashboardFragment.html b/src/main/resources/templates/students/fragments/taskDashboardFragment.html index 0daea58..3779ef8 100644 --- a/src/main/resources/templates/students/fragments/taskDashboardFragment.html +++ b/src/main/resources/templates/students/fragments/taskDashboardFragment.html @@ -7,14 +7,14 @@
- - + +
- - - title -

type

+ title +

status

+ +
diff --git a/src/main/resources/templates/students/fragments/taskLineFragment.html b/src/main/resources/templates/students/fragments/taskLineFragment.html index 79ad5d7..44c2d03 100644 --- a/src/main/resources/templates/students/fragments/taskLineFragment.html +++ b/src/main/resources/templates/students/fragments/taskLineFragment.html @@ -4,15 +4,15 @@ -
+
- - - Первая хадач - Курсовая работа + + + + - - + diff --git a/src/main/resources/templates/students/fragments/taskStatusFragment.html b/src/main/resources/templates/students/fragments/taskStatusFragment.html index 8f3d800..ea9a3e9 100644 --- a/src/main/resources/templates/students/fragments/taskStatusFragment.html +++ b/src/main/resources/templates/students/fragments/taskStatusFragment.html @@ -5,18 +5,14 @@ - - -
- -
-
- -
-
+ + + + +
-
+
@@ -25,12 +21,6 @@
-
- -
-
- -
diff --git a/src/main/resources/templates/students/task.html b/src/main/resources/templates/students/task.html index 533c8f6..98c4147 100644 --- a/src/main/resources/templates/students/task.html +++ b/src/main/resources/templates/students/task.html @@ -21,47 +21,60 @@
-
+
- +
- + +

Incorrect title

- +
- +
-
+
-
- +
+
- +
- +
-
+

Incorrect title

Дата создания:
- - + text
@@ -98,8 +111,8 @@
Дата изменения:
- - + text
diff --git a/src/main/resources/templates/students/tasks.html b/src/main/resources/templates/students/tasks.html index 076f7ba..37ade14 100644 --- a/src/main/resources/templates/students/tasks.html +++ b/src/main/resources/templates/students/tasks.html @@ -20,8 +20,8 @@
- -
+ +
@@ -37,16 +37,6 @@
- Добавить задачу diff --git a/src/main/resources/templates/students/task.html b/src/main/resources/templates/students/task.html index 98c4147..ceda3bc 100644 --- a/src/main/resources/templates/students/task.html +++ b/src/main/resources/templates/students/task.html @@ -11,6 +11,7 @@
+
@@ -21,7 +22,7 @@
-
@@ -45,17 +46,19 @@
- +
- +
-
+
- +
@@ -77,18 +80,19 @@ class="alert alert-danger">Incorrect title

-
-
+
- +
@@ -99,7 +103,7 @@
+ th:text="${taskDto.createDate == null ? '' : #dates.format(taskDto.createDate, 'dd.MM.yyyy HH:mm')}"> text
@@ -112,7 +116,7 @@
+ th:text="${taskDto.updateDate == null ? '' : #dates.format(taskDto.updateDate, 'dd.MM.yyyy HH:mm')}"> text
@@ -124,6 +128,7 @@
+
diff --git a/src/main/resources/templates/students/tasks.html b/src/main/resources/templates/students/tasks.html index 37ade14..b1177d8 100644 --- a/src/main/resources/templates/students/tasks.html +++ b/src/main/resources/templates/students/tasks.html @@ -20,7 +20,7 @@
- +
@@ -41,7 +41,6 @@ -
From 5eae7305c4523f2c656b5b660352540cee4a7143 Mon Sep 17 00:00:00 2001 From: ASH Date: Thu, 11 Apr 2019 00:14:03 +0400 Subject: [PATCH 03/20] #74 codestyle --- .../students/controller/TaskController.java | 5 +++-- .../java/ru/ulstu/students/model/TaskDto.java | 18 +++++++++--------- .../ru/ulstu/students/service/TaskService.java | 2 +- .../ulstu/tags/repository/TagRepository.java | 2 +- .../java/ru/ulstu/tags/service/TagService.java | 1 + .../students/fragments/taskLineFragment.html | 8 ++++---- .../fragments/taskNavigationFragment.html | 2 +- .../students/fragments/taskStatusFragment.html | 2 +- .../resources/templates/students/task.html | 5 +++-- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java index 52c9fc7..4b4d12d 100644 --- a/src/main/java/ru/ulstu/students/controller/TaskController.java +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -11,6 +11,7 @@ import ru.ulstu.tags.model.Tag; import ru.ulstu.tags.model.TagDto; import springfox.documentation.annotations.ApiIgnore; import ru.ulstu.students.service.TaskService; + import javax.validation.Valid; import java.io.IOException; import java.util.List; @@ -55,7 +56,7 @@ public class TaskController { if (taskDto.getDeadlines().isEmpty()) { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } - if(errors.hasErrors()) + if (errors.hasErrors()) return TASK_PAGE; taskService.save(taskDto); return String.format(REDIRECT_TO, TASKS_PAGE); @@ -64,7 +65,7 @@ public class TaskController { @PostMapping(value = "/task", params = "addDeadline") public String addDeadline(@Valid TaskDto taskDto, Errors errors) { filterEmptyDeadlines(taskDto); - if(errors.hasErrors()) + if (errors.hasErrors()) return TASK_PAGE; taskDto.getDeadlines().add(new Deadline()); return TASK_PAGE; diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java index 896d9ea..dc41be8 100644 --- a/src/main/java/ru/ulstu/students/model/TaskDto.java +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -36,14 +36,14 @@ public class TaskDto { @JsonCreator public TaskDto(@JsonProperty("id") Integer id, - @JsonProperty("title") String title, - @JsonProperty("description") String description, - @JsonProperty("createDate") Date createDate, - @JsonProperty("updateDate") Date updateDate, - @JsonProperty("status") Task.TaskStatus status, - @JsonProperty("deadlines") List deadlines, - @JsonProperty("tagIds") Set tagIds, - @JsonProperty("tags") Set tags){ + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("createDate") Date createDate, + @JsonProperty("updateDate") Date updateDate, + @JsonProperty("status") Task.TaskStatus status, + @JsonProperty("deadlines") List deadlines, + @JsonProperty("tagIds") Set tagIds, + @JsonProperty("tags") Set tags) { this.id = id; this.title = title; this.status = status; @@ -142,6 +142,6 @@ public class TaskDto { return StringUtils.abbreviate(tags .stream() .map(tag -> tag.getTagName()) - .collect(Collectors.joining(", ")), MAX_TAGS_LENGTH ); + .collect(Collectors.joining(", ")), MAX_TAGS_LENGTH); } } diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java index 22190ee..5e969ac 100644 --- a/src/main/java/ru/ulstu/students/service/TaskService.java +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -28,7 +28,7 @@ public class TaskService { private final TagService tagService; public TaskService(TaskRepository grantRepository, - DeadlineService deadlineService, TagService tagService){ + DeadlineService deadlineService, TagService tagService) { this.taskRepository = grantRepository; this.deadlineService = deadlineService; this.tagService = tagService; diff --git a/src/main/java/ru/ulstu/tags/repository/TagRepository.java b/src/main/java/ru/ulstu/tags/repository/TagRepository.java index 038a740..d4a9c76 100644 --- a/src/main/java/ru/ulstu/tags/repository/TagRepository.java +++ b/src/main/java/ru/ulstu/tags/repository/TagRepository.java @@ -3,6 +3,6 @@ package ru.ulstu.tags.repository; import org.springframework.data.jpa.repository.JpaRepository; import ru.ulstu.tags.model.TagDto; -public interface TagRepository extends JpaRepository{ +public interface TagRepository extends JpaRepository { } diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index 4d8232f..adf2a82 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service; import ru.ulstu.tags.model.TagDto; import ru.ulstu.tags.repository.TagRepository; + import javax.transaction.Transactional; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/main/resources/templates/students/fragments/taskLineFragment.html b/src/main/resources/templates/students/fragments/taskLineFragment.html index 122de6d..baad17e 100644 --- a/src/main/resources/templates/students/fragments/taskLineFragment.html +++ b/src/main/resources/templates/students/fragments/taskLineFragment.html @@ -6,12 +6,12 @@
- - + + - + - + diff --git a/src/main/resources/templates/students/fragments/taskNavigationFragment.html b/src/main/resources/templates/students/fragments/taskNavigationFragment.html index 33f5cdb..cf32140 100644 --- a/src/main/resources/templates/students/fragments/taskNavigationFragment.html +++ b/src/main/resources/templates/students/fragments/taskNavigationFragment.html @@ -16,7 +16,7 @@ diff --git a/src/main/resources/templates/students/fragments/taskStatusFragment.html b/src/main/resources/templates/students/fragments/taskStatusFragment.html index ea9a3e9..77fd529 100644 --- a/src/main/resources/templates/students/fragments/taskStatusFragment.html +++ b/src/main/resources/templates/students/fragments/taskStatusFragment.html @@ -7,7 +7,7 @@ - +
diff --git a/src/main/resources/templates/students/task.html b/src/main/resources/templates/students/task.html index ceda3bc..74ec8f6 100644 --- a/src/main/resources/templates/students/task.html +++ b/src/main/resources/templates/students/task.html @@ -1,9 +1,10 @@ + layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"> - + From b4a2a8086ddd3f3301716ce6971512939e2cd521 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 12 Apr 2019 15:51:06 +0400 Subject: [PATCH 04/20] #62 remove verification of empty deadline list --- .../conference/controller/ConferenceController.java | 9 +++------ .../java/ru/ulstu/conference/model/ConferenceDto.java | 10 ++-------- .../resources/templates/conferences/conference.html | 4 +--- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 006a1de..750d46d 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -19,9 +19,7 @@ import java.io.IOException; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.core.controller.Navigation.CONFERENCES_PAGE; -import static ru.ulstu.core.controller.Navigation.CONFERENCE_PAGE; -import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; +import static ru.ulstu.core.controller.Navigation.*; @Controller() @@ -52,9 +50,6 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "save") public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); - if (conferenceDto.getDeadlines().isEmpty()) { - errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); - } if (errors.hasErrors()) return CONFERENCE_PAGE; conferenceService.save(conferenceDto); @@ -69,6 +64,8 @@ public class ConferenceController { return CONFERENCE_PAGE; conferenceDto.getDeadlines().add(new Deadline()); return CONFERENCE_PAGE; + + } private void filterEmptyDeadlines(ConferenceDto conferenceDto) { diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index 277e783..eb67d39 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -11,11 +11,7 @@ import ru.ulstu.user.model.UserDto; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import static ru.ulstu.core.util.StreamApiUtils.convert; @@ -36,7 +32,6 @@ public class ConferenceDto { @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDate = new Date(); - @NotEmpty private List deadlines = new ArrayList<>(); private Set userIds = new HashSet<>(); private Set paperIds = new HashSet<>(); @@ -45,8 +40,7 @@ public class ConferenceDto { private Integer filterUserId; public ConferenceDto() { - deadlines.add(new Deadline()); - } + } @JsonCreator public ConferenceDto(@JsonProperty("id") Integer id, diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index cbc0019..08083a5 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -60,9 +60,7 @@ th:field="*{deadlines[__${rowStat.index}__].date}"/> Удалить + th:onclick="|$(this).parent().remove();|"/>
From 9711febefb27e3f3fce81f7d4e1f601df70f325e Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sat, 13 Apr 2019 13:02:36 +0400 Subject: [PATCH 05/20] #55 added delete deadline --- .../controller/ConferenceController.java | 17 +++++++++++++++-- .../ru/ulstu/conference/model/Conference.java | 1 - .../ulstu/conference/model/ConferenceDto.java | 18 ++++++++++++++++-- .../conference/service/ConferenceService.java | 12 ++++++------ .../deadline/service/DeadlineService.java | 6 ++++++ .../templates/conferences/conference.html | 8 +++++--- 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 750d46d..61456c6 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -19,7 +19,9 @@ import java.io.IOException; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.core.controller.Navigation.*; +import static ru.ulstu.core.controller.Navigation.CONFERENCES_PAGE; +import static ru.ulstu.core.controller.Navigation.CONFERENCE_PAGE; +import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; @Controller() @@ -64,8 +66,19 @@ public class ConferenceController { return CONFERENCE_PAGE; conferenceDto.getDeadlines().add(new Deadline()); return CONFERENCE_PAGE; + } - + @PostMapping(value = "/conference", params = "removeDeadline") + public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors, + @RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException { + if (errors.hasErrors()) + return CONFERENCE_PAGE; + conferenceService.removeDeadline(conferenceDto, deadlineIndex); + if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { + conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); + } + conferenceDto.getDeadlines().remove(conferenceDto.getDeadlines().get(deadlineIndex)); + return CONFERENCE_PAGE; } private void filterEmptyDeadlines(ConferenceDto conferenceDto) { diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 1c824b3..faed15c 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -56,7 +56,6 @@ public class Conference extends BaseEntity { @OrderBy("date") private List deadlines = new ArrayList<>(); - @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "paper_conference", joinColumns = {@JoinColumn(name = "conference_id")}, diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index eb67d39..e5efcde 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -11,7 +11,11 @@ import ru.ulstu.user.model.UserDto; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.Size; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import static ru.ulstu.core.util.StreamApiUtils.convert; @@ -33,6 +37,7 @@ public class ConferenceDto { @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDate = new Date(); private List deadlines = new ArrayList<>(); + private List removedDeadlineIds = new ArrayList<>(); private Set userIds = new HashSet<>(); private Set paperIds = new HashSet<>(); private Set papers = new HashSet<>(); @@ -40,7 +45,7 @@ public class ConferenceDto { private Integer filterUserId; public ConferenceDto() { - } + } @JsonCreator public ConferenceDto(@JsonProperty("id") Integer id, @@ -188,4 +193,13 @@ public class ConferenceDto { public void setFilterUserId(Integer filterUserId) { this.filterUserId = filterUserId; } + + public List getRemovedDeadlineIds() { + return removedDeadlineIds; + } + + public void setRemovedDeadlineIds(List removedDeadlineIds) { + this.removedDeadlineIds = removedDeadlineIds; + } + } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index c28c637..46e7ff7 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -53,20 +53,20 @@ public class ConferenceService { public Integer create(ConferenceDto conferenceDto) throws IOException { Conference newConference = copyFromDto(new Conference(), conferenceDto); newConference = conferenceRepository.save(newConference); - - return newConference.getId(); } @Transactional public Integer update(ConferenceDto conferenceDto) throws IOException { Conference conference = conferenceRepository.findOne(conferenceDto.getId()); - conferenceRepository.save(copyFromDto(conference, conferenceDto)); - return conference.getId(); } + public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { + + } + private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException { conference.setTitle(conferenceDto.getTitle()); conference.setDescription(conferenceDto.getDescription()); @@ -74,9 +74,9 @@ public class ConferenceService { conference.setPing(0); conference.setBeginDate(conferenceDto.getBeginDate()); conference.setEndDate(conferenceDto.getEndDate()); - + conferenceDto.getRemovedDeadlineIds() + .forEach(deadlineService::remove); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); - return conference; } diff --git a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java index 2180025..d4ff2ef 100644 --- a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java +++ b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java @@ -41,4 +41,10 @@ public class DeadlineService { newDeadline = deadlineRepository.save(newDeadline); return newDeadline; } + + @Transactional + public void remove(Integer deadlineId) { + deadlineRepository.delete(deadlineId); + + } } diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 08083a5..c93fc39 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -50,6 +50,7 @@
+
@@ -58,9 +59,10 @@ th:field="*{deadlines[__${rowStat.index}__].description}"/> - Удалить + +
From 34499abd609c1b2e4570f969d63546e56c5c153f Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 13 Apr 2019 22:59:59 +0400 Subject: [PATCH 06/20] #62 fix remove deadline in other JPA operation --- .../java/ru/ulstu/conference/service/ConferenceService.java | 3 +-- src/main/java/ru/ulstu/deadline/service/DeadlineService.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 46e7ff7..ac44d4b 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -60,6 +60,7 @@ public class ConferenceService { public Integer update(ConferenceDto conferenceDto) throws IOException { Conference conference = conferenceRepository.findOne(conferenceDto.getId()); conferenceRepository.save(copyFromDto(conference, conferenceDto)); + conferenceDto.getRemovedDeadlineIds().forEach(deadlineService::remove); return conference.getId(); } @@ -74,8 +75,6 @@ public class ConferenceService { conference.setPing(0); conference.setBeginDate(conferenceDto.getBeginDate()); conference.setEndDate(conferenceDto.getEndDate()); - conferenceDto.getRemovedDeadlineIds() - .forEach(deadlineService::remove); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); return conference; } diff --git a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java index d4ff2ef..0ef8a4f 100644 --- a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java +++ b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java @@ -45,6 +45,5 @@ public class DeadlineService { @Transactional public void remove(Integer deadlineId) { deadlineRepository.delete(deadlineId); - } } From d6a11a5902f469bad0df2312e8b51778239240c5 Mon Sep 17 00:00:00 2001 From: ASH Date: Sun, 14 Apr 2019 17:50:23 +0400 Subject: [PATCH 07/20] #74 fixing codestyle and tags --- .../students/controller/TaskController.java | 24 +++------- .../java/ru/ulstu/students/model/Task.java | 11 ++--- .../java/ru/ulstu/students/model/TaskDto.java | 13 +++--- .../ulstu/students/service/TaskService.java | 12 ++--- src/main/java/ru/ulstu/tags/model/Tag.java | 23 +++++++++- src/main/java/ru/ulstu/tags/model/TagDto.java | 44 ------------------- .../ulstu/tags/repository/TagRepository.java | 8 +++- .../ru/ulstu/tags/service/TagService.java | 34 +++++++------- 8 files changed, 64 insertions(+), 105 deletions(-) delete mode 100644 src/main/java/ru/ulstu/tags/model/TagDto.java diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java index 4b4d12d..8fd9575 100644 --- a/src/main/java/ru/ulstu/students/controller/TaskController.java +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -7,10 +7,8 @@ import org.springframework.web.bind.annotation.*; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.students.model.Task; import ru.ulstu.students.model.TaskDto; -import ru.ulstu.tags.model.Tag; -import ru.ulstu.tags.model.TagDto; -import springfox.documentation.annotations.ApiIgnore; import ru.ulstu.students.service.TaskService; +import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; import java.io.IOException; @@ -56,8 +54,9 @@ public class TaskController { if (taskDto.getDeadlines().isEmpty()) { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } - if (errors.hasErrors()) + if (errors.hasErrors()) { return TASK_PAGE; + } taskService.save(taskDto); return String.format(REDIRECT_TO, TASKS_PAGE); } @@ -65,8 +64,9 @@ public class TaskController { @PostMapping(value = "/task", params = "addDeadline") public String addDeadline(@Valid TaskDto taskDto, Errors errors) { filterEmptyDeadlines(taskDto); - if (errors.hasErrors()) + if (errors.hasErrors()) { return TASK_PAGE; + } taskDto.getDeadlines().add(new Deadline()); return TASK_PAGE; } @@ -76,20 +76,6 @@ public class TaskController { return taskService.getTaskStatuses(); } -// @ModelAttribute("allTags") -// public List getAllTags() { -// return taskService.getTaskTags(); -// } - -// @PostMapping(value = "/task", params = "addTag") -// public String addTag(@Valid TaskDto taskDto, Errors errors) { -// filterEmptyDeadlines(taskDto); -// if(errors.hasErrors()) -// return TASK_PAGE; -// taskDto.getTags().add(new TagDto()); -// return TASK_PAGE; -// } - private void filterEmptyDeadlines(TaskDto taskDto) { taskDto.setDeadlines(taskDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index 1ffa95c..be1b1c6 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -6,10 +6,11 @@ import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; -import ru.ulstu.tags.model.TagDto; import javax.persistence.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Entity public class Task extends BaseEntity { @@ -57,7 +58,7 @@ public class Task extends BaseEntity { @JoinTable(name = "task_tags", joinColumns = {@JoinColumn(name = "task_id")}, inverseJoinColumns = {@JoinColumn(name = "tag_id")}) - private Set tags = new HashSet<>(); + private List tags = new ArrayList<>(); public String getTitle() { return title; @@ -107,11 +108,11 @@ public class Task extends BaseEntity { this.updateDate = updateDate; } - public Set getTags() { + public List getTags() { return tags; } - public void setTags(Set tags) { + public void setTags(List tags) { this.tags = tags; } } diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java index dc41be8..941a6df 100644 --- a/src/main/java/ru/ulstu/students/model/TaskDto.java +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; -import ru.ulstu.tags.model.TagDto; +import ru.ulstu.tags.model.Tag; import java.util.ArrayList; import java.util.Date; @@ -13,8 +13,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import static ru.ulstu.core.util.StreamApiUtils.convert; - public class TaskDto { private final static int MAX_TAGS_LENGTH = 50; @@ -28,7 +26,7 @@ public class TaskDto { private Date createDate; private Date updateDate; private Set tagIds; - private Set tags; + private List tags; public TaskDto() { deadlines.add(new Deadline()); @@ -43,7 +41,7 @@ public class TaskDto { @JsonProperty("status") Task.TaskStatus status, @JsonProperty("deadlines") List deadlines, @JsonProperty("tagIds") Set tagIds, - @JsonProperty("tags") Set tags) { + @JsonProperty("tags") List tags) { this.id = id; this.title = title; this.status = status; @@ -62,7 +60,6 @@ public class TaskDto { this.createDate = task.getCreateDate(); this.updateDate = task.getUpdateDate(); this.description = task.getDescription(); -// this.tagIds = convert(task.getTags(), tag -> tag.getId()); this.tags = task.getTags(); } @@ -130,11 +127,11 @@ public class TaskDto { this.tagIds = tagIds; } - public Set getTags() { + public List getTags() { return tags; } - public void setTags(Set tags) { + public void setTags(List tags) { this.tags = tags; } diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java index 5e969ac..7b67a44 100644 --- a/src/main/java/ru/ulstu/students/service/TaskService.java +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -7,12 +7,12 @@ import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.students.model.Task; import ru.ulstu.students.model.TaskDto; import ru.ulstu.students.repository.TaskRepository; -import ru.ulstu.tags.model.Tag; -import ru.ulstu.tags.model.TagDto; import ru.ulstu.tags.service.TagService; import java.io.IOException; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.List; import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; @@ -64,9 +64,6 @@ public class TaskService { task.setUpdateDate(new Date()); task.getTags().clear(); task.setTags(tagService.saveOrCreate(taskDto.getTags())); -// if (taskDto.getTagIds() != null && !taskDto.getTagIds().isEmpty()) { -// taskDto.getTagIds().forEach(tagIds -> task.getTags().add(tagService.findById(tagIds))); -// } return task; } @@ -95,7 +92,4 @@ public class TaskService { return Arrays.asList(Task.TaskStatus.values()); } -// public List getTaskTags() { -// return tagService.; -// } } diff --git a/src/main/java/ru/ulstu/tags/model/Tag.java b/src/main/java/ru/ulstu/tags/model/Tag.java index d299b22..aed000f 100644 --- a/src/main/java/ru/ulstu/tags/model/Tag.java +++ b/src/main/java/ru/ulstu/tags/model/Tag.java @@ -1,20 +1,39 @@ package ru.ulstu.tags.model; -import org.hibernate.validator.constraints.NotBlank; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.core.model.BaseEntity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; +import javax.validation.constraints.Size; @Entity @Table(name = "tag") public class Tag extends BaseEntity { - @NotBlank + @NotEmpty + @Size(max = 50) @Column(name = "tag_name") private String tagName; + public Tag() { + + } + + @JsonCreator + public Tag(@JsonProperty("id") Integer id, + @JsonProperty("tag_name") String tagName) { + this.setId(id); + this.tagName = tagName; + } + + public Tag(String name) { + this.tagName = name; + } + public String getTagName() { return tagName; } diff --git a/src/main/java/ru/ulstu/tags/model/TagDto.java b/src/main/java/ru/ulstu/tags/model/TagDto.java deleted file mode 100644 index 582ea5d..0000000 --- a/src/main/java/ru/ulstu/tags/model/TagDto.java +++ /dev/null @@ -1,44 +0,0 @@ -package ru.ulstu.tags.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotEmpty; -import ru.ulstu.core.model.BaseEntity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.validation.constraints.Size; - -@Entity -@Table(name = "tag") -public class TagDto extends BaseEntity { - - @NotEmpty - @Size(max = 50) - @Column(name = "tag_name") - private String tagName; - - public TagDto() { - - } - - @JsonCreator - public TagDto(@JsonProperty("id") Integer id, - @JsonProperty("tag_name") String tagName) { - this.setId(id); - this.tagName = tagName; - } - - public TagDto(String name) { - this.tagName = name; - } - - public String getTagName() { - return tagName; - } - - public void setTagName(String tagName) { - this.tagName = tagName; - } -} diff --git a/src/main/java/ru/ulstu/tags/repository/TagRepository.java b/src/main/java/ru/ulstu/tags/repository/TagRepository.java index d4a9c76..213abae 100644 --- a/src/main/java/ru/ulstu/tags/repository/TagRepository.java +++ b/src/main/java/ru/ulstu/tags/repository/TagRepository.java @@ -1,8 +1,12 @@ package ru.ulstu.tags.repository; import org.springframework.data.jpa.repository.JpaRepository; -import ru.ulstu.tags.model.TagDto; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import ru.ulstu.tags.model.Tag; -public interface TagRepository extends JpaRepository { +public interface TagRepository extends JpaRepository { + @Query("SELECT t FROM Tag t WHERE (t.tagName = :tagName)") + Tag findByName(@Param("tagName") String tagName); } diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index adf2a82..681a506 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -1,17 +1,13 @@ package ru.ulstu.tags.service; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; - -import ru.ulstu.tags.model.TagDto; +import ru.ulstu.tags.model.Tag; import ru.ulstu.tags.repository.TagRepository; import javax.transaction.Transactional; -import java.util.Set; +import java.util.List; import java.util.stream.Collectors; -import static ru.ulstu.core.util.StreamApiUtils.convert; - @Service public class TagService { @@ -23,23 +19,29 @@ public class TagService { this.tagRepository = tagRepository; } - public Set saveOrCreate(Set tagDtos) { - return tagDtos + public List saveOrCreate(List tags) { + return tags .stream() - .map(tagDto -> { - return tagRepository.exists(tagDto.getId()) ? takeExist(tagDto) : create(tagDto); - }).collect(Collectors.toSet()); + .map(tag -> { + return tag.getId() != null ? getExistById(tag) : + isExistByName(tag.getTagName()) != null ? isExistByName(tag.getTagName()) : create(tag); + }).collect(Collectors.toList()); } @Transactional - public TagDto takeExist(TagDto tagDto) { - return tagRepository.findOne(tagDto.getId()); + public Tag getExistById(Tag tag) { + return tagRepository.findOne(tag.getId()); } @Transactional - public TagDto create(TagDto tagDto) { - TagDto newTag = new TagDto(); - newTag.setTagName(tagDto.getTagName()); + public Tag isExistByName(String tagName) { + return tagRepository.findByName(tagName); + } + + @Transactional + public Tag create(Tag tag) { + Tag newTag = new Tag(); + newTag.setTagName(tag.getTagName()); newTag = tagRepository.save(newTag); return newTag; } From 8cfc64ea85044ad88403a595b0a8726163ce37d5 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 14 Apr 2019 20:42:11 +0400 Subject: [PATCH 08/20] #55 added delete input style --- .../conference/controller/ConferenceController.java | 13 ++++++------- .../ulstu/conference/service/ConferenceService.java | 5 ++++- src/main/resources/public/css/conference.css | 4 ++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 61456c6..7a229ca 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -52,8 +52,9 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "save") public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); - if (errors.hasErrors()) + if (errors.hasErrors()) { return CONFERENCE_PAGE; + } conferenceService.save(conferenceDto); return String.format(REDIRECT_TO, CONFERENCES_PAGE); @@ -62,8 +63,9 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "addDeadline") public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { filterEmptyDeadlines(conferenceDto); - if (errors.hasErrors()) + if (errors.hasErrors()) { return CONFERENCE_PAGE; + } conferenceDto.getDeadlines().add(new Deadline()); return CONFERENCE_PAGE; } @@ -71,13 +73,10 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "removeDeadline") public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors, @RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException { - if (errors.hasErrors()) + if (errors.hasErrors()) { return CONFERENCE_PAGE; - conferenceService.removeDeadline(conferenceDto, deadlineIndex); - if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { - conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); } - conferenceDto.getDeadlines().remove(conferenceDto.getDeadlines().get(deadlineIndex)); + conferenceService.removeDeadline(conferenceDto, deadlineIndex); return CONFERENCE_PAGE; } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index ac44d4b..13ce1d5 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -65,7 +65,10 @@ public class ConferenceService { } public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { - + if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { + conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); + } + conferenceDto.getDeadlines().remove(conferenceDto.getDeadlines().get(deadlineIndex)); } private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException { diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index ec88796..004fe8c 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -19,6 +19,7 @@ body { .deadline { margin: 0; height: 40px; + min-height: 40px; } .deadline-text { @@ -63,6 +64,9 @@ body { .icon-delete { background-color: #f44; + background-image: url(/img/conference/delete.png); + background-repeat: round; + color: transparent !important; } .icon-delete:hover { From 1f36e04cd3eec6900f82af4dac8d8505ba9571d5 Mon Sep 17 00:00:00 2001 From: ASH Date: Sun, 14 Apr 2019 21:24:22 +0400 Subject: [PATCH 09/20] #74 fully adding tags --- src/main/resources/public/css/tasks.css | 73 +++++++++++++++---- src/main/resources/public/js/tasks.js | 70 ++++++++++++++++++ .../resources/templates/students/task.html | 15 +++- 3 files changed, 139 insertions(+), 19 deletions(-) diff --git a/src/main/resources/public/css/tasks.css b/src/main/resources/public/css/tasks.css index 2f42db5..6d18c99 100644 --- a/src/main/resources/public/css/tasks.css +++ b/src/main/resources/public/css/tasks.css @@ -1,24 +1,65 @@ -.bootstrap-tagsinput{ - +.tags-container { width: 100%; padding: .375rem .75rem; + background-color: #fff; + border: 1px solid #ccc; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + display: inline-block; + color: #555; + vertical-align: middle; + border-radius: 4px; + max-width: 100%; + line-height: 22px; + cursor: text; } -.bootstrap-tagsinput .label{ - - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: 700; - line-height: 2.5; - color: #fff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; +.input-tag-name { + border: none; + box-shadow: none; + outline: none; + background-color: transparent; + padding: 0 6px; + margin: 0; + width: auto; + max-width: inherit; } -.bootstrap-tagsinput .label-info{ +.tag { + display: inline-block; + padding: .2em .6em .3em; + background-color: orange; + border-radius: .25em; + margin-right: 4px; + margin-bottom: 4px; + + font-size: 75%; + font-weight: 700; + line-height: 1.5; + color: #fff; +} + +.tag-name span[data-role="remove"] { + margin-left: 8px; + cursor: pointer; +} + +.tag-name span[data-role="remove"]:after { + content: "x"; + padding: 0px 2px; +} + +.tag-name input[type="text"] { + background: transparent; + border: none; + display: inline-flex; + font-size: 100%; + font-weight: 700; + line-height: 1.5; + color: #fff; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + outline: none; + cursor: default; - background-color: orange; } diff --git a/src/main/resources/public/js/tasks.js b/src/main/resources/public/js/tasks.js index 6bf160c..b333c31 100644 --- a/src/main/resources/public/js/tasks.js +++ b/src/main/resources/public/js/tasks.js @@ -1,5 +1,75 @@ /*") + .attr("id", 'tags' + tagNumber) + .addClass("tag"); + // контейнер id + var idInput = $("") + .attr("type", "hidden") + .attr("id", "tags" + tagNumber + ".id") + .attr("name", "tags[" + tagNumber + "].id") + .attr("value", ''); + // контейнер текста + var conDiv = $("
") + .addClass("tag-name"); + // текст тега + var nameInput = $("") + .attr("type", "text") + .attr("id", "tags" + tagNumber + ".tagName") + .attr("name", "tags[" + tagNumber + "].tagName") + .attr("value", tagName) + .attr("readonly", "true") + .attr("size", tagName.length); + // кнопка удалить тег + var removeSpan = $("") + .attr("data-role", "remove") + .bind("click", removeTag); + + conDiv.append(nameInput); + conDiv.append(removeSpan); + newTagRow.append(idInput); + newTagRow.append(conDiv); + $(this).before(newTagRow); + } + + $(this).val(''); + } + }); + + $("span[data-role=remove]").click(removeTag); $(".task-row").mouseenter(function (event) { var taskRow = $(event.target).closest(".task-row"); $(taskRow).css("background-color", "#f8f9fa"); diff --git a/src/main/resources/templates/students/task.html b/src/main/resources/templates/students/task.html index 74ec8f6..968c7a0 100644 --- a/src/main/resources/templates/students/task.html +++ b/src/main/resources/templates/students/task.html @@ -53,8 +53,18 @@
- +
+
+ +
+ + +
+
+ +
@@ -131,7 +141,6 @@
-
\ No newline at end of file From f88f035e65860038652d9003d6e3dced97fe4002 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 14 Apr 2019 21:34:39 +0400 Subject: [PATCH 10/20] #55 little fix --- .../java/ru/ulstu/conference/service/ConferenceService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 13ce1d5..9c40295 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -68,7 +68,7 @@ public class ConferenceService { if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); } - conferenceDto.getDeadlines().remove(conferenceDto.getDeadlines().get(deadlineIndex)); + conferenceDto.getDeadlines().remove((int) deadlineIndex); } private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException { From 0cc8de2d323fd026fdf4983292d5e23079878dbd Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 10:36:55 +0400 Subject: [PATCH 11/20] #58 added delete method of conference --- .../ulstu/conference/controller/ConferenceController.java | 7 +++++++ .../ru/ulstu/conference/service/ConferenceService.java | 6 ++++++ .../templates/conferences/fragments/confLineFragment.html | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 7a229ca..1011c51 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -60,6 +61,12 @@ public class ConferenceController { } + @GetMapping("/delete/{conference-id}") + public String delete(@PathVariable("conference-id") Integer conferenceId) throws IOException { + conferenceService.delete(conferenceId); + return String.format(REDIRECT_TO, CONFERENCES_PAGE); + } + @PostMapping(value = "/conference", params = "addDeadline") public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { filterEmptyDeadlines(conferenceDto); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 9c40295..b01bd42 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -64,6 +64,12 @@ public class ConferenceService { return conference.getId(); } + @Transactional + public void delete(Integer conferenceId) { + // Conference conference = conferenceRepository.findOne(conferenceId); + conferenceRepository.delete(conferenceId); + } + public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index 317da03..d104952 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -4,13 +4,13 @@ -
+
- + - - + From 909c657c890a2bc4994141d60d6692120dc51d2d Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 15:48:17 +0400 Subject: [PATCH 12/20] #58 added delete confirm --- .../conference/service/ConferenceService.java | 5 +- src/main/resources/public/css/conference.css | 5 ++ src/main/resources/public/js/conference.js | 54 ++++++++++++------- .../templates/conferences/conferences.html | 3 +- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index b01bd42..84ae923 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -66,8 +66,9 @@ public class ConferenceService { @Transactional public void delete(Integer conferenceId) { - // Conference conference = conferenceRepository.findOne(conferenceId); - conferenceRepository.delete(conferenceId); + if (conferenceRepository.exists(conferenceId)) { + conferenceRepository.delete(conferenceId); + } } public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 004fe8c..bc63bfe 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -2,6 +2,11 @@ body { min-width: 400px; } +.conference-row .col:hover { + background-color: #eaeaea; + border-radius: .25rem; +} + diff --git a/src/main/resources/public/js/conference.js b/src/main/resources/public/js/conference.js index 304daae..dd843ca 100644 --- a/src/main/resources/public/js/conference.js +++ b/src/main/resources/public/js/conference.js @@ -1,27 +1,41 @@ $(document).ready(function () { - $('.data-href-js').click( function() { - window.location = $(this).attr('data-href'); + $(".conference-row").mouseenter(function (event) { + var conferenceRow = $(event.target).closest(".conference-row"); + $(conferenceRow).css("background-color", "#f8f9fa"); + $(conferenceRow).find(".remove-conference").removeClass("d-none"); + + }); + $(".conference-row").mouseleave(function (event) { + var conferenceRow = $(event.target).closest(".conference-row"); + $(conferenceRow).css("background-color", "white"); + $(conferenceRow).closest(".conference-row").find(".remove-conference").addClass("d-none"); }); - $('.circle').parent().click( function() { - $(this).children('.circle').toggleClass('circle-active'); - }); + $('a[data-confirm]').click(function(ev) { + var href = $(this).attr('href'); + if (!$('#dataConfirmModal').length) { + $('#modalDelete').append(''); + } + $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); + $('#dataConfirmOK').attr('href', href); + $('#dataConfirmModal').modal({show:true}); + return false; }); }); diff --git a/src/main/resources/templates/conferences/conferences.html b/src/main/resources/templates/conferences/conferences.html index fa88aaf..46b2e73 100644 --- a/src/main/resources/templates/conferences/conferences.html +++ b/src/main/resources/templates/conferences/conferences.html @@ -3,6 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="default" xmlns:th=""> + @@ -46,7 +47,7 @@
- +
From 735cbb5f7bb27f096a480dac62138ab27f8734c4 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 16 Apr 2019 09:46:24 +0400 Subject: [PATCH 13/20] #66 added front-end part --- .../templates/conferences/conference.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index c93fc39..13686b3 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -136,9 +136,11 @@
-
- +
@@ -136,6 +135,7 @@
+ From d81d1cf72c875fe619abea9fd6c8b21d6452abff Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 16 Apr 2019 13:41:10 +0400 Subject: [PATCH 19/20] #74 some code fixes --- .../ru/ulstu/tags/service/TagService.java | 8 +- src/main/resources/public/css/agency.css | 1690 ++++++++--------- src/main/resources/templates/index.html | 6 - 3 files changed, 840 insertions(+), 864 deletions(-) diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index 8541aad..4e88304 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -23,15 +23,11 @@ public class TagService { return tags .stream() .map(tag -> { - if (tag.getId() != null) { + if (tag.getId() != null) { return getExistById(tag); } else { Tag existTag = isExistByName(tag.getTagName()); - if (existTag != null) { - return existTag; - } else { - return create(tag); - } + return existTag != null ? existTag : create(tag); } }).collect(Collectors.toList()); } diff --git a/src/main/resources/public/css/agency.css b/src/main/resources/public/css/agency.css index e1cc226..fb3ec24 100644 --- a/src/main/resources/public/css/agency.css +++ b/src/main/resources/public/css/agency.css @@ -1,853 +1,839 @@ -body { - overflow-x: hidden; - font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -p { - line-height: 1.75; -} - -a { - color: #000000; -} - -a:hover { - color: #fec503; -} - -.text-draft { - color: rgba(0, 0, 0, 0.48) !important; -} - -.text-primary { - color: #228bba !important; -} - -.text-warning { - color: #940000 !important; -} - -.text-review { - color: #94028d !important; -} - -.text-success { - color: #007741 !important; -} - -.text-accepted { - color: #fec503 !important; -} - -.text-not-accepted { - color: #A38831 !important; -} - -.text-failed { - color: #A38831 !important; -} - -h1, -h2, -h3, -h4, -h5, -h6 { - font-weight: 700; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -section { - padding: 100px 0; -} - -section h2.section-heading { - font-size: 2.5vw; - margin-top: 0; - margin-bottom: 15px; -} - -section h3.section-subheading { - font-size: 16px; - font-weight: 400; - font-style: italic; - margin-bottom: 75px; - text-transform: none; - font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -@media (min-width: 768px) { - section { - padding: 100px 0; - } -} - -.btn { - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-weight: 700; -} - -.btn-xl { - font-size: 18px; - padding: 20px 40px; -} - -.btn-success { - background-color: #28a745; - border-color: #28a745; -} - -.btn-primary { - background-color: #fed136; - border-color: #fed136; -} - -.btn-default { - background-color: #ffffff; - border-color: #ced4da;; -} - -.btn-info { - background-color: #5bc0de; - border-color: #5bc0de; -} - -.progress-bar { - display: flex; - -ms-flex-direction: column; - flex-direction: column; - -ms-flex-pack: center; - justify-content: center; - color: #fff; - text-align: center; - white-space: nowrap; - background-color: #fed136; - transition: width .6s ease; -} - -.btn-primary:active, .btn-primary:focus, .btn-primary:hover { - background-color: #fec810 !important; - border-color: #fec810 !important; - color: white; -} - -.btn-primary:active, .btn-primary:focus { - box-shadow: 0 0 0 0.2rem rgba(254, 209, 55, 0.5) !important; -} - -::-moz-selection { - background: #fed136; - text-shadow: none; -} - -::selection { - background: #fed136; - text-shadow: none; -} - -img::selection { - background: transparent; -} - -img::-moz-selection { - background: transparent; -} - -#mainNav { - background-color: #212529; -} - -#mainNav .navbar-toggler { - font-size: 12px; - right: 0; - padding: 13px; - text-transform: uppercase; - color: white; - border: 0; - background-color: #fed136; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -#mainNav .navbar-brand { - color: #fed136; - font-family: 'Kaushan Script', 'Helvetica Neue', Helvetica, Arial, cursive; -} - -#mainNav .navbar-brand.active, #mainNav .navbar-brand:active, #mainNav .navbar-brand:focus, #mainNav .navbar-brand:hover { - color: #fec503; -} - -#mainNav .navbar-nav .nav-item .nav-link { - font-size: 90%; - font-weight: 400; - padding: 0.75em 0; - letter-spacing: 1px; - color: white; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -#mainNav .navbar-nav .nav-item .nav-link.active, #mainNav .navbar-nav .nav-item .nav-link:hover { - color: #fed136; -} - -@media (min-width: 992px) { - #mainNav { - padding-top: 25px; - padding-bottom: 25px; - -webkit-transition: padding-top 0.3s, padding-bottom 0.3s; - -moz-transition: padding-top 0.3s, padding-bottom 0.3s; - transition: padding-top 0.3s, padding-bottom 0.3s; - border: none; - background-color: transparent; - } - - #mainNav .navbar-brand { - font-size: 1.75em; - -webkit-transition: all 0.3s; - -moz-transition: all 0.3s; - transition: all 0.3s; - } - - #mainNav .navbar-nav .nav-item .nav-link { - padding: 1.1em 1em !important; - } - - #mainNav.navbar-shrink { - padding-top: 0; - padding-bottom: 0; - background-color: #212529; - } - - #mainNav.navbar-shrink .navbar-brand { - font-size: 1.25em; - padding: 12px 0; - } -} - -header.masthead { - text-align: center; - color: white; - background-image: url("../img/header-bg.jpg"); - background-repeat: no-repeat; - background-attachment: scroll; - background-position: center center; - -webkit-background-size: cover; - -moz-background-size: cover; - -o-background-size: cover; - background-size: cover; -} - -header.masthead .intro-text { - padding-top: 150px; - padding-bottom: 100px; -} - -header.masthead .intro-text .intro-lead-in { - font-size: 22px; - font-style: italic; - line-height: 22px; - margin-bottom: 25px; - font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -header.masthead .intro-text .intro-heading { - font-size: 50px; - font-weight: 700; - line-height: 50px; - margin-bottom: 25px; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -@media (min-width: 768px) { - header.masthead .intro-text { - padding-top: 300px; - padding-bottom: 200px; - } - - header.masthead .intro-text .intro-lead-in { - font-size: 40px; - font-style: italic; - line-height: 40px; - margin-bottom: 25px; - font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; - } - - header.masthead .intro-text .intro-heading { - font-size: 75px; - font-weight: 700; - line-height: 75px; - margin-bottom: 50px; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; - } -} - -.service-heading { - margin: 15px 0; - text-transform: none; -} - -#portfolio .portfolio-item { - right: 0; - margin: 0 0 15px; -} - -#portfolio .portfolio-item .portfolio-link { - position: relative; - display: block; - max-width: 400px; - margin: 0 auto; - cursor: pointer; -} - -#portfolio .portfolio-item .portfolio-link .portfolio-hover { - position: absolute; - width: 100%; - height: 100%; - -webkit-transition: all ease 0.5s; - -moz-transition: all ease 0.5s; - transition: all ease 0.5s; - opacity: 0; - background: rgba(254, 209, 54, 0.9); -} - -#portfolio .portfolio-item .portfolio-link .portfolio-hover:hover { - opacity: 1; -} - -#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content { - font-size: 20px; - position: absolute; - top: 50%; - width: 100%; - height: 20px; - margin-top: -12px; - text-align: center; - color: white; -} - -#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content i { - margin-top: -12px; -} - -#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h3, -#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h4 { - margin: 0; -} - -#portfolio .portfolio-item .portfolio-caption { - max-width: 400px; - margin: 0 auto; - padding: 25px; - text-align: center; - background-color: #fff; -} - -#portfolio .portfolio-item .portfolio-caption h4 { - margin: 0; - text-transform: none; -} - -#portfolio .portfolio-item .portfolio-caption p { - font-size: 16px; - font-style: italic; - margin: 0; - font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -#portfolio * { - z-index: 2; -} - -@media (min-width: 767px) { - #portfolio .portfolio-item { - margin: 0 0 30px; - } -} - -.portfolio-modal { - padding-right: 0px !important; -} - -.portfolio-modal .modal-dialog { - margin: 1rem; - max-width: 100vw; -} - -.portfolio-modal .modal-content { - padding: 100px 0; - text-align: center; -} - -.portfolio-modal .modal-content h2 { - font-size: 3em; - margin-bottom: 15px; -} - -.portfolio-modal .modal-content p { - margin-bottom: 30px; -} - -.portfolio-modal .modal-content p.item-intro { - font-size: 16px; - font-style: italic; - margin: 20px 0 30px; - font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -.portfolio-modal .modal-content ul.list-inline { - margin-top: 0; - margin-bottom: 30px; -} - -.portfolio-modal .modal-content img { - margin-bottom: 30px; -} - -.portfolio-modal .modal-content button { - cursor: pointer; -} - -.portfolio-modal .close-modal { - position: absolute; - top: 25px; - right: 25px; - width: 75px; - height: 75px; - cursor: pointer; - background-color: transparent; -} - -.portfolio-modal .close-modal:hover { - opacity: 0.3; -} - -.portfolio-modal .close-modal .lr { - /* Safari and Chrome */ - z-index: 1051; - width: 1px; - height: 75px; - margin-left: 35px; - /* IE 9 */ - -webkit-transform: rotate(45deg); - -ms-transform: rotate(45deg); - transform: rotate(45deg); - background-color: #212529; -} - -.portfolio-modal .close-modal .lr .rl { - /* Safari and Chrome */ - z-index: 1052; - width: 1px; - height: 75px; - /* IE 9 */ - -webkit-transform: rotate(90deg); - -ms-transform: rotate(90deg); - transform: rotate(90deg); - background-color: #212529; -} - -.timeline { - position: relative; - padding: 0; - list-style: none; -} - -.timeline:before { - position: absolute; - top: 0; - bottom: 0; - left: 40px; - width: 2px; - margin-left: -1.5px; - content: ''; - background-color: #e9ecef; -} - -.timeline > li { - position: relative; - min-height: 50px; - margin-bottom: 50px; -} - -.timeline > li:after, .timeline > li:before { - display: table; - content: ' '; -} - -.timeline > li:after { - clear: both; -} - -.timeline > li .timeline-panel { - position: relative; - float: right; - width: 100%; - padding: 0 20px 0 100px; - text-align: left; -} - -.timeline > li .timeline-panel:before { - right: auto; - left: -15px; - border-right-width: 15px; - border-left-width: 0; -} - -.timeline > li .timeline-panel:after { - right: auto; - left: -14px; - border-right-width: 14px; - border-left-width: 0; -} - -.timeline > li .timeline-image { - position: absolute; - z-index: 100; - left: 0; - width: 80px; - height: 80px; - margin-left: 0; - text-align: center; - color: white; - border: 7px solid #e9ecef; - border-radius: 100%; - background-color: #fed136; -} - -.timeline > li .timeline-image h4 { - font-size: 10px; - line-height: 14px; - margin-top: 12px; -} - -.timeline > li.timeline-inverted > .timeline-panel { - float: right; - padding: 0 20px 0 100px; - text-align: left; -} - -.timeline > li.timeline-inverted > .timeline-panel:before { - right: auto; - left: -15px; - border-right-width: 15px; - border-left-width: 0; -} - -.timeline > li.timeline-inverted > .timeline-panel:after { - right: auto; - left: -14px; - border-right-width: 14px; - border-left-width: 0; -} - -.timeline > li:last-child { - margin-bottom: 0; -} - -.timeline .timeline-heading h4 { - margin-top: 0; - color: inherit; -} - -.timeline .timeline-heading h4.subheading { - text-transform: none; -} - -.timeline .timeline-body > ul, -.timeline .timeline-body > p { - margin-bottom: 0; -} - -@media (min-width: 768px) { - .timeline:before { - left: 50%; - } - - .timeline > li { - min-height: 100px; - margin-bottom: 100px; - } - - .timeline > li .timeline-panel { - float: left; - width: 41%; - padding: 0 20px 20px 30px; - text-align: right; - } - - .timeline > li .timeline-image { - left: 50%; - width: 100px; - height: 100px; - margin-left: -50px; - } - - .timeline > li .timeline-image h4 { - font-size: 13px; - line-height: 18px; - margin-top: 16px; - } - - .timeline > li.timeline-inverted > .timeline-panel { - float: right; - padding: 0 30px 20px 20px; - text-align: left; - } -} - -@media (min-width: 992px) { - .timeline > li { - min-height: 150px; - } - - .timeline > li .timeline-panel { - padding: 0 20px 20px; - } - - .timeline > li .timeline-image { - width: 150px; - height: 150px; - margin-left: -75px; - } - - .timeline > li .timeline-image h4 { - font-size: 18px; - line-height: 26px; - margin-top: 30px; - } - - .timeline > li.timeline-inverted > .timeline-panel { - padding: 0 20px 20px; - } -} - -@media (min-width: 1200px) { - .timeline > li { - min-height: 170px; - } - - .timeline > li .timeline-panel { - padding: 0 20px 20px 100px; - } - - .timeline > li .timeline-image { - width: 170px; - height: 170px; - margin-left: -85px; - } - - .timeline > li .timeline-image h4 { - margin-top: 40px; - } - - .timeline > li.timeline-inverted > .timeline-panel { - padding: 0 100px 20px 20px; - } -} - -.team-member { - margin-bottom: 50px; - text-align: center; -} - -.team-member img { - width: 225px; - height: 225px; - border: 7px solid #fff; -} - -.team-member h4 { - margin-top: 25px; - margin-bottom: 0; - text-transform: none; -} - -.team-member p { - margin-top: 0; -} - -section#contact { - background-color: #212529; - background-image: url("../img/map-image.png"); - background-repeat: no-repeat; - background-position: center; -} - -section#contact .section-heading { - color: #fff; -} - -section#contact .form-group { - margin-bottom: 25px; -} - -section#contact .form-group input, -section#contact .form-group textarea { - padding: 20px; -} - -section#contact .form-group input.form-control { - height: auto; -} - -section#contact .form-group textarea.form-control { - height: 248px; -} - -section#contact .form-control:focus { - border-color: #fed136; - box-shadow: none; -} - -section#contact ::-webkit-input-placeholder { - font-weight: 700; - color: #ced4da; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -section#contact :-moz-placeholder { - font-weight: 700; - color: #ced4da; - /* Firefox 18- */ - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -section#contact ::-moz-placeholder { - font-weight: 700; - color: #ced4da; - /* Firefox 19+ */ - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -section#contact :-ms-input-placeholder { - font-weight: 700; - color: #ced4da; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -footer { - padding: 25px 0; - text-align: center; -} - -footer span.copyright { - font-size: 90%; - line-height: 40px; - text-transform: none; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -footer ul.quicklinks { - font-size: 90%; - line-height: 40px; - margin-bottom: 0; - text-transform: none; - font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -ul.social-buttons { - margin-bottom: 0; -} - -ul.social-buttons li a { - font-size: 20px; - line-height: 40px; - display: block; - width: 40px; - height: 40px; - -webkit-transition: all 0.3s; - -moz-transition: all 0.3s; - transition: all 0.3s; - color: white; - border-radius: 100%; - outline: none; - background-color: #212529; -} - -ul.social-buttons li a:active, ul.social-buttons li a:focus, ul.social-buttons li a:hover { - background-color: #fed136; -} - -.dashboard-card { - background: #ffffff none repeat scroll 0 0; - margin: 15px; - padding: 20px; - border: 0 solid #e7e7e7; - border-radius: 5px; - box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05); -} - -@media (min-width: 1500px) { - .col-xl-3 { - max-width: 20%; - } - - .container { - max-width: 1340px; - } -} - -.toolbar-button { - width: 100%; - margin: 5px; -} - -.img-fluid { - width: 100% !important; -} - -/* --------------------------------------------------- - FEEDBACK STYLE ------------------------------------------------------ */ -.feedback-panel { - list-style-type: none; - padding: 5px; -} - -.feedback-panel .alert { - padding: 5px; - margin-bottom: 5px; - cursor: pointer; -} - -/* --------------------------------------------------- - MEDIAQUERIES ------------------------------------------------------ */ -@media (min-width: 768px) { - section h2.section-heading { - font-size: 3.5vw; - margin-top: 0; - margin-bottom: 15px; - } -} - -@media (min-width: 1500px) { - section h2.section-heading { - font-size: 1.5vw; - margin-top: 0; - margin-bottom: 15px; - } -} - -@media (min-width: 768px) { - .feedback-panel { - position: fixed; - overflow-y: hidden; - max-height: calc(100vh - 60px); - width: 250px; - top: 50px; - right: 15px; - opacity: .8; - z-index: 10000; - } - - .feedback-panel .alert { - padding: 10px; - margin-bottom: 10px; - overflow: hidden; - } - - .feedback-panel .alert:hover { - border-color: #888; - } +body { + overflow-x: hidden; + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +p { + line-height: 1.75; +} + +a { + color: #000000; +} + +a:hover { + color: #fec503; +} + +.text-draft { + color: rgba(0, 0, 0, 0.48) !important; +} + +.text-primary { + color: #228bba !important; +} + +.text-warning { + color: #940000 !important; +} + +.text-review { + color: #94028d !important; +} + +.text-success { + color: #007741 !important; +} + +.text-accepted { + color: #fec503 !important; +} + +.text-not-accepted { + color: #A38831 !important; +} + +.text-failed { + color: #A38831 !important; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + font-weight: 700; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +section { + padding: 100px 0; +} + +section h2.section-heading { + font-size: 2.5vw; + margin-top: 0; + margin-bottom: 15px; +} + +section h3.section-subheading { + font-size: 16px; + font-weight: 400; + font-style: italic; + margin-bottom: 75px; + text-transform: none; + font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +@media (min-width: 768px) { + section { + padding: 100px 0; + } +} + +.btn { + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-weight: 700; +} + +.btn-xl { + font-size: 18px; + padding: 20px 40px; +} + +.btn-success { + background-color: #28a745; + border-color: #28a745; +} + +.btn-primary { + background-color: #fed136; + border-color: #fed136; +} + +.btn-default { + background-color: #ffffff; + border-color: #ced4da;; +} + +.btn-info { + background-color: #5bc0de; + border-color: #5bc0de; +} + +.progress-bar { + display: flex; + -ms-flex-direction: column; + flex-direction: column; + -ms-flex-pack: center; + justify-content: center; + color: #fff; + text-align: center; + white-space: nowrap; + background-color: #fed136; + transition: width .6s ease; +} + +.btn-primary:active, .btn-primary:focus, .btn-primary:hover { + background-color: #fec810 !important; + border-color: #fec810 !important; + color: white; +} + +.btn-primary:active, .btn-primary:focus { + box-shadow: 0 0 0 0.2rem rgba(254, 209, 55, 0.5) !important; +} + +::-moz-selection { + background: #fed136; + text-shadow: none; +} + +::selection { + background: #fed136; + text-shadow: none; +} + +img::selection { + background: transparent; +} + +img::-moz-selection { + background: transparent; +} + +#mainNav { + background-color: #212529; +} + +#mainNav .navbar-toggler { + font-size: 12px; + right: 0; + padding: 13px; + text-transform: uppercase; + color: white; + border: 0; + background-color: #fed136; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +#mainNav .navbar-brand { + color: #fed136; + font-family: 'Kaushan Script', 'Helvetica Neue', Helvetica, Arial, cursive; +} + +#mainNav .navbar-brand.active, #mainNav .navbar-brand:active, #mainNav .navbar-brand:focus, #mainNav .navbar-brand:hover { + color: #fec503; +} + +#mainNav .navbar-nav .nav-item .nav-link { + font-size: 90%; + font-weight: 400; + padding: 0.75em 0; + letter-spacing: 1px; + color: white; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +#mainNav .navbar-nav .nav-item .nav-link.active, #mainNav .navbar-nav .nav-item .nav-link:hover { + color: #fed136; +} + +@media (min-width: 992px) { + #mainNav { + padding-top: 25px; + padding-bottom: 25px; + -webkit-transition: padding-top 0.3s, padding-bottom 0.3s; + -moz-transition: padding-top 0.3s, padding-bottom 0.3s; + transition: padding-top 0.3s, padding-bottom 0.3s; + border: none; + background-color: transparent; + } + + #mainNav .navbar-brand { + font-size: 1.75em; + -webkit-transition: all 0.3s; + -moz-transition: all 0.3s; + transition: all 0.3s; + } + + #mainNav .navbar-nav .nav-item .nav-link { + padding: 1.1em 1em !important; + } + + #mainNav.navbar-shrink { + padding-top: 0; + padding-bottom: 0; + background-color: #212529; + } + + #mainNav.navbar-shrink .navbar-brand { + font-size: 1.25em; + padding: 12px 0; + } +} + +header.masthead { + text-align: center; + color: white; + background-image: url("../img/header-bg.jpg"); + background-repeat: no-repeat; + background-attachment: scroll; + background-position: center center; + -webkit-background-size: cover; + -moz-background-size: cover; + -o-background-size: cover; + background-size: cover; +} + +header.masthead .intro-text { + padding-top: 150px; + padding-bottom: 100px; +} + +header.masthead .intro-text .intro-lead-in { + font-size: 22px; + font-style: italic; + line-height: 22px; + margin-bottom: 25px; + font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +header.masthead .intro-text .intro-heading { + font-size: 50px; + font-weight: 700; + line-height: 50px; + margin-bottom: 25px; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +@media (min-width: 768px) { + header.masthead .intro-text { + padding-top: 300px; + padding-bottom: 200px; + } + + header.masthead .intro-text .intro-lead-in { + font-size: 40px; + font-style: italic; + line-height: 40px; + margin-bottom: 25px; + font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; + } + + header.masthead .intro-text .intro-heading { + font-size: 75px; + font-weight: 700; + line-height: 75px; + margin-bottom: 50px; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; + } +} + +.service-heading { + margin: 15px 0; + text-transform: none; +} + +#portfolio .portfolio-item { + right: 0; + margin: 0 0 15px; +} + +#portfolio .portfolio-item .portfolio-link { + position: relative; + display: block; + max-width: 400px; + margin: 0 auto; + cursor: pointer; +} + +#portfolio .portfolio-item .portfolio-link .portfolio-hover { + position: absolute; + width: 100%; + height: 100%; + -webkit-transition: all ease 0.5s; + -moz-transition: all ease 0.5s; + transition: all ease 0.5s; + opacity: 0; + background: rgba(254, 209, 54, 0.9); +} + +#portfolio .portfolio-item .portfolio-link .portfolio-hover:hover { + opacity: 1; +} + +#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content { + font-size: 20px; + position: absolute; + top: 50%; + width: 100%; + height: 20px; + margin-top: -12px; + text-align: center; + color: white; +} + +#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content i { + margin-top: -12px; +} + +#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h3, +#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h4 { + margin: 0; +} + +#portfolio .portfolio-item .portfolio-caption { + max-width: 400px; + margin: 0 auto; + padding: 25px; + text-align: center; + background-color: #fff; +} + +#portfolio .portfolio-item .portfolio-caption h4 { + margin: 0; + text-transform: none; +} + +#portfolio .portfolio-item .portfolio-caption p { + font-size: 16px; + font-style: italic; + margin: 0; + font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +#portfolio * { + z-index: 2; +} + +@media (min-width: 767px) { + #portfolio .portfolio-item { + margin: 0 0 30px; + } +} + +.portfolio-modal { + padding-right: 0px !important; +} + +.portfolio-modal .modal-dialog { + margin: 1rem; + max-width: 100vw; +} + +.portfolio-modal .modal-content { + padding: 100px 0; + text-align: center; +} + +.portfolio-modal .modal-content h2 { + font-size: 3em; + margin-bottom: 15px; +} + +.portfolio-modal .modal-content p { + margin-bottom: 30px; +} + +.portfolio-modal .modal-content p.item-intro { + font-size: 16px; + font-style: italic; + margin: 20px 0 30px; + font-family: 'Droid Serif', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +.portfolio-modal .modal-content ul.list-inline { + margin-top: 0; + margin-bottom: 30px; +} + +.portfolio-modal .modal-content img { + margin-bottom: 30px; +} + +.portfolio-modal .modal-content button { + cursor: pointer; +} + +.portfolio-modal .close-modal { + position: absolute; + top: 25px; + right: 25px; + width: 75px; + height: 75px; + cursor: pointer; + background-color: transparent; +} + +.portfolio-modal .close-modal:hover { + opacity: 0.3; +} + +.portfolio-modal .close-modal .lr { + /* Safari and Chrome */ + z-index: 1051; + width: 1px; + height: 75px; + margin-left: 35px; + /* IE 9 */ + -webkit-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + background-color: #212529; +} + +.portfolio-modal .close-modal .lr .rl { + /* Safari and Chrome */ + z-index: 1052; + width: 1px; + height: 75px; + /* IE 9 */ + -webkit-transform: rotate(90deg); + -ms-transform: rotate(90deg); + transform: rotate(90deg); + background-color: #212529; +} + +.timeline { + position: relative; + padding: 0; + list-style: none; +} + +.timeline:before { + position: absolute; + top: 0; + bottom: 0; + left: 40px; + width: 2px; + margin-left: -1.5px; + content: ''; + background-color: #e9ecef; +} + +.timeline > li { + position: relative; + min-height: 50px; + margin-bottom: 50px; +} + +.timeline > li:after, .timeline > li:before { + display: table; + content: ' '; +} + +.timeline > li:after { + clear: both; +} + +.timeline > li .timeline-panel { + position: relative; + float: right; + width: 100%; + padding: 0 20px 0 100px; + text-align: left; +} + +.timeline > li .timeline-panel:before { + right: auto; + left: -15px; + border-right-width: 15px; + border-left-width: 0; +} + +.timeline > li .timeline-panel:after { + right: auto; + left: -14px; + border-right-width: 14px; + border-left-width: 0; +} + +.timeline > li .timeline-image { + position: absolute; + z-index: 100; + left: 0; + width: 80px; + height: 80px; + margin-left: 0; + text-align: center; + color: white; + border: 7px solid #e9ecef; + border-radius: 100%; + background-color: #fed136; +} + +.timeline > li .timeline-image h4 { + font-size: 10px; + line-height: 14px; + margin-top: 12px; +} + +.timeline > li.timeline-inverted > .timeline-panel { + float: right; + padding: 0 20px 0 100px; + text-align: left; +} + +.timeline > li.timeline-inverted > .timeline-panel:before { + right: auto; + left: -15px; + border-right-width: 15px; + border-left-width: 0; +} + +.timeline > li.timeline-inverted > .timeline-panel:after { + right: auto; + left: -14px; + border-right-width: 14px; + border-left-width: 0; +} + +.timeline > li:last-child { + margin-bottom: 0; +} + +.timeline .timeline-heading h4 { + margin-top: 0; + color: inherit; +} + +.timeline .timeline-heading h4.subheading { + text-transform: none; +} + +.timeline .timeline-body > ul, +.timeline .timeline-body > p { + margin-bottom: 0; +} + +@media (min-width: 768px) { + .timeline:before { + left: 50%; + } + + .timeline > li { + min-height: 100px; + margin-bottom: 100px; + } + + .timeline > li .timeline-panel { + float: left; + width: 41%; + padding: 0 20px 20px 30px; + text-align: right; + } + + .timeline > li .timeline-image { + left: 50%; + width: 100px; + height: 100px; + margin-left: -50px; + } + + .timeline > li .timeline-image h4 { + font-size: 13px; + line-height: 18px; + margin-top: 16px; + } + + .timeline > li.timeline-inverted > .timeline-panel { + float: right; + padding: 0 30px 20px 20px; + text-align: left; + } +} + +@media (min-width: 992px) { + .timeline > li { + min-height: 150px; + } + + .timeline > li .timeline-panel { + padding: 0 20px 20px; + } + + .timeline > li .timeline-image { + width: 150px; + height: 150px; + margin-left: -75px; + } + + .timeline > li .timeline-image h4 { + font-size: 18px; + line-height: 26px; + margin-top: 30px; + } + + .timeline > li.timeline-inverted > .timeline-panel { + padding: 0 20px 20px; + } +} + +@media (min-width: 1200px) { + .timeline > li { + min-height: 170px; + } + + .timeline > li .timeline-panel { + padding: 0 20px 20px 100px; + } + + .timeline > li .timeline-image { + width: 170px; + height: 170px; + margin-left: -85px; + } + + .timeline > li .timeline-image h4 { + margin-top: 40px; + } + + .timeline > li.timeline-inverted > .timeline-panel { + padding: 0 100px 20px 20px; + } +} + +.team-member { + margin-bottom: 50px; + text-align: center; +} + +.team-member img { + width: 225px; + height: 225px; + border: 7px solid #fff; +} + +.team-member h4 { + margin-top: 25px; + margin-bottom: 0; + text-transform: none; +} + +.team-member p { + margin-top: 0; +} + +section#contact { + background-color: #212529; + background-image: url("../img/map-image.png"); + background-repeat: no-repeat; + background-position: center; +} + +section#contact .section-heading { + color: #fff; +} + +section#contact .form-group { + margin-bottom: 25px; +} + +section#contact .form-group input, +section#contact .form-group textarea { + padding: 20px; +} + +section#contact .form-group input.form-control { + height: auto; +} + +section#contact .form-group textarea.form-control { + height: 248px; +} + +section#contact .form-control:focus { + border-color: #fed136; + box-shadow: none; +} + +section#contact ::-webkit-input-placeholder { + font-weight: 700; + color: #ced4da; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +section#contact :-moz-placeholder { + font-weight: 700; + color: #ced4da; + /* Firefox 18- */ + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +section#contact ::-moz-placeholder { + font-weight: 700; + color: #ced4da; + /* Firefox 19+ */ + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +section#contact :-ms-input-placeholder { + font-weight: 700; + color: #ced4da; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +footer { + padding: 25px 0; + text-align: center; +} + +footer span.copyright { + font-size: 90%; + line-height: 40px; + text-transform: none; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +footer ul.quicklinks { + font-size: 90%; + line-height: 40px; + margin-bottom: 0; + text-transform: none; + font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +ul.social-buttons { + margin-bottom: 0; +} + +ul.social-buttons li a { + font-size: 20px; + line-height: 40px; + display: block; + width: 40px; + height: 40px; + -webkit-transition: all 0.3s; + -moz-transition: all 0.3s; + transition: all 0.3s; + color: white; + border-radius: 100%; + outline: none; + background-color: #212529; +} + +ul.social-buttons li a:active, ul.social-buttons li a:focus, ul.social-buttons li a:hover { + background-color: #fed136; +} + +.dashboard-card { + background: #ffffff none repeat scroll 0 0; + margin: 15px; + padding: 20px; + border: 0 solid #e7e7e7; + border-radius: 5px; + box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05); +} + +.toolbar-button { + width: 100%; + margin: 5px; +} + +/* --------------------------------------------------- + FEEDBACK STYLE +----------------------------------------------------- */ +.feedback-panel { + list-style-type: none; + padding: 5px; +} + +.feedback-panel .alert { + padding: 5px; + margin-bottom: 5px; + cursor: pointer; +} + +/* --------------------------------------------------- + MEDIAQUERIES +----------------------------------------------------- */ +@media (min-width: 768px) { + section h2.section-heading { + font-size: 3.5vw; + margin-top: 0; + margin-bottom: 15px; + } +} + +@media (min-width: 1500px) { + section h2.section-heading { + font-size: 1.5vw; + margin-top: 0; + margin-bottom: 15px; + } +} + +@media (min-width: 768px) { + .feedback-panel { + position: fixed; + overflow-y: hidden; + max-height: calc(100vh - 60px); + width: 250px; + top: 50px; + right: 15px; + opacity: .8; + z-index: 10000; + } + + .feedback-panel .alert { + padding: 10px; + margin-bottom: 10px; + overflow: hidden; + } + + .feedback-panel .alert:hover { + border-color: #888; + } } \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 2d86945..3bf7f4e 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -10,12 +10,6 @@
-
-
-

Work hard

-

sometimes

-
-
From 81d07645c20b60f7c9ceb742df37a4c03690e06c Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 16 Apr 2019 14:18:49 +0400 Subject: [PATCH 20/20] #65 added delete method of article, fixed copyFromDto method --- .../conference/controller/ConferenceController.java | 10 ++++++++++ .../ru/ulstu/conference/service/ConferenceService.java | 6 ++++++ .../resources/templates/conferences/conference.html | 5 ++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 0f76881..823f853 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -94,6 +94,16 @@ public class ConferenceController { return CONFERENCE_PAGE; } + @PostMapping(value = "/conference", params = "removePaper") + public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors, + @RequestParam(value = "removePaper") Integer paperIndex) throws IOException { + if (errors.hasErrors()) { + return CONFERENCE_PAGE; + } + conferenceService.removePaper(conferenceDto, paperIndex); + return CONFERENCE_PAGE; + } + public List getNotSelectPapers(List paperIds) { return conferenceService.getConferencePapers(paperIds); } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index e95addb..4d267d1 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -83,6 +83,11 @@ public class ConferenceService { conferenceDto.getDeadlines().remove((int) deadlineIndex); } + public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException { + Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex); + conferenceDto.getNotSelectedPapers().add(removedPaper); + } + public List getConferencePapers(List paperIds) { return paperService.findAllNotSelect(paperIds); } @@ -94,6 +99,7 @@ public class ConferenceService { conference.setPing(0); conference.setBeginDate(conferenceDto.getBeginDate()); conference.setEndDate(conferenceDto.getEndDate()); + conference.setPapers(conferenceDto.getPapers()); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) { conferenceDto.getPaperIds().forEach(paperId -> diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 1ed2859..27c602a 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -60,8 +60,7 @@ + alt="Удалить" name="removeDeadline" th:value="${rowStat.index}"/>
@@ -146,7 +145,7 @@ + alt="Удалить" name="removePaper" th:value="${rowStat.index}"/>