mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
fixes notifications when creating sample types and groups
This commit is contained in:
parent
58930f3456
commit
5695842fe3
|
@ -45,6 +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);
|
||||
});
|
||||
|
||||
$("form#new_sample_type").on("ajax:error", function(e, data, status, xhr) {
|
||||
|
@ -73,6 +74,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);
|
||||
});
|
||||
|
||||
$("form#new_sample_group").on("ajax:error", function(e, data, status, xhr) {
|
||||
|
@ -141,6 +143,17 @@ function updateSamplesTypesandGroups() {
|
|||
});
|
||||
}
|
||||
|
||||
function sampleAlertMsg(message) {
|
||||
var html_snippet = '<div class="alert alert-success alert-dismissable samples-flash-alert ">' +
|
||||
'<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>'+ message +'</span>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
$('#notifications').html(html_snippet);
|
||||
}
|
||||
|
||||
function initTutorial() {
|
||||
var currentStep = parseInt(Cookies.get('current_tutorial_step'), 10);
|
||||
if (currentStep == 8)
|
||||
|
|
|
@ -16,4 +16,10 @@
|
|||
.alert {
|
||||
position: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
.samples-flash-alert {
|
||||
position: relative;
|
||||
top: 50px;
|
||||
z-index: 1000;
|
||||
}
|
|
@ -19,7 +19,12 @@ class SampleGroupsController < ApplicationController
|
|||
if @sample_group.save
|
||||
format.json {
|
||||
render json: {
|
||||
id: @sample_group.id
|
||||
id: @sample_group.id,
|
||||
flash: t(
|
||||
"sample_groups.create.success_flash",
|
||||
sample_group: @sample_group.name,
|
||||
organization: @organization.name
|
||||
)
|
||||
},
|
||||
status: :ok
|
||||
}
|
||||
|
|
|
@ -17,14 +17,19 @@ class SampleTypesController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @sample_type.save
|
||||
flash[:success] = t(
|
||||
"sample_types.create.success_flash",
|
||||
sample_type: @sample_type.name,
|
||||
organization: @organization.name
|
||||
)
|
||||
# flash[:success] = t(
|
||||
# "sample_types.create.success_flash",
|
||||
# sample_type: @sample_type.name,
|
||||
# organization: @organization.name
|
||||
# )
|
||||
format.json {
|
||||
render json: {
|
||||
id: @sample_type.id
|
||||
id: @sample_type.id,
|
||||
flash: t(
|
||||
"sample_types.create.success_flash",
|
||||
sample_type: @sample_type.name,
|
||||
organization: @organization.name
|
||||
)
|
||||
},
|
||||
status: :ok
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue