mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 06:04:35 +08:00
fixes notifications when creating sample types and groups
This commit is contained in:
parent
58930f3456
commit
5695842fe3
4 changed files with 36 additions and 7 deletions
|
@ -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) {
|
$("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);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("form#new_sample_type").on("ajax:error", function(e, data, status, xhr) {
|
$("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) {
|
$("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);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("form#new_sample_group").on("ajax:error", function(e, data, status, xhr) {
|
$("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() {
|
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)
|
||||||
|
|
|
@ -16,4 +16,10 @@
|
||||||
.alert {
|
.alert {
|
||||||
position: inherit !important;
|
position: inherit !important;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.samples-flash-alert {
|
||||||
|
position: relative;
|
||||||
|
top: 50px;
|
||||||
|
z-index: 1000;
|
||||||
}
|
}
|
|
@ -19,7 +19,12 @@ class SampleGroupsController < ApplicationController
|
||||||
if @sample_group.save
|
if @sample_group.save
|
||||||
format.json {
|
format.json {
|
||||||
render 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
|
status: :ok
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,19 @@ class SampleTypesController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @sample_type.save
|
if @sample_type.save
|
||||||
flash[:success] = t(
|
# flash[:success] = t(
|
||||||
"sample_types.create.success_flash",
|
# "sample_types.create.success_flash",
|
||||||
sample_type: @sample_type.name,
|
# sample_type: @sample_type.name,
|
||||||
organization: @organization.name
|
# organization: @organization.name
|
||||||
)
|
# )
|
||||||
format.json {
|
format.json {
|
||||||
render 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
|
status: :ok
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue