소스 검색

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 9 년 전
부모
커밋
18cfde780b
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);