[#138] simplify saveQuery, drop $route dependency

This commit is contained in:
Amir Nissim
2014-03-24 15:28:05 +02:00
parent 028a3e9d62
commit 5ce4fcb974
2 changed files with 20 additions and 20 deletions

View File

@@ -1,13 +1,13 @@
(function() {
'use strict';
function QueryEditCtrl($controller, $scope, $route, $location, growl, Query, Visualization) {
function QueryEditCtrl($controller, $scope, $location, growl, Query, Visualization) {
// extends QueryViewCtrl
$controller('QueryViewCtrl', {$scope: $scope});
var
_queryText = $scope.query.query,
isNewQuery = !$route.current.locals.query.id;
isNewQuery = !$scope.query.id;
$scope.sourceMode = true;
$scope.isDirty = false;
@@ -36,8 +36,8 @@
if (isNewQuery) {
// save new query when creating a visualization
var unbind = $scope.$watch('selectedTab == "add"', function(newPanel) {
if (newPanel && $route.current.params.queryId == undefined) {
var unbind = $scope.$watch('selectedTab == "add"', function(triggerSave) {
if (triggerSave) {
unbind();
$scope.saveQuery();
}
@@ -47,7 +47,7 @@
};
angular.module('redash.controllers').controller('QueryEditCtrl', [
'$controller', '$scope', '$route', '$location', 'growl', 'Query',
'$controller', '$scope', '$location', 'growl', 'Query',
'Visualization', QueryEditCtrl
]);
})();