Skip to content

Commit

Permalink
Merge pull request #2825 from tvdeyen/always-show-headline-level
Browse files Browse the repository at this point in the history
Always show headline level
  • Loading branch information
tvdeyen authored Apr 10, 2024
2 parents e2f9520 + a6e6675 commit 0c76560
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
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

0 comments on commit 0c76560

Please sign in to comment.