Pārlūkot izejas kodu

[oozie] Fix remove kill node

Enrico Berti 11 gadi atpakaļ
vecāks
revīzija
b57c5c73d9

+ 1 - 1
apps/oozie/src/oozie/templates/editor/workflow_editor.mako

@@ -428,7 +428,7 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
   <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="min-height: 40px">
     <div class="big-icon" data-bind="visible: ! $root.isEditing()"><i class="fa fa-magic"></i></div>
     
-    <div data-bind="visible: $root.isEditing">
+    <div data-bind="visible: $root.isEditing" style="padding: 10px">
       <ul data-bind="foreach: children" class="unstyled">
         <li>${ _('To') }
         <select data-bind="options: $root.workflow.nodeIds,

+ 33 - 27
apps/oozie/static/js/workflow-editor.ko.js

@@ -299,46 +299,52 @@ var Workflow = function (vm, workflow) {
 
   self.removeNode = function (node_id) {
     var node = self.getNodeById(node_id);
+
     var parents = self.getParents(node_id);
     var parent = null;
 
     var childLink = node.get_link('to');
-    var childId = ko.mapping.toJS(childLink)['to'];
+    if (childLink) {
+      var childId = ko.mapping.toJS(childLink)['to'];
 
-    $.each(parents, function (index, _parent) {
-      _parent.remove_link('to', node_id);
-      _parent.children.unshift({'to': childId});
-      parent = _parent;
-    });
+      $.each(parents, function (index, _parent) {
+        _parent.remove_link('to', node_id);
+        _parent.children.unshift({'to': childId});
+        parent = _parent;
+      });
 
-    self.nodes.remove(node);
+      self.nodes.remove(node);
 
-    // If need to remove fork
-    if (parent.type() == 'fork-widget') {
-      var fork = parent;
-      var join = self.getNodeById(childId);
+      // If need to remove fork
+      if (parent.type() == 'fork-widget') {
+        var fork = parent;
+        var join = self.getNodeById(childId);
 
-      if (join.type() == 'join-widget') {
-        if (fork.children().length == 2) {
-          // Link top to above and delete fork
-          fork.remove_link('to', childId);
-          var forkParent = self.getParents(fork.id())[0];
-          forkParent.set_link('to', ko.mapping.toJS(fork.get_link('to'))['to']); // Only link
+        if (join.type() == 'join-widget') {
+          if (fork.children().length == 2) {
+            // Link top to above and delete fork
+            fork.remove_link('to', childId);
+            var forkParent = self.getParents(fork.id())[0];
+            forkParent.set_link('to', ko.mapping.toJS(fork.get_link('to'))['to']); // Only link
 
-          self.nodes.remove(fork);
+            self.nodes.remove(fork);
 
-          // Link bottom to child of join
-          var beboreJoin = self.getParents(childId)[0];
-          var joinChildId = ko.mapping.toJS(join.get_link('to'))['to'];
-          beboreJoin.set_link('to', joinChildId);
+            // Link bottom to child of join
+            var beboreJoin = self.getParents(childId)[0];
+            var joinChildId = ko.mapping.toJS(join.get_link('to'))['to'];
+            beboreJoin.set_link('to', joinChildId);
 
-          self.nodes.remove(join);
-        } else {
-          parent.remove_link('to', childId);
+            self.nodes.remove(join);
+          } else {
+            parent.remove_link('to', childId);
+          }
         }
+      } else if (parent.type() == 'decision-widget') {
+        parent.remove_link('to', childId);
       }
-    } else if (parent.type() == 'decision-widget') {
-      parent.remove_link('to', childId);
+    }
+    else {
+      self.nodes.remove(node);
     }
   };