Fix an issue with sample editing and type/group dropdowns [SCI-819]

This commit is contained in:
Oleksii Kriuchykhin 2016-12-21 16:41:28 +01:00
parent 2474eac37d
commit e22ff6f8bb
2 changed files with 0 additions and 35 deletions

View file

@ -782,7 +782,6 @@ function createSampleTypeSelect(data, selected) {
.attr('value', val.id).text(val.name);
$selectType.append($option);
});
$selectType.makeDropdownOptionsLinks(selected, 'add-mode');
return $selectType;
}
@ -810,7 +809,6 @@ function createSampleGroupSelect(data, selected) {
$selectGroup.append($option);
});
$selectGroup.makeDropdownOptionsLinks(selected, 'add-mode');
return $selectGroup;
}

View file

@ -215,36 +215,3 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
});
}
}
/**
* Add redirection links on dropdown elements. You must specify 'href'
* attribute yourself, and the dropdown elments which don't have them, will get
* '#' by default.
* @param {number} selectedIdx Index of element to be selected
* @param {string} urlParam URL parameter to pass to the link URLs
* @return {Object} This
*/
$.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) {
selectedIdx = _.isUndefined(selectedIdx) ? -1 : selectedIdx;
$(this).change(function() {
window.location.href = addParam($(this).find('option:selected')
.attr('href'), urlParam);
});
$(this).find('option')
.each(function() {
if ($(this).is('[href]')) {
$(this).addClass('link-look');
} else {
$(this).attr('href', '#');
}
});
var selectedOpt = $(this).find('option[value="' + selectedIdx + '"]');
if (!selectedOpt.length) {
selectedOpt = $(this).find('option').eq(0);
}
selectedOpt.attr('selected', true);
return this;
};