mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
Ensure we can edit grid values in the debugger using keyboard shortcuts. Fixes #3153
This commit is contained in:
parent
efcf87636d
commit
92a0bb605d
@ -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';
|
import $ from 'jquery';
|
||||||
|
|
||||||
const PERIOD_KEY = 190,
|
const PERIOD_KEY = 190,
|
||||||
|
23
web/pgadmin/tools/debugger/static/js/debugger_utils.js
Normal file
23
web/pgadmin/tools/debugger/static/js/debugger_utils.js
Normal 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,
|
||||||
|
};
|
@ -2,10 +2,11 @@ define([
|
|||||||
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
|
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
|
||||||
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
|
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
|
||||||
'pgadmin.backgrid', 'pgadmin.backform', 'sources/../bundle/codemirror',
|
'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(
|
], function(
|
||||||
gettext, url_for, $, _, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
|
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,
|
var CodeMirror = codemirror.default,
|
||||||
@ -185,7 +186,6 @@ define([
|
|||||||
'CodeMirror-activeline-background'
|
'CodeMirror-activeline-background'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call function to create and update local variables ....
|
// Call function to create and update local variables ....
|
||||||
self.GetStackInformation(trans_id);
|
self.GetStackInformation(trans_id);
|
||||||
if (pgTools.DirectDebug.debug_type) {
|
if (pgTools.DirectDebug.debug_type) {
|
||||||
@ -345,7 +345,6 @@ define([
|
|||||||
'wrap', 'CodeMirror-activeline-background'
|
'wrap', 'CodeMirror-activeline-background'
|
||||||
);
|
);
|
||||||
self.active_line_no = (res.data.result[0].linenumber - 2);
|
self.active_line_no = (res.data.result[0].linenumber - 2);
|
||||||
|
|
||||||
// Update the stack, local variables and parameters information
|
// Update the stack, local variables and parameters information
|
||||||
self.GetStackInformation(trans_id);
|
self.GetStackInformation(trans_id);
|
||||||
|
|
||||||
@ -1211,8 +1210,10 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
variable_grid.collection.on(
|
variable_grid.collection.on(
|
||||||
'backgrid:edited', () => {
|
'backgrid:edited', (ch1, ch2, command) => {
|
||||||
pgTools.DirectDebug.editor.focus();
|
debuggerUtils.setFocusToDebuggerEditor(
|
||||||
|
pgTools.DirectDebug.editor, command
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1294,8 +1295,10 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
param_grid.collection.on(
|
param_grid.collection.on(
|
||||||
'backgrid:edited', () => {
|
'backgrid:edited', (ch1, ch2, command) => {
|
||||||
pgTools.DirectDebug.editor.focus();
|
debuggerUtils.setFocusToDebuggerEditor(
|
||||||
|
pgTools.DirectDebug.editor, command
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1371,7 +1374,6 @@ define([
|
|||||||
(res.data.result[0].linenumber - 2), 'wrap',
|
(res.data.result[0].linenumber - 2), 'wrap',
|
||||||
'CodeMirror-activeline-background'
|
'CodeMirror-activeline-background'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Call function to create and update local variables ....
|
// Call function to create and update local variables ....
|
||||||
self.GetLocalVariables(pgTools.DirectDebug.trans_id);
|
self.GetLocalVariables(pgTools.DirectDebug.trans_id);
|
||||||
}
|
}
|
||||||
|
44
web/regression/javascript/debugger_utils_spec.js
Normal file
44
web/regression/javascript/debugger_utils_spec.js
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -230,6 +230,7 @@ var webpackShimConfig = {
|
|||||||
'pgadmin.tools.import_export': path.join(__dirname, './pgadmin/tools/import_export/static/js/import_export'),
|
'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.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.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.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.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'),
|
'pgadmin.browser.collection': path.join(__dirname, './pgadmin/browser/static/js/collection'),
|
||||||
|
Loading…
Reference in New Issue
Block a user