mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-10 17:03:56 +08:00
fixes notification disappearance and error notifications
This commit is contained in:
parent
a35bf7182f
commit
1b1e6daa21
2 changed files with 25 additions and 17 deletions
|
@ -336,7 +336,7 @@ function onClickEdit() {
|
|||
},
|
||||
error: function (e, data, status, xhr) {
|
||||
if (e.status == 403) {
|
||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
||||
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||
changeToViewMode();
|
||||
updateButtons();
|
||||
}
|
||||
|
@ -398,20 +398,21 @@ function onClickSave() {
|
|||
dataType: "json",
|
||||
data: data,
|
||||
success: function (data) {
|
||||
sampleAlertMsg(data.flash);
|
||||
sampleAlertMsg(data.flash, "success");
|
||||
onClickCancel();
|
||||
},
|
||||
error: function (e, eData, status, xhr) {
|
||||
var data = e.responseJSON;
|
||||
clearAllErrors();
|
||||
sampleAlertMsgHide();
|
||||
|
||||
if (e.status == 404) {
|
||||
showAlertMessage(I18n.t("samples.js.not_found_error"));
|
||||
sampleAlertMsg(I18n.t("samples.js.not_found_error"), "danger");
|
||||
changeToViewMode();
|
||||
updateButtons();
|
||||
}
|
||||
else if (e.status == 403) {
|
||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
||||
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||
changeToViewMode();
|
||||
updateButtons();
|
||||
}
|
||||
|
@ -611,7 +612,7 @@ function onClickAddSample() {
|
|||
},
|
||||
error: function (e, eData, status, xhr) {
|
||||
if (e.status == 403)
|
||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
||||
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||
changeToViewMode();
|
||||
updateButtons();
|
||||
}
|
||||
|
@ -705,10 +706,4 @@ function changeToEditMode() {
|
|||
|
||||
// Table specific stuff
|
||||
table.button(0).enable(false);
|
||||
}
|
||||
|
||||
// Shows alert and changes
|
||||
function showAlertMessage(msg) {
|
||||
$("#alert-container").append("<div class='alert alert-danger'> <strong>Error!</strong> " + msg + "</div>");
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ $("#modal-create-sample-type").on("shown.bs.modal", function(event) {
|
|||
$("form#new_sample_type").on("ajax:success", function(ev, data, status) {
|
||||
$("#modal-create-sample-type").modal("hide");
|
||||
updateSamplesTypesandGroups();
|
||||
sampleAlertMsg(data.flash);
|
||||
sampleAlertMsg(data.flash, "success");
|
||||
currentMode = "viewMode";
|
||||
updateButtons();
|
||||
});
|
||||
|
@ -76,7 +76,7 @@ $("#modal-create-sample-group").on("shown.bs.modal", function(event) {
|
|||
$("form#new_sample_group").on("ajax:success", function(ev, data, status) {
|
||||
$("#modal-create-sample-group").modal("hide");
|
||||
updateSamplesTypesandGroups();
|
||||
sampleAlertMsg(data.flash);
|
||||
sampleAlertMsg(data.flash, "success");
|
||||
currentMode = "viewMode";
|
||||
updateButtons();
|
||||
});
|
||||
|
@ -147,11 +147,19 @@ function updateSamplesTypesandGroups() {
|
|||
});
|
||||
}
|
||||
|
||||
function sampleAlertMsg(message) {
|
||||
var html_snippet = '<div class="alert alert-success alert-dismissable alert-floating">' +
|
||||
function sampleAlertMsg(message, type) {
|
||||
var alert_type, glyph_sign;
|
||||
if (type == "success") {
|
||||
alert_type = " alert-success ";
|
||||
glyph_sign = " glyphicon-ok-sign ";
|
||||
} else if (type == "danger") {
|
||||
alert_type = " alert-danger ";
|
||||
glyph_sign = " glyphicon-exclamation-sign ";
|
||||
}
|
||||
var html_snippet = '<div class="alert' + alert_type + 'alert-dismissable alert-floating">' +
|
||||
'<div class="container">' +
|
||||
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
|
||||
'<span class="glyphicon glyphicon-ok-sign"></span>' +
|
||||
'<span class="glyphicon' + glyph_sign + '"></span>' +
|
||||
'<span>'+ message +'</span>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
@ -159,6 +167,11 @@ function sampleAlertMsg(message) {
|
|||
$('#content-wrapper').addClass('alert-shown');
|
||||
}
|
||||
|
||||
function sampleAlertMsgHide() {
|
||||
$('#notifications').html('<div></div>');
|
||||
$('#content-wrapper').removeClass('alert-shown');
|
||||
}
|
||||
|
||||
function initTutorial() {
|
||||
var currentStep = parseInt(Cookies.get('current_tutorial_step'), 10);
|
||||
if (currentStep == 8)
|
||||
|
|
Loading…
Reference in a new issue