mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-14 10:53:01 +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) {
|
error: function (e, data, status, xhr) {
|
||||||
if (e.status == 403) {
|
if (e.status == 403) {
|
||||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||||
changeToViewMode();
|
changeToViewMode();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
@ -398,20 +398,21 @@ function onClickSave() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: data,
|
data: data,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
sampleAlertMsg(data.flash);
|
sampleAlertMsg(data.flash, "success");
|
||||||
onClickCancel();
|
onClickCancel();
|
||||||
},
|
},
|
||||||
error: function (e, eData, status, xhr) {
|
error: function (e, eData, status, xhr) {
|
||||||
var data = e.responseJSON;
|
var data = e.responseJSON;
|
||||||
clearAllErrors();
|
clearAllErrors();
|
||||||
|
sampleAlertMsgHide();
|
||||||
|
|
||||||
if (e.status == 404) {
|
if (e.status == 404) {
|
||||||
showAlertMessage(I18n.t("samples.js.not_found_error"));
|
sampleAlertMsg(I18n.t("samples.js.not_found_error"), "danger");
|
||||||
changeToViewMode();
|
changeToViewMode();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
else if (e.status == 403) {
|
else if (e.status == 403) {
|
||||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||||
changeToViewMode();
|
changeToViewMode();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
@ -611,7 +612,7 @@ function onClickAddSample() {
|
||||||
},
|
},
|
||||||
error: function (e, eData, status, xhr) {
|
error: function (e, eData, status, xhr) {
|
||||||
if (e.status == 403)
|
if (e.status == 403)
|
||||||
showAlertMessage(I18n.t("samples.js.permission_error"));
|
sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
|
||||||
changeToViewMode();
|
changeToViewMode();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
@ -706,9 +707,3 @@ function changeToEditMode() {
|
||||||
// Table specific stuff
|
// Table specific stuff
|
||||||
table.button(0).enable(false);
|
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) {
|
$("form#new_sample_type").on("ajax:success", function(ev, data, status) {
|
||||||
$("#modal-create-sample-type").modal("hide");
|
$("#modal-create-sample-type").modal("hide");
|
||||||
updateSamplesTypesandGroups();
|
updateSamplesTypesandGroups();
|
||||||
sampleAlertMsg(data.flash);
|
sampleAlertMsg(data.flash, "success");
|
||||||
currentMode = "viewMode";
|
currentMode = "viewMode";
|
||||||
updateButtons();
|
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) {
|
$("form#new_sample_group").on("ajax:success", function(ev, data, status) {
|
||||||
$("#modal-create-sample-group").modal("hide");
|
$("#modal-create-sample-group").modal("hide");
|
||||||
updateSamplesTypesandGroups();
|
updateSamplesTypesandGroups();
|
||||||
sampleAlertMsg(data.flash);
|
sampleAlertMsg(data.flash, "success");
|
||||||
currentMode = "viewMode";
|
currentMode = "viewMode";
|
||||||
updateButtons();
|
updateButtons();
|
||||||
});
|
});
|
||||||
|
@ -147,11 +147,19 @@ function updateSamplesTypesandGroups() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleAlertMsg(message) {
|
function sampleAlertMsg(message, type) {
|
||||||
var html_snippet = '<div class="alert alert-success alert-dismissable alert-floating">' +
|
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">' +
|
'<div class="container">' +
|
||||||
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
|
'<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>' +
|
'<span>'+ message +'</span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
@ -159,6 +167,11 @@ function sampleAlertMsg(message) {
|
||||||
$('#content-wrapper').addClass('alert-shown');
|
$('#content-wrapper').addClass('alert-shown');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sampleAlertMsgHide() {
|
||||||
|
$('#notifications').html('<div></div>');
|
||||||
|
$('#content-wrapper').removeClass('alert-shown');
|
||||||
|
}
|
||||||
|
|
||||||
function initTutorial() {
|
function initTutorial() {
|
||||||
var currentStep = parseInt(Cookies.get('current_tutorial_step'), 10);
|
var currentStep = parseInt(Cookies.get('current_tutorial_step'), 10);
|
||||||
if (currentStep == 8)
|
if (currentStep == 8)
|
||||||
|
|
Loading…
Reference in a new issue