Skip to content

Commit

Permalink
Merge pull request #180 from RitvikSardana/develop-ritvik-tab-enter-ux
Browse files Browse the repository at this point in the history
fix(UX): Navigate between rows using "Enter" & "Tab" in Assessment Result Tool
  • Loading branch information
RitvikSardana authored Jan 26, 2024
2 parents 7f77de8 + 521cb9b commit 570cf9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ frappe.ui.form.on('Assessment Result Tool', {
}));
result_table.appendTo(frm.fields_dict.result_html.wrapper);

$(".assessment-criteria").on("keydown",function (e) {
// get data-criteria attribute
let criteriaIndex = cint(e.target.parentElement.getAttribute('data-criteria-index'));
changeFocusToNextCell(e, 2 + criteriaIndex)
})

$(".result-comment").on("keydown",function (e) {
changeFocusToNextCell(e, 5)
})

function changeFocusToNextCell (e,cellIndex) {
if (e.keyCode === 13 && !e.shiftKey) {
let nextRow = e.target.parentElement.parentElement.nextElementSibling;
if (nextRow) {
nextRow.cells[cellIndex].lastElementChild.focus()
}
}
if (e.keyCode === 13 && e.shiftKey) {
let prevRow = e.target.parentElement.parentElement.previousElementSibling;
if (prevRow) {
prevRow.cells[cellIndex].lastElementChild.focus()
}
}
}

result_table.on('change', 'input', function(e) {
let $input = $(e.target);
let student = $input.data().student;
Expand Down
2 changes: 1 addition & 1 deletion education/public/js/assessment_result_tool.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<td>{{ s.student }}</td>
<td>{{ s.student_name }}</td>
{% for c in criteria %}
<td>
<td class="assessment-criteria" data-criteria-index="{{c._index}}">
<span data-student="{{s.student}}" data-criteria="{{c.assessment_criteria}}" class="student-result-grade badge" >
{% if(s.assessment_details) { %}
{{s.assessment_details[c.assessment_criteria][1]}}
Expand Down

0 comments on commit 570cf9c

Please sign in to comment.