浏览代码

HUE-3161 [oozie] Fix automatic workflow parameter population in Coordinator editor

Note: Earlier we just updated previous params and if the new Workflow has less params
we just left the extra params for the user to delete it.
Now, we delete unused old params and add whatever is new.
krish 10 年之前
父节点
当前提交
18cfde7
共有 1 个文件被更改,包括 13 次插入3 次删除
  1. 13 3
      apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

+ 13 - 3
apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

@@ -82,12 +82,22 @@ var Coordinator = function (vm, coordinator) {
         "uuid": self.properties.workflow(),
       }, function (data) {
         self.workflowParameters(data.parameters);
-        // Pre-add the variables
+
+        // Remove Uncommon params
+        prev_variables = self.variables.slice();
+        $.each(prev_variables, function (index, variable) {
+          if (data.parameters.filter(function(param) { return param['name'] == variable.workflow_variable() }).length == 0) {
+            self.variables.remove(variable);
+          }
+        });
+
+        // Append the new variables
+        prev_variables = self.variables.slice();
         $.each(data.parameters, function (index, param) {
-          if (self.variables().length < data.parameters.length) {
+          if (prev_variables.filter(function(variable) { return param['name'] == variable.workflow_variable() }).length == 0) {
             self.addVariable();
+            self.variables()[self.variables().length - 1].workflow_variable(param['name']);
           }
-          self.variables()[self.variables().length - 1].workflow_variable(param['name']);
         });
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);