Skip to content

Commit

Permalink
Use normal select tag for most select boxes
Browse files Browse the repository at this point in the history
These selects do not need the select2 features, because the list of
options is small.
  • Loading branch information
tvdeyen committed Sep 29, 2023
1 parent 4873033 commit 81d8d5e
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 25 deletions.
5 changes: 2 additions & 3 deletions app/views/alchemy/admin/ingredients/_file_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<%- if css_classes.present? -%>
<%= f.input :css_class,
collection: css_classes,
include_blank: Alchemy.t('None'),
input_html: {class: 'alchemy_selectbox'} %>
include_blank: Alchemy.t('None') %>
<%- else -%>
<%= f.input :css_class,
label: Alchemy.t(:position_in_text),
collection: [
[Alchemy.t(:above), "no_float"],
[Alchemy.t(:left), "left"],
[Alchemy.t(:right), "right"]
], include_blank: Alchemy.t('Layout default'), input_html: {class: 'alchemy_selectbox'} %>
], include_blank: Alchemy.t('Layout default') %>
<%- end -%>
8 changes: 3 additions & 5 deletions app/views/alchemy/admin/ingredients/_picture_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
collection: [
[Alchemy.t('Layout default'), ""]
] + ingredient.settings[:sizes].to_a,
include_blank: false,
input_html: {class: 'alchemy_selectbox'} %>
include_blank: false %>
<%- end -%>
<%- if ingredient.settings[:css_classes].present? -%>
<%= f.input :css_class,
collection: ingredient.settings[:css_classes],
include_blank: Alchemy.t('None'),
input_html: {class: 'alchemy_selectbox'} %>
include_blank: Alchemy.t('None') %>
<%- else -%>
<%= f.input :css_class,
label: Alchemy.t(:position_in_text),
collection: [
[Alchemy.t(:above), "no_float"],
[Alchemy.t(:left), "left"],
[Alchemy.t(:right), "right"]
], include_blank: Alchemy.t("Layout default"), input_html: {class: 'alchemy_selectbox'} %>
], include_blank: Alchemy.t("Layout default") %>
<%- end -%>
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/ingredients/_video_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
<%= f.input :loop, as: :boolean %>
<%= f.input :muted, as: :boolean %>
<%= f.input :playsinline, as: :boolean %>
<%= f.input :preload, collection: %w(auto none metadata),
include_blank: false, input_html: {class: 'alchemy_selectbox'} %>
<%= f.input :preload, collection: %w(auto none metadata), include_blank: false %>
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/languages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<% if language.errors[:locale].present? || language.locale.present? %>
<%= f.input :locale,
collection: language.matching_locales.presence || ::I18n.available_locales,
selected: language.locale || language.language_code || ::I18n.default_locale.to_s,
input_html: {class: 'alchemy_selectbox'} %>
selected: language.locale || language.language_code || ::I18n.default_locale.to_s %>
<% end %>
<%= f.input :frontpage_name %>
<%= f.input :page_layout,
Expand Down
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/nodes/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<% if node.new_record? && node.root? %>
<%= f.input :menu_type,
collection: Alchemy::Language.current.available_menu_names.map { |n| [I18n.t(n, scope: [:alchemy, :menu_names]), n] },
include_blank: false,
input_html: { class: 'alchemy_selectbox' } %>
include_blank: false %>
<% else %>
<% if node.root? %>
<%= f.input :name %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/_external_link.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</label>
<%= select_tag 'external_link_target',
options_for_select(Alchemy::Page.link_target_options),
class: 'alchemy_selectbox link_target' %>
class: 'link_target' %>
</div>
<div class="submit">
<%= button_tag Alchemy.t(:apply), class: 'create-link button', data: { link_type: 'external' } %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/_file_link.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</label>
<%= select_tag 'file_link_target',
options_for_select(Alchemy::Page.link_target_options),
class: 'alchemy_selectbox link_target' %>
class: 'link_target' %>
</div>
<div class="submit">
<%= button_tag Alchemy.t(:apply), class: 'create-link button', data: { link_type: 'file' } %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/_internal_link.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</label>
<%= select_tag 'internal_link_target',
options_for_select(Alchemy::Page.link_target_options),
class: 'alchemy_selectbox link_target' %>
class: 'link_target' %>
</div>
<div class="submit">
<%= button_tag Alchemy.t(:apply), class: 'create-link button', data: { link_type: 'internal' } %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/alchemy/admin/pages/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@
<label><%= Alchemy.t(:preview_size) %></label>
<%= select_tag 'preview_size',
preview_sizes_for_select,
class: 'alchemy_selectbox medium' %>
class: 'medium' %>
</div>
<div class="toolbar_spacer"></div>
<% if @preview_urls.many? %>
<div class="select_with_label">
<label><%= Alchemy.t(:preview_url) %></label>
<%= select_tag 'preview_url',
options_for_select(@preview_urls),
class: 'alchemy_selectbox large' %>
class: 'large' %>
</div>
<% end %>
<div class="button_with_label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
languages.map { |l| [l.name, l.id] },
Alchemy::Language.current.id
),
class: 'alchemy_selectbox short',
data: {'auto-submit' => true}
) %>
<% end %>
<label><%= Alchemy.t("Language tree") %></label>
<label for="language_id">
<%= Alchemy.t("Language tree") %>
</label>
</div>
<div class="toolbar_spacer"></div>
<% end %>
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/partials/_site_select.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<%- if multi_site? -%>
<div class="button_with_label">
<%= select_tag 'change_site',
options_for_select(sites_for_select, Alchemy::Site.current.id),
class: 'alchemy_selectbox' %>
options_for_select(sites_for_select, Alchemy::Site.current.id) %>
<label><%= Alchemy.t("Current site") %></label>
</div>
<div class="toolbar_spacer"></div>
Expand Down
12 changes: 11 additions & 1 deletion app/views/alchemy/admin/styleguide/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,19 @@
<% end %>

<form class="simple_form alchemy" action="#" accept-charset="UTF-8" method="post">
<div class="input select">
<label class="select control-label" for="select2">Select2</label>
<select class="select alchemy_selectbox" id="select2">
<option value="">Please choose</option>
<option value="1">Option 1</option>
<option selected="selected" value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</div>

<div class="input select">
<label class="select control-label" for="select">Select</label>
<select class="select alchemy_selectbox" id="select">
<select class="select" id="select">
<option value="">Please choose</option>
<option value="1">Option 1</option>
<option selected="selected" value="2">Option 2</option>
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/language_tree_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

it "displays a form for creating language root with preselected page layout and front page name" do
visit("/admin/pages")
select2 "Klingon", from: "Language tree"
select "Klingon", from: "Language tree"
expect(page).to have_content("This language has no homepage yet")

within("form#create_language_tree") do
Expand Down

0 comments on commit 81d8d5e

Please sign in to comment.