Skip to content

Commit

Permalink
Add keyboard shortcuts for setting flag state in quick review mode
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin committed Jul 4, 2023
1 parent 987684b commit 6775589
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions evap/staff/templates/staff_evaluation_textanswers_quick.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ <h5 class="modal-title" id="hotkeys-modal-title">Hotkeys</h5>
<tr><td><kbd>L</kbd></td><td>{% trans 'Delete answer' %}</td></tr>
<tr><td><kbd>&#x232b;</kbd></td><td>{% trans 'Unreview answer' %}</td></tr>
<tr><td><kbd>E</kbd></td><td>{% trans 'Edit answer' %}</td></tr>
<tr><td><kbd>F</kbd></td><td>{% trans 'Set flag' %}</td></tr>
<tr><td><kbd>D</kbd></td><td>{% trans 'Clear flag' %}</td></tr>
<tr><td><kbd>&#x21b2;</kbd></td><td>{% trans 'Review next evaluation' %}</td></tr>
<tr><td><kbd>S</kbd></td><td>{% trans 'Skip evaluation' %}</td></tr>
<tr><td><kbd>N</kbd></td><td>{% trans 'Show all again' %}</td></tr>
Expand Down
5 changes: 4 additions & 1 deletion evap/static/ts/src/quick-review-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]"],
Expand Down Expand Up @@ -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<HTMLInputElement>(selector, this.slider);
input.checked = true;
};
Expand Down

0 comments on commit 6775589

Please sign in to comment.