From c6e500dfa44704568b58d5a867eb51eff91fd4da Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Fri, 30 Aug 2019 10:44:19 -0400 Subject: [PATCH] NIFI-6290: - Ensuring the first allowable value is selected. --- .../webapp/js/jquery/combo/jquery.combo.js | 11 ++++++----- .../canvas/nf-process-group-configuration.js | 19 +++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js index 816a28bc2d..fb825d5bc7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js @@ -135,7 +135,6 @@ // get the combo var combo = $(this); - var firstOption = null; // clear any current contents, remote events, and store options combo.empty().unbind().data('options', options); @@ -187,10 +186,6 @@ // process the options $.each(comboConfigOptions.options, function (i, option) { - if (firstOption === null) { - firstOption = option; - } - var optionText = $('').attr('title', option.text).text(option.text); var optionValue = $('').text(option.value); @@ -282,6 +277,12 @@ // add the drop down arrow $('
').appendTo(combo); + // get the first option + var firstOption = null; + if (options.options.length > 0) { + firstOption = options.options[0]; + } + // set the selection if (isDefinedAndNotNull(options.selectedOption)) { selectOption(combo, options.selectedOption.text, options.selectedOption.value); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js index 9650d32d6c..0dba8df716 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js @@ -372,20 +372,15 @@ } }; - // initialize the parameter context combo - var combo = $('#process-group-parameter-context-combo').combo('destroy').combo(comboOptions); - // populate the parameter context - if (processGroupResult.permissions.canRead) { - var parameterContextId = null; - if ($.isEmptyObject(processGroupResult.component.parameterContext) === false) { - parameterContextId = processGroupResult.component.parameterContext.id; - } - - $('#process-group-parameter-context-combo').combo('setSelectedOption', { - value: parameterContextId - }); + if (processGroupResult.permissions.canRead && $.isEmptyObject(processGroupResult.component.parameterContext) === false) { + comboOptions.selectedOption = { + value: processGroupResult.component.parameterContext.id + }; } + + // initialize the parameter context combo + $('#process-group-parameter-context-combo').combo('destroy').combo(comboOptions); }).fail(nfErrorHandler.handleAjaxError); };