Готовая 4 лаба

This commit is contained in:
DyCTaTOR 2024-06-02 16:27:38 +04:00
parent abc103ea52
commit b75177292e
3 changed files with 18 additions and 20 deletions

Binary file not shown.

View File

@ -74,11 +74,11 @@ public class NewsController {
model.addAllAttributes(attributes);
model.addAttribute(PAGE_ATTRIBUTE, page);
model.addAttribute(DESCRIPTION_ATTRIBUTE, description);
model.addAttribute("departmentId", departmentId);
model.addAttribute(DEPARTMENT_ATTRIBUTE, getDepartment(departmentId));
if(departmentId != null){
model.addAttribute("departmentId", departmentId);
model.addAttribute(DEPARTMENT_ITEM_ATTRIBUTE, departmentService.get(departmentId));
}
model.addAttribute(DEPARTMENT_ATTRIBUTE, getDepartments());
return NEWS_VIEW;
}

View File

@ -21,23 +21,21 @@
<i class="fa fa-search">Поиск</i>
</button>
</div>
</form>
</div>
<div class="d-flex justify-content-center">
<form class="w-25 mt-2" method="get">
<div class="input-group">
<label for="departmentId" class="form-label"></label>
<select id="departmentId" class="form-control" name="departmentId">
<option th:if="${departmentId} == null" value="">Выберите кафедру</option>
<option th:unless="${departmentId} == null" th:value="${departmentId}"
th:text="${department.name}" />
<option th:each="departmentItem : ${departments}" th:value="${departmentItem.id}"
th:text="${departmentItem.name}" th:selected="${departmentId} == ${departmentItem.id}">
</option>
</select>
<button class="btn btn-primary" type="submit">
<i class="fa fa-check">Выбрать</i>
</button>
<div class="input-group d-flex justify-content-center">
<div class="input-group-append">
<label for="departmentId" class="form-label" />
<select id="departmentId" class="form-control" name="departmentId">
<option th:if="${departmentId} == null" value="" selected>Без фильтра</option>
<option th:each="departmentItem : ${departments}" th:value="${departmentItem.id}"
th:text="${departmentItem.name}" th:selected="${departmentId} == ${departmentItem.id}">
</option>
</select>
</div>
<div class="input-group-append">
<button class="btn btn-primary" type="submit">
<i class="fa fa-check">Выбрать</i>
</button>
</div>
</div>
</form>
</div>
@ -45,7 +43,7 @@
<h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*">
<div>
<a href="/news/edit/(page=${page})" class="btn btn-danger mt-4">Добавить новость</a>
<a th:href="@{/news/edit/(page=${page})}" class="btn btn-danger mt-4">Добавить новость</a>
</div>
<div class="row">
<div class="col mt-4 colStyle" th:each="newItem : ${items}">