Skip to content

Commit

Permalink
Toggle for query editor autocomplete (re getredash#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short committed Jan 9, 2018
1 parent 5e79808 commit 7404019
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/app/components/queries/query-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function queryEditor(QuerySnippet) {
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) {
if (tokensCount > 5000 || !$scope.$parent.editorAutocomplete) {
editor.setOption('enableLiveAutocompletion', false);
editor.setOption('enableBasicAutocompletion', false);
} else {
Expand All @@ -132,6 +132,10 @@ function queryEditor(QuerySnippet) {
$scope.$parent.$on('angular-resizable.resizing', () => {
editor.resize();
});
$scope.$parent.$watch('editorAutocomplete', () => {
editor.setOption('enableLiveAutocompletion', $scope.$parent.editorAutocomplete);
editor.setOption('enableBasicAutocompletion', $scope.$parent.editorAutocomplete);
});

editor.focus();
},
Expand Down
4 changes: 4 additions & 0 deletions client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ <h3>
<span ng-if="dataSource.options.doc_url == '' || !dataSource.options.doc_url">{{ dataSource.type_name }} documentation</span>
<get-data-source-version id='data-source-version'></get-data-source-version>

<input type="checkbox" ng-model="editorAutocomplete">
Enable Autocomplete
</button>

<div class="pull-right">
<button class="btn btn-s btn-default" ng-click="togglePublished()" ng-if="query.is_draft && query.id != undefined && (isQueryOwner || currentUser.hasPermission('admin'))">
<span class="fa fa-paper-plane"></span> Publish
Expand Down
2 changes: 2 additions & 0 deletions client/app/pages/queries/source-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function QuerySourceCtrl(
.catch(error => toastr.error(error));
};

$scope.editorAutocomplete = true;

$scope.duplicateQuery = () => {
Query.fork({ id: $scope.query.id }, (newQuery) => {
$location.url(newQuery.getSourceLink()).replace();
Expand Down

0 comments on commit 7404019

Please sign in to comment.