diff --git a/app/assets/javascripts/samples/sample_datatable.js b/app/assets/javascripts/samples/sample_datatable.js
index 547469f68..985c3b6c5 100644
--- a/app/assets/javascripts/samples/sample_datatable.js
+++ b/app/assets/javascripts/samples/sample_datatable.js
@@ -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("
Error! " + msg + "
");
-}
-
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/samples/samples.js b/app/assets/javascripts/samples/samples.js
index 973cd15b7..41ab8b6a4 100644
--- a/app/assets/javascripts/samples/samples.js
+++ b/app/assets/javascripts/samples/samples.js
@@ -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 = '' +
+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 = '
' +
'
' +
'' +
- '' +
+ '' +
''+ message +'' +
'
' +
'
';
@@ -159,6 +167,11 @@ function sampleAlertMsg(message) {
$('#content-wrapper').addClass('alert-shown');
}
+function sampleAlertMsgHide() {
+ $('#notifications').html('
');
+ $('#content-wrapper').removeClass('alert-shown');
+}
+
function initTutorial() {
var currentStep = parseInt(Cookies.get('current_tutorial_step'), 10);
if (currentStep == 8)