<!DOCTYPE html>
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Новости</title>
</head>

<body>
    <main class="text-center" layout:fragment="content">
        <span class="mainSt">
            <b>Новости</b>
        </span>
        <div>
            <a href="/news/edit/" class="btn btn-danger">Добавить новость</a>
        </div>
        <table class="table">
            <caption></caption>
            <thead>
                <tr>
                    <th scope="col" class="w-5">ID</th>
                    <th scope="col" class="w-10">Дата публикации</th>
                    <th scope="col" class="w-25">Заголовок</th>
                    <th scope="col" class="w-50">Описание</th>
                    <th scope="col" class="w-10"></th>
                    <th scope="col" class="w-10"></th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="newItem : ${news}">
                    <th scope="row" th:text="${newItem.id}"></th>
                    <td th:text="${newItem.date}"></td>
                    <td th:text="${newItem.name}"></td>
                    <td th:text="${newItem.description}"></td>
                    <td>
                        <form th:action="@{/news/edit/{id}(id=${newItem.id})}" method="get">
                            <button type="submit" class="btn btn-link button-link">
                                <i class="fa fa-edit">Изменить</i>
                            </button>
                        </form>
                    </td>
                    <td>
                        <form th:action="@{/news/delete/{id}(id=${newItem.id})}" method="post">
                            <button type="submit" class="btn btn-link button-link"
                                onclick="return confirm('Вы уверены?')">
                                <i class="fa fa-trash">Удалить</i>
                            </button>
                        </form>
                    </td>
                </tr>
            </tbody>
        </table>
    </main>
</body>

</html>