You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sc...@apache.org on 2019/08/30 17:54:15 UTC

[nifi] 08/09: NIFI-6290: - Ensuring the first allowable value is selected.

This is an automated email from the ASF dual-hosted git repository.

scottyaslan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit c6e500dfa44704568b58d5a867eb51eff91fd4da
Author: Matt Gilman <ma...@gmail.com>
AuthorDate: Fri Aug 30 10:44:19 2019 -0400

    NIFI-6290:
    - Ensuring the first allowable value is selected.
---
 .../src/main/webapp/js/jquery/combo/jquery.combo.js   | 11 ++++++-----
 .../js/nf/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 816a28b..fb825d5 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 = $('<span class="combo-option-text"></span>').attr('title', option.text).text(option.text);
                             var optionValue = $('<span class="hidden"></span>').text(option.value);
 
@@ -282,6 +277,12 @@
                     // add the drop down arrow
                     $('<div class="combo-arrow fa fa-chevron-down"></div>').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 9650d32..0dba8df 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);
     };