Skip to content

Commit

Permalink
Merge pull request #6388 from himdel/bz1769968-dialog-editor-id
Browse files Browse the repository at this point in the history
Dialog Editor, ExplorerPresenter - make sure all ids are strings in javascript

(cherry picked from commit 747eb57)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1772932
  • Loading branch information
martinpovolny authored and simaishi committed Nov 15, 2019
1 parent 1e88eef commit ecde4ce
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/infra_networking_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def replace_right_cell(options = {})
partial_locals = {:controller =>'infra_networking'}
if partial == 'layouts/x_gtl'
partial_locals[:action_url] = @lastaction
presenter[:parent_id] = @record.id.to_s # Set parent rec id for JS function miqGridSort to build URL
presenter[:parent_id] = @record.id # Set parent rec id for JS function miqGridSort to build URL
presenter[:parent_class] = params[:controller] # Set parent class for URL also
end
presenter.update(:main_div, r[:partial => partial, :locals => partial_locals])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ def replace_right_cell(options = {})
partial_locals[:action_url] = @lastaction

# Set parent record id & class for JS function miqGridSort to build URL
presenter[:parent_id] = @record.id.to_s
presenter[:parent_id] = @record.id
presenter[:parent_class] = params[:controller]
end
presenter.update(:main_div, r[:partial => partial, :locals => partial_locals])
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/miq_ae_customization_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module MiqAeCustomizationHelper
def dialog_id_action
url = request.parameters
if url[:id].present?
{:id => @record.id, :action => 'edit'}
{:id => @record.id.to_s, :action => 'edit'}
elsif url[:copy].present?
{:id => url[:copy], :action => 'copy'}
else
Expand Down
5 changes: 3 additions & 2 deletions app/presenters/explorer_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,11 @@ def for_render_default
toolbar
end

# ids are nil or string
data[:record] = {
:parentId => @options[:parent_id],
:parentId => @options[:parent_id]&.to_s,
:parentClass => @options[:parent_class],
:recordId => @options[:record_id],
:recordId => @options[:record_id]&.to_s,
}

unless @options[:osf_node].blank?
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/explorer_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
end

context "#[:record_id]" do
it 'sets :record object' do
it 'sets :record object, ensuring string id' do
@presenter[:record_id] = 666
expect(subject[:record][:recordId]).to eq(666)
expect(subject[:record][:recordId]).to eq("666")
end
end

Expand Down

0 comments on commit ecde4ce

Please sign in to comment.