Lab variants: redirect back anchors to the saved variant with highlight
This commit is contained in:
@@ -403,14 +403,24 @@ class AdminLabController(
|
|||||||
redirect: RedirectAttributes,
|
redirect: RedirectAttributes,
|
||||||
): String =
|
): String =
|
||||||
try {
|
try {
|
||||||
api.saveVariant(
|
val detail =
|
||||||
token(session),
|
api.saveVariant(
|
||||||
labId,
|
token(session),
|
||||||
form.variantId,
|
labId,
|
||||||
VariantSavePayload(form.labLevelId, form.number, form.title, form.statementMd),
|
form.variantId,
|
||||||
)
|
VariantSavePayload(form.labLevelId, form.number, form.title, form.statementMd),
|
||||||
|
)
|
||||||
redirect.addFlashAttribute("notice", "Вариант сохранён")
|
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) {
|
} catch (ex: ApiException) {
|
||||||
redirect.addFlashAttribute("error", ex.message)
|
redirect.addFlashAttribute("error", ex.message)
|
||||||
"redirect:/admin/labs/$labId"
|
"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; }
|
.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); }
|
.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; }
|
.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 { font-weight: 600; }
|
||||||
.variant-name b { font-variant-numeric: tabular-nums; }
|
.variant-name b { font-variant-numeric: tabular-nums; }
|
||||||
p { margin-top: 0; }
|
p { margin-top: 0; }
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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="flex flex-wrap items-center justify-between gap-2">
|
||||||
<div class="variant-name">Вариант <b th:text="${v.number}">—</b><span th:if="${v.title}"
|
<div class="variant-name">Вариант <b th:text="${v.number}">—</b><span th:if="${v.title}"
|
||||||
class="text-muted"
|
class="text-muted"
|
||||||
|
|||||||
Reference in New Issue
Block a user