Fix issue with adjunct deletion from overflow menu

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/89399d99
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/89399d99
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/89399d99

Branch: refs/heads/master
Commit: 89399d99736173f6efd514c97a5f299364895daa
Parents: 3c1ab28
Author: Thomas Bouron <[email protected]>
Authored: Wed Oct 10 15:34:10 2018 +0100
Committer: Thomas Bouron <[email protected]>
Committed: Thu Oct 11 15:13:56 2018 +0100

----------------------------------------------------------------------
 .../spec-editor/spec-editor.directive.js        | 20 ++++++++++++++++----
 .../spec-editor/spec-editor.template.html       |  2 +-
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/89399d99/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
----------------------------------------------------------------------
diff --git 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
index 03adce1..76bdfa7 100644
--- 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
+++ 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
@@ -27,13 +27,14 @@ import {RESERVED_KEYS, DSL_ENTITY_SPEC} from 
'../providers/blueprint-service.pro
 import brooklynDslEditor from '../dsl-editor/dsl-editor';
 import brooklynDslViewer from '../dsl-viewer/dsl-viewer';
 import template from './spec-editor.template.html';
+import {graphicalState} from '../../views/main/graphical/graphical.state';
 
 const MODULE_NAME = 'brooklyn.components.spec-editor';
 const ANY_MEMBERSPEC_REGEX = /(^.*[m,M]ember[s,S]pec$)/;
 const REPLACED_DSL_ENTITYSPEC = '___brooklyn:entitySpec';
 
 angular.module(MODULE_NAME, [onEnter, autoGrow, blurOnEnter, 
brooklynDslEditor, brooklynDslViewer])
-    .directive('specEditor', ['$rootScope', '$templateCache', '$injector', 
'$sanitize', '$filter', '$log', '$sce', '$timeout', '$document', 
'blueprintService', specEditorDirective])
+    .directive('specEditor', ['$rootScope', '$templateCache', '$injector', 
'$sanitize', '$filter', '$log', '$sce', '$timeout', '$document', '$state', 
'blueprintService', specEditorDirective])
     .filter('specEditorConfig', specEditorConfigFilter)
     .filter('specEditorType', specEditorTypeFilter);
 
@@ -71,7 +72,7 @@ export const CONFIG_FILTERS = [
     }
 ];
 
-export function specEditorDirective($rootScope, $templateCache, $injector, 
$sanitize, $filter, $log, $sce, $timeout, $document, blueprintService) {
+export function specEditorDirective($rootScope, $templateCache, $injector, 
$sanitize, $filter, $log, $sce, $timeout, $document, $state, blueprintService) {
     return {
         restrict: 'E',
         scope: {
@@ -332,8 +333,19 @@ export function specEditorDirective($rootScope, 
$templateCache, $injector, $sani
             }
         };
 
-        scope.removeEntity = ()=> {
-            $rootScope.$broadcast('d3.remove', scope.model);
+        scope.removeModel = ()=> {
+            switch (scope.model.family) {
+                case EntityFamily.ENRICHER:
+                    scope.model.parent.removeEnricher(scope.model._id);
+                    break;
+                case EntityFamily.POLICY:
+                    scope.model.parent.removePolicy(scope.model._id);
+                    break;
+                default:
+                    $rootScope.$broadcast('d3.remove', scope.model);
+                    break;
+            }
+            $state.go(graphicalState.name);
         };
 
         scope.getConfigIssues = specEditor.getConfigIssues = ()=> {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/89399d99/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
----------------------------------------------------------------------
diff --git 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
index 713da93..2eda1d6 100644
--- 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
+++ 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
@@ -29,7 +29,7 @@
             <ul class="dropdown-menu" uib-dropdown-menu role="menu" 
aria-labelledby="spec-actions">
                 <li role="menuitem"><a 
ng-href="/brooklyn-ui-catalog/#!/bundles/{{model.miscData.get('bundle').symbolicName}}/{{model.miscData.get('bundle').version}}/types/{{model.type}}/{{model.version
 || 'latest'}}" target="_blank">Open in Catalog</a></li>
                 <li role="separator" class="divider"></li>
-                <li role="menuitem"><a href ng-click="removeEntity()"><span 
class="text-danger">Delete</span></a></li>
+                <li role="menuitem"><a href ng-click="removeModel()"><span 
class="text-danger">Delete</span></a></li>
             </ul>
         </div>
     </div>

Reply via email to