NIFI-6290:

- Ensuring the first allowable value is selected.
This commit is contained in:
Matt Gilman 2019-08-30 10:44:19 -04:00 committed by Scott Aslan
parent f318a8c685
commit c6e500dfa4
2 changed files with 13 additions and 17 deletions

View File

@ -135,7 +135,6 @@
// get the combo // get the combo
var combo = $(this); var combo = $(this);
var firstOption = null;
// clear any current contents, remote events, and store options // clear any current contents, remote events, and store options
combo.empty().unbind().data('options', options); combo.empty().unbind().data('options', options);
@ -187,10 +186,6 @@
// process the options // process the options
$.each(comboConfigOptions.options, function (i, option) { $.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 optionText = $('<span class="combo-option-text"></span>').attr('title', option.text).text(option.text);
var optionValue = $('<span class="hidden"></span>').text(option.value); var optionValue = $('<span class="hidden"></span>').text(option.value);
@ -282,6 +277,12 @@
// add the drop down arrow // add the drop down arrow
$('<div class="combo-arrow fa fa-chevron-down"></div>').appendTo(combo); $('<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 // set the selection
if (isDefinedAndNotNull(options.selectedOption)) { if (isDefinedAndNotNull(options.selectedOption)) {
selectOption(combo, options.selectedOption.text, options.selectedOption.value); selectOption(combo, options.selectedOption.text, options.selectedOption.value);

View File

@ -372,20 +372,15 @@
} }
}; };
// initialize the parameter context combo
var combo = $('#process-group-parameter-context-combo').combo('destroy').combo(comboOptions);
// populate the parameter context // populate the parameter context
if (processGroupResult.permissions.canRead) { if (processGroupResult.permissions.canRead && $.isEmptyObject(processGroupResult.component.parameterContext) === false) {
var parameterContextId = null; comboOptions.selectedOption = {
if ($.isEmptyObject(processGroupResult.component.parameterContext) === false) { value: processGroupResult.component.parameterContext.id
parameterContextId = processGroupResult.component.parameterContext.id; };
} }
$('#process-group-parameter-context-combo').combo('setSelectedOption', { // initialize the parameter context combo
value: parameterContextId $('#process-group-parameter-context-combo').combo('destroy').combo(comboOptions);
});
}
}).fail(nfErrorHandler.handleAjaxError); }).fail(nfErrorHandler.handleAjaxError);
}; };