diff --git a/app/assets/javascripts/angular/work_packages/view_models/relations-handler.js b/app/assets/javascripts/angular/work_packages/view_models/relations-handler.js index d2ab054877..a039fc1815 100644 --- a/app/assets/javascripts/angular/work_packages/view_models/relations-handler.js +++ b/app/assets/javascripts/angular/work_packages/view_models/relations-handler.js @@ -73,8 +73,11 @@ angular.module('openproject.viewModels') }, removeRelation: function(scope) { + var index = this.relations.indexOf(scope.relation); + var handler = this; + WorkPackageService.removeWorkPackageRelation(scope.relation).then(function(response){ - scope.$emit('workPackageRefreshRequired', ''); + handler.relations.splice(index, 1); }, function(error) { ApiHelper.handleError(scope, error); }); @@ -138,8 +141,11 @@ angular.module('openproject.viewModels') }; handler.getRelatedWorkPackage = function(workPackage, relation) { return relation.fetch() }; handler.removeRelation = function(scope) { + var index = this.relations.indexOf(scope.relation); + var handler = this; + WorkPackageService.updateWorkPackage(scope.relation, {parentId: null}).then(function(response){ - scope.$emit('workPackageRefreshRequired', ''); + handler.relations.splice(index, 1); }, function(error) { ApiHelper.handleError(scope, error); }