From 0d7d34c059ce21b9e3a82a7580992b4b5eaf845f Mon Sep 17 00:00:00 2001 From: kunw Date: Wed, 29 Jun 2016 20:48:45 +0800 Subject: [PATCH] update for updating policies when existing target. --- .../replication/create-policy.directive.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/static/resources/js/components/replication/create-policy.directive.js b/static/resources/js/components/replication/create-policy.directive.js index 304ccdfd4..c7c7efdda 100644 --- a/static/resources/js/components/replication/create-policy.directive.js +++ b/static/resources/js/components/replication/create-policy.directive.js @@ -69,7 +69,7 @@ $scope.$watch('vm.targetId', function(current) { if(current) { - vm1.selection.id = current; + vm1.selection.id = current || vm.destinations[0].id; } }); @@ -125,15 +125,19 @@ function saveOrUpdateDestination() { var target = { + 'name' : vm1.name, 'endpoint': vm1.endpoint, 'username': vm1.username, 'password': vm1.password }; - if(vm.checkedAddTarget) { - target.name = vm1.name; + + if(vm.checkedAddTarget){ CreateDestinationService(target.name, target.endpoint, target.username, target.password) .success(createDestinationSuccess) .error(createDestinationFailed); + }else{ + vm.policy.targetId = vm1.selection.id; + saveOrUpdatePolicy(); } } @@ -154,7 +158,10 @@ function update(policy) { vm.policy = policy; - saveOrUpdateDestination(); + if(vm.targetEditable) { + vm.policy.targetId = vm1.selection.id; + saveOrUpdatePolicy(); + } } function pingDestination() {