2016-02-12 23:52:43 +08:00
|
|
|
var previousIndex;
|
|
|
|
var disabledOptions;
|
|
|
|
$("select").focus(function() {
|
|
|
|
previousIndex = $(this)[0].selectedIndex;
|
|
|
|
}).change(function () {
|
|
|
|
var currSelect = $(this);
|
|
|
|
var currIndex = $(currSelect)[0].selectedIndex;
|
|
|
|
|
|
|
|
$("select").each(function() {
|
|
|
|
if (currSelect !== $(this) && currIndex > 0) {
|
|
|
|
$(this).children().eq(currIndex).attr("disabled", "disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).children().eq(previousIndex).removeAttr("disabled");
|
|
|
|
});
|
|
|
|
|
|
|
|
previousIndex = currIndex;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create import samples ajax
|
|
|
|
$("form#form-import")
|
|
|
|
.submit(function(e) {
|
|
|
|
disabledOptions = $("option[disabled='disabled']");
|
|
|
|
disabledOptions.removeAttr("disabled");
|
|
|
|
})
|
|
|
|
.on("ajax:success", function(ev, data, status) {
|
|
|
|
// Simply reload page to show flash and updated samples list
|
|
|
|
location.reload();
|
|
|
|
})
|
|
|
|
.on("ajax:error", function(ev, data, status) {
|
|
|
|
if (_.isUndefined(data.responseJSON.html)) {
|
|
|
|
// Simply reload page to show flash
|
|
|
|
location.reload();
|
|
|
|
} else {
|
|
|
|
// Re-disable options
|
|
|
|
disabledOptions.attr("disabled", "disabled");
|
|
|
|
|
|
|
|
// Populate the errors container
|
|
|
|
$("#import-errors-container").html(data.responseJSON.html);
|
|
|
|
}
|
2016-10-13 16:00:36 +08:00
|
|
|
});
|