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

Always show headline level #2825

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions app/views/alchemy/ingredients/_headline_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@
<%= render "alchemy/ingredients/shared/anchor", ingredient_editor: headline_editor %>
<% end %>

<% if has_level_select %>
<div class="input-addon right<%= " second" if has_size_select %>">
<div class="input-addon right<%= " second" if has_size_select %>">
<sl-tooltip content="<%= f.object.class.human_attribute_name(:level) %>">
<%= f.select :level,
options_for_select(headline_editor.level_options, headline_editor.level),
{},
{ class: "custom-select", title: f.object.class.human_attribute_name(:level) } %>
</div>
<% end %>
{
class: "custom-select",
disabled: !has_level_select
} %>
</sl-tooltip>
</div>

<% if has_size_select %>
<div class="input-addon right">
<%= f.select :size, options_for_select(headline_editor.size_options, headline_editor.size),
{},
{ class: "custom-select", title: f.object.class.human_attribute_name(:size) } %>
<sl-tooltip content="<%= f.object.class.human_attribute_name(:size) %>">
<%= f.select :size, options_for_select(headline_editor.size_options, headline_editor.size),
{},
{ class: "custom-select" } %>
</sl-tooltip>
</div>
<% end %>
<% end %>
Expand Down
12 changes: 10 additions & 2 deletions spec/views/alchemy/ingredients/headline_editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@
is_expected.to have_selector("select[name='element[ingredients_attributes][0][level]']")
end

it "renders a tooltip" do
is_expected.to have_selector("sl-tooltip[content='Level']")
end

context "when only one level is given" do
let(:settings) do
{levels: [1]}
end

it "does not render a level select" do
is_expected.to_not have_selector("select[name='element[ingredients_attributes][0][level]']")
it "renders a disabled level select" do
is_expected.to have_selector("select[disabled][name='element[ingredients_attributes][0][level]']")
end
end

Expand All @@ -60,6 +64,10 @@
it "renders a size select" do
is_expected.to have_selector("select[name='element[ingredients_attributes][0][size]']")
end

it "renders a tooltip" do
is_expected.to have_selector("sl-tooltip[content='Size']")
end
end

context "with settings anchor set to true" do
Expand Down