Lab variants: redirect back anchors to the saved variant with highlight
This commit is contained in:
@@ -403,14 +403,24 @@ class AdminLabController(
|
||||
redirect: RedirectAttributes,
|
||||
): String =
|
||||
try {
|
||||
api.saveVariant(
|
||||
token(session),
|
||||
labId,
|
||||
form.variantId,
|
||||
VariantSavePayload(form.labLevelId, form.number, form.title, form.statementMd),
|
||||
)
|
||||
val detail =
|
||||
api.saveVariant(
|
||||
token(session),
|
||||
labId,
|
||||
form.variantId,
|
||||
VariantSavePayload(form.labLevelId, form.number, form.title, form.statementMd),
|
||||
)
|
||||
redirect.addFlashAttribute("notice", "Вариант сохранён")
|
||||
"redirect:/admin/labs/$labId"
|
||||
// вернуться к отредактированному/созданному варианту на странице лабы
|
||||
val anchor =
|
||||
form.variantId
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?: detail.levels
|
||||
.firstOrNull { it.id == form.labLevelId }
|
||||
?.variants
|
||||
?.firstOrNull { it.number == form.number.trim() }
|
||||
?.id
|
||||
if (anchor.isNullOrBlank()) "redirect:/admin/labs/$labId" else "redirect:/admin/labs/$labId#variant-$anchor"
|
||||
} catch (ex: ApiException) {
|
||||
redirect.addFlashAttribute("error", ex.message)
|
||||
"redirect:/admin/labs/$labId"
|
||||
|
||||
@@ -89,6 +89,7 @@ a:not(.btn):hover { color: var(--c-accent-hover); }
|
||||
.user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.84375rem; margin-left: auto; }
|
||||
.nav-user { font-weight: 500; color: var(--c-text); }
|
||||
.score-big { display: inline-block; margin-left: 0.5rem; font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--c-tone-pos); font-variant-numeric: tabular-nums; vertical-align: middle; }
|
||||
.variant-block:target { outline: 2px solid var(--c-accent); outline-offset: 4px; border-radius: var(--radius); }
|
||||
.variant-name { font-weight: 600; }
|
||||
.variant-name b { font-variant-numeric: tabular-nums; }
|
||||
p { margin-top: 0; }
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div th:each="v : ${level.variants}" class="variant-block mb-4">
|
||||
<div th:each="v : ${level.variants}" class="variant-block mb-4" th:id="'variant-' + ${v.id}">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="variant-name">Вариант <b th:text="${v.number}">—</b><span th:if="${v.title}"
|
||||
class="text-muted"
|
||||
|
||||
Reference in New Issue
Block a user