Skip to content

Commit

Permalink
Fix humanization for add nested element button
Browse files Browse the repository at this point in the history
Converting `nestable_element` to a symbol allows us to humanize the nestable element name.

(cherry picked from commit 1281ae7)

# Conflicts:
#	app/views/alchemy/admin/elements/_add_nested_element_form.html.erb
  • Loading branch information
nsaloj committed Dec 28, 2023
1 parent b5e18b4 commit ff1c391
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= content_tag :div, class: 'add-nested-element', data: { element_id: element.id } do %>
<% if element.expanded? || element.fixed? %>
<% if element.nestable_elements.length == 1 &&
(nestable_element = element.nestable_elements.first) &&
<% if element.nestable_elements.length == 1 &&
(nestable_element = element.nestable_elements.first) &&
Alchemy::Element.all_from_clipboard_for_parent_element(get_clipboard("elements"), element).none?
%>
<%= form_for [:admin, Alchemy::Element.new(name: nestable_element)],
Expand All @@ -14,7 +14,7 @@
</button>
<% end %>
<% else %>
<%= link_to_dialog (nestable_element ? Alchemy.t(:add_nested_element, name: Alchemy.t(nestable_element, scope: 'element_names')) : Alchemy.t("New Element")),
<%= link_to_dialog (nestable_element ? Alchemy.t(:add_nested_element, name: Alchemy.t(nestable_element.to_sym, scope: 'element_names')) : Alchemy.t("New Element")),
alchemy.new_admin_element_path(
parent_element_id: element.id,
page_version_id: element.page_version_id
Expand All @@ -24,4 +24,4 @@
}, class: "button add-nestable-element-button" %>
<% end %>
<% end %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions spec/features/admin/edit_elements_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
scenario "the add button opens add element form with the clipboard tab" do
visit alchemy.admin_elements_path(page_version_id: element.page_version_id)
button = page.find(".add-nestable-element-button")
expect(button).to have_content "Add slide"
expect(button).to have_content "Add Slide"
button.click
expect(page).to have_select("Element")
expect(page).to have_link("Paste from clipboard")
Expand All @@ -76,7 +76,7 @@
scenario "the add element button immediately creates the nested element." do
visit alchemy.admin_elements_path(page_version_id: element.page_version_id)
button = page.find("button.add-nestable-element-button")
expect(button).to have_content "Add slide"
expect(button).to have_content "Add Slide"
button.click
expect(page).to have_selector(".element-editor[data-element-name='slide']")
end
Expand Down

0 comments on commit ff1c391

Please sign in to comment.