Просмотр исходного кода

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 лет назад
Родитель
Сommit
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(),
         "uuid": self.properties.workflow(),
       }, function (data) {
       }, function (data) {
         self.workflowParameters(data.parameters);
         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) {
         $.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.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) {
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);
         $(document).trigger("error", xhr.responseText);