From 2bcb56d2490d25f79cfe30f55c13d540d2f87911 Mon Sep 17 00:00:00 2001 From: Christopher Valles Date: Mon, 3 Mar 2014 16:41:53 +0000 Subject: [PATCH] Fixing PR #112 as discussed with Arik --- rd_ui/app/scripts/controllers.js | 7 +++++++ rd_ui/app/scripts/directives.js | 24 +----------------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/rd_ui/app/scripts/controllers.js b/rd_ui/app/scripts/controllers.js index 46eaa2e8..ac990516 100644 --- a/rd_ui/app/scripts/controllers.js +++ b/rd_ui/app/scripts/controllers.js @@ -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) { diff --git a/rd_ui/app/scripts/directives.js b/rd_ui/app/scripts/directives.js index 17156b2e..da8b387e 100644 --- a/rd_ui/app/scripts/directives.js +++ b/rd_ui/app/scripts/directives.js @@ -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");