Autocomplete on all database objects

This commit is contained in:
Dan Sosedoff 2019-12-04 19:36:09 -06:00
parent e54030dee9
commit 5d2ec70476
2 changed files with 53 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,9 @@
var editor = null;
var connected = false;
var bookmarks = {};
var default_rows_limit = 100;
var currentObject = null;
var editor = null;
var connected = false;
var bookmarks = {};
var default_rows_limit = 100;
var currentObject = null;
var autocompleteObjects = [];
var filterOptions = {
"equal": "= 'DATA'",
@ -162,6 +163,23 @@ function loadSchemas() {
$(".schema").addClass("expanded");
}
// Clear out all autocomplete objects
autocompleteObjects = [];
for (schema in data) {
for (kind in data[schema]) {
if (!(kind == "table" || kind == "view" || kind == "materialized_view")) {
continue
}
for (item in data[schema][kind]) {
autocompleteObjects.push({
caption: data[schema][kind][item],
value: data[schema][kind][item],
meta: kind
});
}
}
}
bindContextMenus();
});
}
@ -712,13 +730,21 @@ function buildTableFilters(name, type) {
});
}
var objectAutocompleter = {
getCompletions: function (editor, session, pos, prefix, callback) {
callback(null, autocompleteObjects);
}
}
function initEditor() {
var writeQueryTimeout = null;
editor = ace.edit("custom_query");
editor.setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
});
editor.completers.push(objectAutocompleter);
editor.setFontSize(13);
editor.setTheme("ace/theme/tomorrow");