#76 delete function added
This commit is contained in:
parent
9da227ab34
commit
59887e5141
@ -71,6 +71,13 @@ public class TaskController {
|
||||
return TASK_PAGE;
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{task-id}")
|
||||
public String delete(@PathVariable("task-id") Integer taskId) throws IOException {
|
||||
taskService.delete(taskId);
|
||||
return String.format(REDIRECT_TO, TASKS_PAGE);
|
||||
}
|
||||
|
||||
|
||||
@ModelAttribute("allStatuses")
|
||||
public List<Task.TaskStatus> getTaskStatuses() {
|
||||
return taskService.getTaskStatuses();
|
||||
|
@ -76,8 +76,10 @@ public class TaskService {
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer taskId) throws IOException {
|
||||
Task task = taskRepository.findOne(taskId);
|
||||
taskRepository.delete(task);
|
||||
if (taskRepository.exists(taskId)) {
|
||||
taskRepository.delete(taskId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void save(TaskDto taskDto) throws IOException {
|
||||
|
@ -90,7 +90,7 @@ $(document).ready(function () {
|
||||
' <div class="modal-dialog modal-sm">\n' +
|
||||
' <div class="modal-content">\n' +
|
||||
' <div class="modal-header">\n' +
|
||||
' <h8 class="modal-title" id="myModalLabel">Удалить статью?</h8>\n' +
|
||||
' <h8 class="modal-title" id="myModalLabel">Удалить задачу?</h8>\n' +
|
||||
' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' +
|
||||
' aria-hidden="true">×</span></button>\n' +
|
||||
' </div>\n' +
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<body>
|
||||
<div class="container" layout:fragment="content">
|
||||
<form id="tasks-form" method="post" th:action="@{'/tasks/tasks'}">
|
||||
<form id="tasks-form" method="post" th:action="@{'/students/tasks'}">
|
||||
<input th:type="hidden" name="taskDeleteId" id="taskDeleteId"/>
|
||||
<section id="tasks">
|
||||
<div class="container">
|
||||
|
Loading…
Reference in New Issue
Block a user