Skip to content

Commit

Permalink
Merge pull request #2924 from martinpovolny/flash_messages_session
Browse files Browse the repository at this point in the history
Provider forms: pass flash messages throught the session rather than url
(cherry picked from commit a3831c9)

https://bugzilla.redhat.com/show_bug.cgi?id=1520669
  • Loading branch information
himdel authored and simaishi committed Dec 4, 2017
1 parent 341d665 commit 9be2979
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def update
def update_ems_button_cancel
update_ems = find_record_with_rbac(model, params[:id])
model_name = model.to_s
flash_msg = _("Edit of %{model} \"%{name}\" was cancelled by the user") %
{:model => ui_lookup(:model => model_name),
:name => update_ems.name}
add_flash(
_("Edit of %{model} \"%{name}\" was cancelled by the user") % {:model => ui_lookup(:model => model_name), :name => update_ems.name}
)
session[:flash_msgs] = @flash_array.dup
js_args = {:action => @lastaction == 'show_dashboard' ? 'show' : @lastaction,
:id => update_ems.id,
:display => session[:ems_display],
:flash_msg => flash_msg,
:record => update_ems}
javascript_redirect(javascript_process_redirect_args(js_args))
end
Expand All @@ -36,19 +36,16 @@ def update_ems_button_save
set_ems_record_vars(update_ems)
if update_ems.save
update_ems.reload
flash = _("%{model} \"%{name}\" was saved") %
{:model => ui_lookup(:model => model.to_s),
:name => update_ems.name}
add_flash(
_("%{model} \"%{name}\" was saved") % {:model => ui_lookup(:model => model.to_s), :name => update_ems.name}
)
construct_edit_for_audit(update_ems)
AuditEvent.success(build_saved_audit(update_ems, @edit))
update_ems.authentication_check_types_queue(update_ems.authentication_for_summary.pluck(:authtype),
:save => true)
ems_path = if @lastaction == 'show_list'
ems_path('show_list', :flash_msg => flash)
else
ems_path(update_ems, :flash_msg => flash)
end
javascript_redirect ems_path

session[:flash_msgs] = @flash_array.dup
javascript_redirect(@lastaction == 'show_list' ? ems_path('show_list') : ems_path(update_ems))
else
update_ems.errors.each do |field, msg|
add_flash("#{field.to_s.capitalize} #{msg}", :error)
Expand Down Expand Up @@ -171,10 +168,9 @@ def create_ems_button_add
if ems.valid? && ems.save
construct_edit_for_audit(ems)
AuditEvent.success(build_created_audit(ems, @edit))
flash_msg = _("%{model} \"%{name}\" was saved") % {:model => ui_lookup(:tables => table_name),
:name => ems.name}
javascript_redirect :action => 'show_list',
:flash_msg => flash_msg
add_flash(_("%{model} \"%{name}\" was saved") % {:model => ui_lookup(:tables => table_name), :name => ems.name})
session[:flash_msgs] = @flash_array.dup
javascript_redirect(:action => 'show_list')
else
@in_a_form = true
ems.errors.each do |field, msg|
Expand All @@ -189,10 +185,10 @@ def create_ems_button_add

def create_ems_button_cancel
model_name = model.to_s
javascript_redirect :action => @lastaction,
:display => session[:ems_display],
:flash_msg => _("Add of %{model} was cancelled by the user") %
{:model => ui_lookup(:model => model_name)}
add_flash(_("Add of %{model} was cancelled by the user") % {:model => ui_lookup(:model => model_name)})
session[:flash_msgs] = @flash_array.dup
javascript_redirect(:action => @lastaction,
:display => session[:ems_display])
end

def ems_form_fields
Expand Down

0 comments on commit 9be2979

Please sign in to comment.