From 56d79d0c2116b1025a31e8b34ee74fec447641a6 Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Mon, 10 Jul 2023 19:53:35 +0200 Subject: [PATCH] Add keyboard shortcuts for setting flag state in quick review mode (#1973) --- evap/staff/templates/staff_evaluation_textanswers_quick.html | 2 ++ evap/static/ts/src/quick-review-slider.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/evap/staff/templates/staff_evaluation_textanswers_quick.html b/evap/staff/templates/staff_evaluation_textanswers_quick.html index f1d1c80a17..2b4c4ef7eb 100644 --- a/evap/staff/templates/staff_evaluation_textanswers_quick.html +++ b/evap/staff/templates/staff_evaluation_textanswers_quick.html @@ -19,6 +19,8 @@ L{% trans 'Delete answer' %} {% trans 'Unreview answer' %} E{% trans 'Edit answer' %} + F{% trans 'Set flag' %} + D{% trans 'Clear flag' %} {% trans 'Review next evaluation' %} S{% trans 'Skip evaluation' %} N{% trans 'Show all again' %} diff --git a/evap/static/ts/src/quick-review-slider.ts b/evap/static/ts/src/quick-review-slider.ts index b5480dd206..5be4b00429 100644 --- a/evap/static/ts/src/quick-review-slider.ts +++ b/evap/static/ts/src/quick-review-slider.ts @@ -49,6 +49,7 @@ interface NavigationButtonWithCounters { } const submitSelectorForAction = (action: Action) => `[type=submit][name=action][value=${action}]`; +const inputSelectorForFlagState = (isFlagged: boolean) => `input[name="is_flagged"][value=${isFlagged.toString()}]`; export class QuickReviewSlider { private readonly slider: HTMLElement; @@ -198,6 +199,8 @@ export class QuickReviewSlider { ["l", submitSelectorForAction(Action.Delete)], ["backspace", submitSelectorForAction(Action.Unreview)], ["e", submitSelectorForAction(Action.TextanswerEdit)], + ["f", inputSelectorForFlagState(true)], + ["d", inputSelectorForFlagState(false)], ["enter", `[data-url=next-evaluation][data-next-evaluation-index="${this.nextEvaluationIndex}"]`], ["m", "[data-startover=undecided]"], ["n", "[data-startover=all]"], @@ -311,7 +314,7 @@ export class QuickReviewSlider { } }; private updateFlaggedToggle = () => { - const selector = `input[name="is_flagged"][value=${("isFlagged" in this.selectedSlide.dataset).toString()}]`; + const selector = inputSelectorForFlagState("isFlagged" in this.selectedSlide.dataset); const input = selectOrError(selector, this.slider); input.checked = true; };