Готовая 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.addAllAttributes(attributes);
model.addAttribute(PAGE_ATTRIBUTE, page); model.addAttribute(PAGE_ATTRIBUTE, page);
model.addAttribute(DESCRIPTION_ATTRIBUTE, description); model.addAttribute(DESCRIPTION_ATTRIBUTE, description);
model.addAttribute("departmentId", departmentId);
model.addAttribute(DEPARTMENT_ATTRIBUTE, getDepartment(departmentId));
if(departmentId != null){ if(departmentId != null){
model.addAttribute("departmentId", departmentId);
model.addAttribute(DEPARTMENT_ITEM_ATTRIBUTE, departmentService.get(departmentId)); model.addAttribute(DEPARTMENT_ITEM_ATTRIBUTE, departmentService.get(departmentId));
} }
model.addAttribute(DEPARTMENT_ATTRIBUTE, getDepartments());
return NEWS_VIEW; return NEWS_VIEW;
} }

View File

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