fixes #33 - set a term(s) status via the keyboard #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes the following changes to /static/js/lute.js:
Adds a new function called
increment_status_for_marked_elements
This function collects selected term elements, groups them by their
data_status_class
level, then submits them in batches to be updated withupdate_status_for_elements
.This function accepts a single argument
shiftBy
, an integer indicating the amount and direction to increment the status class as defined in the constantvalidStatuses
.Abstracts the code in
update_status_for_marked_elements
into a new generic functionupdate_status_for_elements
Separating the selection of elements from the code that submits them to the server allows other functions to update statuses for different use cases.
update_status_for_elements
takes two argumentsnew_status
: the status that will be set on the elementselements
: a nodeList, array, or jQuery selection of elements to updatePasses a new argument to
update_selected_statuses
update_selected_statuses
was doing a redundant selection of elements to update what was sent the server byupdate_status_for_marked_elements
. Passing anelements
argument instead allows more flexibility upstream and removes duplicated element selection code.Binds arrow up and arrow down keys to
increment_status_for_marked_elements
inhandle_keydown