From 570e1171cac22a461c12653d8f335b76f43cdc69 Mon Sep 17 00:00:00 2001
From: Allen Short
Date: Tue, 19 Dec 2017 22:09:13 +0000
Subject: [PATCH] Toggle for query editor autocomplete (re #282)
---
client/app/components/queries/query-editor.js | 13 +++++++++----
client/app/pages/data-sources/show.js | 1 -
client/app/pages/destinations/show.js | 1 -
client/app/pages/queries/query.html | 17 +++++++----------
client/app/pages/queries/source-view.js | 5 +++++
5 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/client/app/components/queries/query-editor.js b/client/app/components/queries/query-editor.js
index 31b8cc1187..1738b17b05 100644
--- a/client/app/components/queries/query-editor.js
+++ b/client/app/components/queries/query-editor.js
@@ -84,10 +84,11 @@ function queryEditor(QuerySnippet, $timeout) {
if (newSchema === undefined) {
return;
}
- const tokensCount = newSchema.reduce((totalLength, table) => totalLength + table.columns.length, 0);
- // If there are too many tokens we disable live autocomplete,
- // as it makes typing slower.
- if (tokensCount > 5000) {
+ const tokensCount =
+ newSchema.reduce((totalLength, table) => totalLength + table.columns.length, 0);
+ // If there are too many tokens or if it's requested via the UI
+ // we disable live autocomplete, as it makes typing slower.
+ if (tokensCount > 5000 || !$scope.$parent.autocompleteQuery) {
editor.setOption('enableLiveAutocompletion', false);
editor.setOption('enableBasicAutocompletion', false);
} else {
@@ -100,6 +101,10 @@ function queryEditor(QuerySnippet, $timeout) {
$scope.$parent.$on('angular-resizable.resizing', () => {
editor.resize();
});
+ $scope.$parent.$watch('autocompleteQuery', () => {
+ editor.setOption('enableLiveAutocompletion', $scope.$parent.autocompleteQuery);
+ editor.setOption('enableBasicAutocompletion', $scope.$parent.autocompleteQuery);
+ });
editor.focus();
},
diff --git a/client/app/pages/data-sources/show.js b/client/app/pages/data-sources/show.js
index 0e95d2c394..072ac98391 100644
--- a/client/app/pages/data-sources/show.js
+++ b/client/app/pages/data-sources/show.js
@@ -8,7 +8,6 @@ function DataSourceCtrl(
$scope, $route, $routeParams, $http, $location, toastr,
currentUser, DataSource,
) {
-
$scope.dataSource = $route.current.locals.dataSource;
$scope.dataSourceId = $routeParams.dataSourceId;
$scope.types = $route.current.locals.types;
diff --git a/client/app/pages/destinations/show.js b/client/app/pages/destinations/show.js
index 939371530a..cb98c563ff 100644
--- a/client/app/pages/destinations/show.js
+++ b/client/app/pages/destinations/show.js
@@ -8,7 +8,6 @@ function DestinationCtrl(
$scope, $route, $routeParams, $http, $location, toastr,
currentUser, Destination,
) {
-
$scope.destination = $route.current.locals.destination;
$scope.destinationId = $routeParams.destinationId;
$scope.types = $route.current.locals.types;
diff --git a/client/app/pages/queries/query.html b/client/app/pages/queries/query.html
index 01c3c7b28e..c1b4c8382b 100644
--- a/client/app/pages/queries/query.html
+++ b/client/app/pages/queries/query.html
@@ -134,21 +134,18 @@
-
-
+
-