Ensure we can edit grid values in the debugger using keyboard shortcuts. Fixes #3153

This commit is contained in:
Murtuza Zabuawala 2018-03-02 15:05:04 +00:00 committed by Dave Page
parent efcf87636d
commit 92a0bb605d
5 changed files with 88 additions and 9 deletions

View File

@ -1,3 +1,12 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
import $ from 'jquery';
const PERIOD_KEY = 190,

View File

@ -0,0 +1,23 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
function setFocusToDebuggerEditor(editor, command) {
const TAB = 9;
if (!command)
return;
let key = command.which || command.keyCode;
// Keys other than Tab key
if (key !== TAB) {
editor.focus();
}
}
module.exports = {
setFocusToDebuggerEditor: setFocusToDebuggerEditor,
};

View File

@ -2,10 +2,11 @@ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
'pgadmin.backgrid', 'pgadmin.backform', 'sources/../bundle/codemirror',
'pgadmin.tools.debugger.ui', 'sources/keyboard_shortcuts', 'wcdocker',
'pgadmin.tools.debugger.ui', 'sources/keyboard_shortcuts',
'pgadmin.tools.debugger.utils', 'wcdocker',
], function(
gettext, url_for, $, _, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
Backform, codemirror, debug_function_again, keyboardShortcuts
Backform, codemirror, debug_function_again, keyboardShortcuts, debuggerUtils
) {
var CodeMirror = codemirror.default,
@ -185,7 +186,6 @@ define([
'CodeMirror-activeline-background'
);
}
// Call function to create and update local variables ....
self.GetStackInformation(trans_id);
if (pgTools.DirectDebug.debug_type) {
@ -345,7 +345,6 @@ define([
'wrap', 'CodeMirror-activeline-background'
);
self.active_line_no = (res.data.result[0].linenumber - 2);
// Update the stack, local variables and parameters information
self.GetStackInformation(trans_id);
@ -1211,8 +1210,10 @@ define([
});
variable_grid.collection.on(
'backgrid:edited', () => {
pgTools.DirectDebug.editor.focus();
'backgrid:edited', (ch1, ch2, command) => {
debuggerUtils.setFocusToDebuggerEditor(
pgTools.DirectDebug.editor, command
);
}
);
@ -1294,8 +1295,10 @@ define([
});
param_grid.collection.on(
'backgrid:edited', () => {
pgTools.DirectDebug.editor.focus();
'backgrid:edited', (ch1, ch2, command) => {
debuggerUtils.setFocusToDebuggerEditor(
pgTools.DirectDebug.editor, command
);
}
);
@ -1371,7 +1374,6 @@ define([
(res.data.result[0].linenumber - 2), 'wrap',
'CodeMirror-activeline-background'
);
// Call function to create and update local variables ....
self.GetLocalVariables(pgTools.DirectDebug.trans_id);
}

View File

@ -0,0 +1,44 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
import { setFocusToDebuggerEditor } from '../../pgadmin/tools/debugger/static/js/debugger_utils';
describe('debuggerUtils', function () {
let editor;
editor = jasmine.createSpyObj('editor', ['focus']);
let tab_key = {
which: 9,
keyCode: 9,
}
let enter_key = {
which: 13,
keyCode: 13,
}
describe('debuggerUtils', function () {
it('returns undefined if no command is passed', function () {
expect(setFocusToDebuggerEditor(editor, null)).toEqual(undefined);
});
});
describe('debuggerUtils', function () {
it('should call focus on editor', function () {
setFocusToDebuggerEditor(editor, enter_key)
expect(editor.focus).toHaveBeenCalled();
});
});
describe('debuggerUtils', function () {
it('should not call focus on editor and returns undefined', function () {
expect(setFocusToDebuggerEditor(editor, tab_key)).toEqual(undefined);
});
});
});

View File

@ -230,6 +230,7 @@ var webpackShimConfig = {
'pgadmin.tools.import_export': path.join(__dirname, './pgadmin/tools/import_export/static/js/import_export'),
'pgadmin.node.view': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view'),
'pgadmin.tools.debugger.ui': path.join(__dirname, './pgadmin/tools/debugger/static/js/debugger_ui'),
'pgadmin.tools.debugger.utils': path.join(__dirname, './pgadmin/tools/debugger/static/js/debugger_utils'),
'pgadmin.node.pga_schedule': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule'),
'pgadmin.node.catalog_object_column': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column'),
'pgadmin.browser.collection': path.join(__dirname, './pgadmin/browser/static/js/collection'),