Промежуточное

This commit is contained in:
DyCTaTOR 2024-06-05 21:30:31 +04:00
parent b08c3f8162
commit b4e93f7719
6 changed files with 22 additions and 20 deletions

Binary file not shown.

View File

@ -25,6 +25,7 @@ import jakarta.validation.Valid;
@RequestMapping(NewsAdminController.URL)
public class NewsAdminController {
public static final String URL = Constants.ADMIN_PREFIX + "/news";
private static final String NEWS_URL = NewsController.URL;
private static final String NEWS_EDIT_VIEW = "new-edit";
private static final String NEWS_ATTRIBUTE = "news";
private static final String DEPARTMENT_ATTRIBUTE = "departments";
@ -68,14 +69,14 @@ public class NewsAdminController {
return NEWS_EDIT_VIEW;
}
newsService.create(toEntity(newItem));
return Constants.REDIRECT_VIEW + URL;
return Constants.REDIRECT_VIEW + NEWS_URL;
}
@PostMapping("/delete/{id}")
public String delete(
@PathVariable(name = "id") Long id) {
newsService.delete(id);
return Constants.REDIRECT_VIEW + URL;
return Constants.REDIRECT_VIEW + NEWS_URL;
}
@GetMapping("/edit/{id}")
@ -103,6 +104,6 @@ public class NewsAdminController {
throw new IllegalArgumentException();
}
newsService.update(id, toEntity(newItem));
return Constants.REDIRECT_VIEW + URL;
return Constants.REDIRECT_VIEW + NEWS_URL;
}
}

View File

@ -9,15 +9,16 @@
<body>
<main class="text-center" layout:fragment="content">
<th:block th:switch="${departments.size()}">
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<span class="mainSt">
<b>Кафедры</b>
</span>
<div>
<a href="/admin/departments/edit/" class="btn btn-danger">Добавить кафедру</a>
</div>
<th:block th:switch="${departments.size()}">
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<table class="table">
<caption></caption>
<thead>

View File

@ -23,13 +23,12 @@
</div>
</form>
</div>
<div>
<a th:href="@{/admin/directions/edit/(page=${page})}" class="btn btn-danger mt-4">Добавить направление</a>
</div>
<th:block th:switch="${items.size()}">
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<div>
<a th:href="@{/admin/directions/edit/(page=${page})}" class="btn btn-danger mt-4">Добавить
направление</a>
</div>
<table class="table">
<caption></caption>
<thead>

View File

@ -7,7 +7,8 @@
<body>
<main layout:fragment="content">
<form action="#" th:action="@{/news/edit/{id}(id=${news.id},(page=${page}))}" th:object="${news}" method="post">
<form action="#" th:action="@{/admin/news/edit/{id}(id=${news.id},(page=${page}))}" th:object="${news}"
method="post">
<div class="mb-3">
<label for="id" class="form-label">ID</label>
<input type="text" th:value="*{id}" id="id" class="form-control" readonly disabled>

View File

@ -9,15 +9,15 @@
<body>
<main class="text-center" layout:fragment="content">
<th:block th:switch="${items.size()}">
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<span class="mainSt">
<b>Пользователи</b>
</span>
<div>
<a href="/users/edit/" class="btn btn-danger">Добавить пользователя</a>
</div>
<th:block th:switch="${items.size()}">
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<table class="table">
<caption></caption>
<thead>