diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8b4dcfa9a..4e9702628 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -138,11 +138,7 @@ $(document.body).ready(function () { }); }; - $("#notifications .alert").on("closed.bs.alert", function () { - $("#content-wrapper") - .addClass("alert-hidden") - .removeClass("alert-shown"); - }); + notificationAlertClose(); $('#main-menu .btn-activity') .on('ajax:before', function () { @@ -158,6 +154,18 @@ $(document.body).ready(function () { }); }); +$(document).ajaxComplete(function(){ + notificationAlertClose(); +}); + +function notificationAlertClose(){ + $("#notifications .alert").on("closed.bs.alert", function () { + $("#content-wrapper") + .addClass("alert-hidden") + .removeClass("alert-shown"); + }); +} + /* * Truncate long strings where is necessary */ diff --git a/app/assets/javascripts/samples/samples.js b/app/assets/javascripts/samples/samples.js index 0b547bf9c..9c6b82a37 100644 --- a/app/assets/javascripts/samples/samples.js +++ b/app/assets/javascripts/samples/samples.js @@ -45,6 +45,9 @@ $("#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); + currentMode = "viewMode"; + updateButtons(); }); $("form#new_sample_type").on("ajax:error", function(e, data, status, xhr) { @@ -73,6 +76,9 @@ $("#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); + currentMode = "viewMode"; + updateButtons(); }); $("form#new_sample_group").on("ajax:error", function(e, data, status, xhr) { @@ -141,6 +147,18 @@ function updateSamplesTypesandGroups() { }); } +function sampleAlertMsg(message) { + var html_snippet = '