Fix learn dialog rendering, add lab publish/draft toggle, bump to v0.1.2

- learn/index.html: restructured dialogs inside section divs to fix scope
- learn/index.html: edit-article dialogs via flat articles list in modal blocks
- LearnController: sectionChoices for select options; secure article fetching
- ContentService: createArticlePlaced: new section adjacent to anchor section
- lab status: published = student-visible, draft = hidden
- lab toggle: click badge in labs list or button in lab header to switch status
- added badge-btn CSS class, removed inline styles
- removed all th:onclick with expressions → data-modal attributes
- footer v0.1.2
This commit is contained in:
2026-09-11 20:41:11 +03:00
parent 006951adae
commit caa48d3193
11 changed files with 219 additions and 131 deletions

View File

@@ -7,6 +7,8 @@
<h1 class="page-title">Лабораторные</h1>
<button class="btn btn-primary" type="button" onclick="openModal('modal-create-lab')">+ Создать</button>
</div>
<p class="text-sm text-muted mb-4">Статус <b>draft</b> — черновик (редактирование, студентам не видна).
<b>published</b> — опубликована (доступна студентам, видны распределённые варианты). Нажмите на бейдж статуса, чтобы переключить.</p>
<div th:if="${notice}" class="alert alert-success" th:text="${notice}"></div>
<div th:if="${error}" class="alert alert-error" th:text="${error}"></div>
@@ -18,7 +20,14 @@
<td th:text="${lab.number}">1</td>
<td><a th:href="@{/admin/labs/{id}(id=${lab.id})}" th:text="${lab.title}">—</a></td>
<td th:text="${lab.variantCount}">0</td>
<td><span class="badge" th:classappend="${lab.status == 'published'} ? 'badge-ok' : 'badge-warn'" th:text="${lab.status}">—</span></td>
<td>
<form class="inline-form" th:action="@{/admin/labs/{id}/toggle-status(id=${lab.id})}" method="post">
<input type="hidden" name="_csrf" th:value="${csrfToken}">
<button class="badge badge-btn"
th:classappend="${lab.status == 'published'} ? 'badge-ok' : 'badge-warn'"
type="submit" th:text="${lab.status}">—</button>
</form>
</td>
<td class="text-center"><form th:action="@{/admin/labs/{id}/delete(id=${lab.id})}" method="post"><input type="hidden" name="_csrf" th:value="${csrfToken}"><button class="btn btn-danger btn-sm" type="submit">Удалить</button></form></td>
</tr>
<tr th:if="${#lists.isEmpty(labs)}"><td colspan="5" class="empty">Лабораторных пока нет.</td></tr>