Fixing PR #112 as discussed with Arik

This commit is contained in:
Christopher Valles 2014-03-03 16:41:53 +00:00
parent 3c24e76eb4
commit 2bcb56d249
2 changed files with 8 additions and 23 deletions

View File

@ -282,6 +282,13 @@
});
}
};
unbind = $scope.$watch('selectedTab == "add"', function(newPanel) {
if (newPanel && $routeParams.queryId == undefined) {
unbind();
$scope.saveQuery();
}
});
}
var QueriesCtrl = function($scope, $http, $location, $filter, Query) {

View File

@ -46,7 +46,7 @@
}
}]);
directives.directive('editVisulatizationForm', ['Visualization', 'growl', '$location', function(Visualization, growl, $location) {
directives.directive('editVisulatizationForm', ['Visualization', 'growl', function(Visualization, growl) {
return {
restrict: 'E',
templateUrl: '/views/edit_visualization.html',
@ -142,28 +142,6 @@
};
scope.submit = function() {
if (!scope.query.id) {
scope.$parent.saveQuery(false, null, false);
var unwatch = scope.$watch('query', function(q) {
if (q && q.id) {
unwatch();
scope.vis['query_id'] = q.id;
scope.saveVisualization(false);
$location.path($location.path().replace('new', q.id)).replace();
}
}, true);
} else {
scope.saveVisualization();
}
};
scope.saveVisualization = function(updateTabs) {
if (updateTabs == undefined) {
updateTabs = true;
}
Visualization.save(scope.vis, function success(result) {
growl.addSuccessMessage("Visualization saved");