Learn: remember expanded sections, open only in the last chapter by default

This commit is contained in:
2026-09-17 20:41:54 +03:00
parent 3730c1f173
commit ac7f1d7168
3 changed files with 25 additions and 5 deletions

View File

@@ -27,7 +27,7 @@
Материалы ещё не добавлены.
</div>
<div th:each="chapter : ${tree?.chapters}" class="card card-body chapter-card mb-4"
<div th:each="chapter, chStat : ${tree?.chapters}" class="card card-body chapter-card mb-4"
th:attr="data-chapter-id=${chapter.id}">
<div class="sort-row">
<span th:if="${currentUser != null and currentUser.admin}" class="drag-handle" draggable="true"
@@ -57,12 +57,13 @@
<div data-section-list>
<p th:if="${#lists.isEmpty(chapter.sections)}" class="text-sm text-muted mt-2 mb-0">Разделов пока нет</p>
<div th:each="section : ${chapter.sections}" class="sub-acc" th:attr="data-section-id=${section.id}">
<div th:each="section : ${chapter.sections}" class="sub-acc collapsed"
th:attr="data-section-id=${section.id},data-default-open=${chStat.last}">
<div class="sub-head sort-row">
<span th:if="${currentUser != null and currentUser.admin}" class="drag-handle" draggable="true"
th:attr="data-drag-kind='section',data-drag-id=${section.id}"
title="Перетащите мышью: изменить порядок или перенести раздел">⠿</span>
<button type="button" class="sub-toggle" aria-expanded="true" onclick="toggleSection(this)"
<button type="button" class="sub-toggle" aria-expanded="false" onclick="toggleSection(this)"
title="Свернуть или развернуть раздел">
<span class="sub-arrow" aria-hidden="true"></span>
</button>