Skip to content

Commit

Permalink
Add keyboard shortcut for toggling flag state of textanswer
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin committed Jul 3, 2023
1 parent 987684b commit ab96634
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <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 'Toggle 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
4 changes: 3 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,7 @@ export class QuickReviewSlider {
["l", submitSelectorForAction(Action.Delete)],
["backspace", submitSelectorForAction(Action.Unreview)],
["e", submitSelectorForAction(Action.TextanswerEdit)],
["f", inputSelectorForFlagState(!("isFlagged" in this.selectedSlide.dataset))],
["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 +313,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 ab96634

Please sign in to comment.