mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-11 01:14:30 +08:00
At importing large sample file, error flash message appears [fixes SCI-903] (#625)
* At importing large sample file, error flash message appears [fixes SCI-903] * Changing double quotes to single * Adding animatedSpinner
This commit is contained in:
parent
31e41fd8ae
commit
1abaefce4f
1 changed files with 21 additions and 12 deletions
|
@ -1,41 +1,50 @@
|
||||||
var previousIndex;
|
var previousIndex;
|
||||||
var disabledOptions;
|
var disabledOptions;
|
||||||
$("select").focus(function() {
|
var loadingSamples = false;
|
||||||
|
$('select').focus(function() {
|
||||||
previousIndex = $(this)[0].selectedIndex;
|
previousIndex = $(this)[0].selectedIndex;
|
||||||
}).change(function () {
|
}).change(function() {
|
||||||
var currSelect = $(this);
|
var currSelect = $(this);
|
||||||
var currIndex = $(currSelect)[0].selectedIndex;
|
var currIndex = $(currSelect)[0].selectedIndex;
|
||||||
|
|
||||||
$("select").each(function() {
|
$('select').each(function() {
|
||||||
if (currSelect !== $(this) && currIndex > 0) {
|
if (currSelect !== $(this) && currIndex > 0) {
|
||||||
$(this).children().eq(currIndex).attr("disabled", "disabled");
|
$(this).children().eq(currIndex).attr('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).children().eq(previousIndex).removeAttr("disabled");
|
$(this).children().eq(previousIndex).removeAttr('disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
previousIndex = currIndex;
|
previousIndex = currIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create import samples ajax
|
// Create import samples ajax
|
||||||
$("form#form-import")
|
$('form#form-import')
|
||||||
.submit(function(e) {
|
.submit(function(e) {
|
||||||
|
// Check if we already uploading samples
|
||||||
|
if (loadingSamples) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
disabledOptions = $("option[disabled='disabled']");
|
disabledOptions = $("option[disabled='disabled']");
|
||||||
disabledOptions.removeAttr("disabled");
|
disabledOptions.removeAttr('disabled');
|
||||||
|
loadingSamples = true;
|
||||||
|
animateSpinner();
|
||||||
})
|
})
|
||||||
.on("ajax:success", function(ev, data, status) {
|
.on('ajax:success', function(ev, data, status) {
|
||||||
// Simply reload page to show flash and updated samples list
|
// Simply reload page to show flash and updated samples list
|
||||||
|
loadingSamples = false;
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
})
|
||||||
.on("ajax:error", function(ev, data, status) {
|
.on('ajax:error', function(ev, data, status) {
|
||||||
|
loadingSamples = false;
|
||||||
if (_.isUndefined(data.responseJSON.html)) {
|
if (_.isUndefined(data.responseJSON.html)) {
|
||||||
// Simply reload page to show flash
|
// Simply reload page to show flash
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
// Re-disable options
|
// Re-disable options
|
||||||
disabledOptions.attr("disabled", "disabled");
|
disabledOptions.attr('disabled', 'disabled');
|
||||||
|
|
||||||
// Populate the errors container
|
// Populate the errors container
|
||||||
$("#import-errors-container").html(data.responseJSON.html);
|
$('#import-errors-container').html(data.responseJSON.html);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue