Newer
Older
teacher-diary / src / main / resources / templates / subject / list.html
@malexple malexple 19 days ago 2 KB fix subject
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org"
      th:replace="~{layout/main :: html(pageTitle='Предметы', activeMenu='subjects', content=~{::content}, scripts=~{})}">
<body>
<th:block th:fragment="content">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <span class="text-muted" th:text="'Всего: ' + ${subjects.size()}"></span>
        </div>
        <a th:href="@{/subjects/new}" class="btn btn-primary">
            <i class="bi bi-plus-lg me-1"></i> Добавить предмет
        </a>
    </div>

    <div th:if="${success}" class="alert alert-success" th:text="${success}"></div>
    <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>

    <div class="card">
        <div class="table-responsive" th:if="${!subjects.isEmpty()}">
            <table class="table table-hover mb-0">
                <thead>
                <tr>
                    <th>Название</th>
                    <th>Описание</th>
                    <th width="150"></th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="subject : ${subjects}">
                    <td class="fw-medium" th:text="${subject.name}"></td>
                    <td class="text-muted" th:text="${subject.description ?: '—'}"></td>
                    <td>
                        <div class="btn-group btn-group-sm">
                            <a th:href="@{/subjects/{id}/edit(id=${subject.id})}" class="btn btn-outline-primary">
                                <i class="bi bi-pencil"></i>
                            </a>
                            <form th:action="@{/subjects/{id}/delete(id=${subject.id})}" method="post" class="d-inline">
                                <button type="submit" class="btn btn-outline-danger" onclick="return confirm('Удалить предмет?')">
                                    <i class="bi bi-trash"></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <div th:if="${subjects.isEmpty()}" class="card-body text-center py-5">
            <i class="bi bi-book text-muted" style="font-size: 48px;"></i>
            <p class="text-muted mt-3 mb-0">Предметов пока нет</p>
            <a th:href="@{/subjects/new}" class="btn btn-primary mt-3">Добавить первый предмет</a>
        </div>
    </div>
</th:block>
</body>
</html>