diff --git a/resources/assets/js/components/RowsEditor.vue b/resources/assets/js/components/RowsEditor.vue index e4eee85..a0bab0c 100644 --- a/resources/assets/js/components/RowsEditor.vue +++ b/resources/assets/js/components/RowsEditor.vue @@ -102,8 +102,11 @@ Rows are identified by row._id, columns by col.id @@ -366,6 +369,49 @@ Rows are identified by row._id, columns by col.id _.each(this.rows, (row, id) => { this.$set(this.rows[id], '_editing', true) }) + }, + + /** + * Move to next or prev editable cell vertically + * + * @param row_id + * @param col_id + * @param dir - +1 down, -1 up + */ + verticalTab (row_id, col_id, dir) { + if (dir == -1) { + // up + let last_editable_row = null + for (let row of Object.values(this.rows)) { + if (row._id === row_id) { + break + } + if (row._editing || this.newRows) { + last_editable_row = row + } + } + if (last_editable_row) { + this.$refs[`edit-${last_editable_row._id}-${col_id}`][0].focus() + } + } + else { + // down + let first_editable_row = null + let foundself = false + for (let row of Object.values(this.rows)) { + if (row._id === row_id) { + foundself = true + continue + } + if (foundself && (row._editing || this.newRows)) { + first_editable_row = row + break + } + } + if (first_editable_row) { + this.$refs[`edit-${first_editable_row._id}-${col_id}`][0].focus() + } + } } }, }