Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display error message correctly that is returned from model. #1115

Merged
merged 2 commits into from Apr 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions app/controllers/catalog_controller.rb
Expand Up @@ -268,9 +268,11 @@ def st_delete
if params[:id]
elements.push(params[:id])
process_sts(elements, 'destroy') unless elements.empty?
add_flash(_("The selected %{record} was deleted") %
{:record => ui_lookup(:table => "service_template")}) if @flash_array.nil?
self.x_node = "root"
if @flash_array.nil?
add_flash(_("The selected %{record} was deleted") %
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this has been there before, but for the sake of translators and nicer translations, we'd like
to get rid of calling ui_lookup() on a static string. So I'd suggest to change the above string to:
"The selected Catalog Item was deleted"

{:record => ui_lookup(:table => "service_template")})
self.x_node = "root"
end
else # showing 1 element, delete it
elements = find_checked_ids_with_rbac(ServiceTemplate)
if elements.empty?
Expand Down Expand Up @@ -632,7 +634,13 @@ def process_sts(sts, task, _display_name = nil)
add_flash(_("%{model} \"%{name}\": Error during '%{task}': %{error_message}") %
{:model => model_name, :name => st_name, :task => task, :error_message => bang.message}, :error)
else
AuditEvent.success(audit)
if st.errors
st.errors.each do |field, msg|
add_flash("#{field.to_s.capitalize} #{msg}", :error)
end
else
AuditEvent.success(audit)
end
end
end
end
Expand Down