Skip to content

Commit

Permalink
Fix dom ids of ingredient editors
Browse files Browse the repository at this point in the history
These editors need a unique dom id to work correctly
with their js events.
  • Loading branch information
tvdeyen committed Aug 10, 2021
1 parent ed79a28 commit 593e24e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/views/alchemy/ingredients/_file_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
},
title: Alchemy.t(:edit_file_properties) %>
</div>
<%= f.hidden_field :attachment_id, value: file_editor.attachment&.id %>
<%= f.hidden_field :attachment_id,
value: file_editor.attachment&.id,
id: file_editor.form_field_id(:attachment_id) %>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/alchemy/ingredients/_link_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= f.text_field :value,
class: "thin_border text_with_icon disabled",
name: nil,
id: nil,
id: link_editor.form_field_id,
disabled: true
%>
<%= f.hidden_field :value, "data-link-value": true %>
Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/ingredients/_node_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= ingredient_label(node_editor, :node_id) %>
<%= f.text_field :node_id,
value: node_editor.node&.id,
id: node_editor.form_field_id(:node_id),
class: 'alchemy_selectbox full_width' %>
<% end %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/ingredients/_page_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= ingredient_label(page_editor, :page_id) %>
<%= f.text_field :page_id,
value: page_editor.page&.id,
id: page_editor.form_field_id(:page_id),
class: 'alchemy_selectbox full_width' %>
<% end %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/ingredients/_picture_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</div>
<% end %>
<%= f.hidden_field :picture_id, value: picture_editor.picture&.id,
id: picture_editor.form_field_id(:picture_id),
data: {
picture_id: true,
image_file_width: picture_editor.image_file_width,
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/alchemy/admin/ingredients_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
subject { helper.ingredient_label(ingredient_editor) }

it "has for attribute set to ingredient form field id" do
is_expected.to have_selector('label[for="element_ingredients_attributes_0_value"]')
is_expected.to have_selector("label[for='element_#{element.id}_ingredient_#{ingredient.id}_value']")
end

context "with another column given" do
subject { helper.ingredient_label(ingredient_editor, :picture_id) }

it "has for attribute set to ingredient form field id for that column" do
is_expected.to have_selector('label[for="element_ingredients_attributes_0_picture_id"]')
is_expected.to have_selector("label[for='element_#{element.id}_ingredient_#{ingredient.id}_picture_id']")
end
end

Expand Down

0 comments on commit 593e24e

Please sign in to comment.