mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
[#138] update queryText when query is saved
This commit is contained in:
@@ -6,14 +6,12 @@
|
||||
$controller('QueryViewCtrl', {$scope: $scope});
|
||||
|
||||
var
|
||||
_queryText = $scope.query.query,
|
||||
isNewQuery = !$scope.query.id,
|
||||
shortcuts = {
|
||||
'meta+s': $scope.saveQuery
|
||||
};
|
||||
|
||||
$scope.sourceMode = true;
|
||||
$scope.isDirty = false;
|
||||
$scope.canEdit = currentUser.canEdit($scope.query);
|
||||
|
||||
$scope.newVisualization = undefined;
|
||||
@@ -35,10 +33,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('query.query', function(newQueryText) {
|
||||
$scope.isDirty = (newQueryText !== _queryText);
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function destroy() {
|
||||
KeyboardShortcuts.unbind(shortcuts);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
'use strict';
|
||||
|
||||
function QueryViewCtrl($scope, $route, $location, notifications, growl, Query, DataSource) {
|
||||
var DEFAULT_TAB = 'table';
|
||||
var
|
||||
DEFAULT_TAB = 'table',
|
||||
queryText;
|
||||
|
||||
$scope.isDirty = false;
|
||||
|
||||
$scope.query = $route.current.locals.query;
|
||||
$scope.queryResult = $scope.query.getQueryResult();
|
||||
@@ -15,6 +19,8 @@
|
||||
$scope.query.data_source_id = $scope.query.data_source_id || dataSources[0].id;
|
||||
});
|
||||
|
||||
queryText = $scope.query.query;
|
||||
|
||||
$scope.lockButton = function(lock) {
|
||||
$scope.queryExecuting = lock;
|
||||
};
|
||||
@@ -33,6 +39,7 @@
|
||||
delete $scope.query.latest_query_data;
|
||||
|
||||
$scope.query.$save(function(savedQuery) {
|
||||
queryText = savedQuery.query;
|
||||
$scope.isDirty = false;
|
||||
|
||||
if (oldId != savedQuery.id) {
|
||||
@@ -73,6 +80,14 @@
|
||||
$scope.executeQuery();
|
||||
};
|
||||
|
||||
$scope.$watch('query.query', function(newQueryText) {
|
||||
$scope.isDirty = (newQueryText !== queryText);
|
||||
});
|
||||
|
||||
$scope.$watch('query.name', function() {
|
||||
$scope.$parent.pageTitle = $scope.query.name;
|
||||
});
|
||||
|
||||
$scope.$watch('queryResult && queryResult.getError()',
|
||||
function(newError, oldError) {
|
||||
if (newError == undefined) {
|
||||
@@ -128,10 +143,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('query.name', function() {
|
||||
$scope.$parent.pageTitle = $scope.query.name;
|
||||
});
|
||||
|
||||
$scope.$watch(function() {
|
||||
return $location.hash()
|
||||
}, function(hash) {
|
||||
|
||||
Reference in New Issue
Block a user