fixes notification when adding new sample

This commit is contained in:
Mojca Lorber 2016-08-29 13:45:54 +02:00
parent 25928bfa0b
commit 53cdbc2638
3 changed files with 24 additions and 3 deletions

View file

@ -398,6 +398,7 @@ function onClickSave() {
dataType: "json",
data: data,
success: function (data) {
sampleAlertMsg(data.flash);
onClickCancel();
},
error: function (e, eData, status, xhr) {

View file

@ -80,7 +80,17 @@ class SamplesController < ApplicationController
errors.delete_if { |k, v| v.blank? }
if errors.empty?
format.json { render json: {}, status: :ok }
format.json {
render json: {
id: sample.id,
flash: t(
'samples.create.success_flash',
sample: sample.name,
organization: @organization.name
)
},
status: :ok
}
else
format.json { render json: errors, status: :bad_request }
end
@ -227,7 +237,17 @@ class SamplesController < ApplicationController
# Now we can destroy empty scfs
scf_to_delete.map(&:destroy)
format.json { render json: {}, status: :ok }
format.json {
render json: {
id: sample.id,
flash: t(
'samples.update.success_flash',
sample: sample.name,
organization: @organization.name
)
},
status: :ok
}
else
format.json { render json: errors, status: :bad_request }
end

View file

@ -909,7 +909,7 @@ en:
create: "Edit sample"
scf_does_not_exist: "This field does not exists."
create:
success_flash: "Successfully added sample to team <strong>%{organization}</strong>"
success_flash: "Successfully added sample <strong>%{sample}</strong> to team <strong>%{organization}</strong>"
update:
success_flash: "Successfully updated sample <strong>%{sample}</strong> to team <strong>%{organization}</strong>"
destroy: