Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-50776] Gives priority to items exactly matching default value.
  • Loading branch information
BeChris committed Apr 12, 2018
1 parent 6526640 commit c26d869
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -73,16 +73,25 @@ var GitParameter = GitParameter || (function($) {
else if (selectedValue == 'DEFAULT' && !isEmpty(_self.getDefaultValue())) {
var defaultValue = _self.getDefaultValue();
console.log("Search default value : " + defaultValue);

var foundExactMatch = false;

for (var i = 0; i < optionsLength; i++ ) {
if (filteredElement.options[i].value == defaultValue) {
filteredElement.options[i].selected = true;
console.log("Found an exact match");
foundExactMatch = true;
break;
}
}
for (var i = 0; i < optionsLength; i++ ) {
if (filteredElement.options[i].value.indexOf(defaultValue) > -1) {
filteredElement.options[i].selected = true;
break;

if (!foundExactMatch) {
for (var i = 0; i < optionsLength; i++ ) {
if (filteredElement.options[i].value.indexOf(defaultValue) > -1) {
filteredElement.options[i].selected = true;
console.log("Found an approximate match : " + filteredElement.options[i].value);
break;
}
}
}
}
Expand Down

0 comments on commit c26d869

Please sign in to comment.