Skip to content

Commit c174c95

Browse files
committed
Improve forms using slim-select for more select fields
1 parent a9038d3 commit c174c95

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

app/views/better_together/communities/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
<div class="mb-3">
107107
<%= form.label :role_id, "Select Role *", class: "form-label" %>
108-
<%= form.collection_select :role_id, ::BetterTogether::Role.where(resource_type: @resource.class.to_s), :id, :name, { prompt: "Select a role" }, { class: "form-select", required: true } %>
108+
<%= form.collection_select :role_id, ::BetterTogether::Role.where(resource_type: @resource.class.to_s), :id, :name, { prompt: "Select a role" }, { class: "form-select", required: true, data: { controller: 'better_together--slim-select' } } %>
109109
</div>
110110
<div class="mb-3">
111111
<%= form.submit "Add", class: "btn btn-primary" %>

app/views/better_together/content/blocks/fields/_hero.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="mb-3 row row-cols-1 row-cols-sm-2">
1616
<div class="align-self-end mb-3">
1717
<%= label_tag "#{scope}[cta_button_style]", block.class.human_attribute_name('cta_button_style'), class: 'form-label' %>
18-
<%= select_tag "#{scope}[cta_button_style]", options_for_select(block.class::AVAILABLE_BTN_CLASSES.map {|k, v| [t("better_together.content.blocks.hero.cta_button_styles.#{k}"), v]}, block.cta_button_style), class: 'form-select' %>
18+
<%= select_tag "#{scope}[cta_button_style]", options_for_select(block.class::AVAILABLE_BTN_CLASSES.map {|k, v| [t("better_together.content.blocks.hero.cta_button_styles.#{k}"), v]}, block.cta_button_style), { class: 'form-select', data: { controller: 'better_together--slim-select' } } %>
1919
</div>
2020

2121
<div class="cta-url-field align-self-end mb-3">

app/views/better_together/content/blocks/fields/_template.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<%- scope = local_assigns[:scope] ? local_assigns[:scope] : BetterTogether::Content::Block.block_name %>
33
<div class="template-fields">
44
<%= required_label block, :template_path %>
5-
<%= select_tag "#{scope}[template_path]", options_for_select(block.class::available_templates.map { |path| [ I18n.t(path.tr('/', '.')), path] }, block.template_path), class: 'form-select' %>
5+
<%= select_tag "#{scope}[template_path]", options_for_select(block.class::available_templates.map { |path| [ I18n.t(path.tr('/', '.')), path] }, block.template_path), { class: 'form-select', data: { controller: 'better_together--slim-select' } } %>
66
</div>

app/views/better_together/content/blocks/fields/shared/_style.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="mb-3 row row-cols-1 row-cols-sm-2">
1414
<div class="mb-3">
1515
<%= label_tag "#{scope}[container_class]", "Container Class" %>
16-
<%= select_tag "#{scope}[container_class]", options_for_select(block.class::VALID_CONTAINER_CLASSES, block.container_class), include_blank: true, class: "form-select" %>
16+
<%= select_tag "#{scope}[container_class]", options_for_select(block.class::VALID_CONTAINER_CLASSES, block.container_class), { include_blank: true, class: "form-select", data: { controller: 'better_together--slim-select' } } %>
1717
</div>
1818

1919
<div class="mb-3">

app/views/better_together/navigation_items/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<div class="mb-3">
4444
<%= form.label :item_type %>
45-
<%= form.select :item_type, options_for_select(['link', 'dropdown', 'separator'], @navigation_item.item_type), { include_blank: true }, { class: 'form-select' + (@navigation_item.errors[:item_type].any? ? ' is-invalid' : '') } %>
45+
<%= form.select :item_type, options_for_select(['link', 'dropdown', 'separator'], @navigation_item.item_type), { include_blank: true }, { class: 'form-select' + (@navigation_item.errors[:item_type].any? ? ' is-invalid' : ''), data: { controller: 'better_together--slim-select' } } %>
4646
<% if @navigation_item.errors[:item_type].any? %>
4747
<div class="invalid-feedback">
4848
<%= @navigation_item.errors[:item_type].join(", ") %>

app/views/better_together/pages/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
<div class="col mb-3 pb-3 border-bottom">
8080
<%= form.label :layout %>
81-
<%= form.select :layout, options_for_select(::BetterTogether::Page::PAGE_LAYOUTS, page.layout), {}, { class: "form-select#{' is-invalid' if page.errors[:layout].any?}" } %>
81+
<%= form.select :layout, options_for_select(::BetterTogether::Page::PAGE_LAYOUTS, page.layout), {}, { class: "form-select#{' is-invalid' if page.errors[:layout].any?}", data: { controller: 'better_together--slim-select' } } %>
8282
<% if page.errors[:layout].any? %>
8383
<div class="invalid-feedback">
8484
<%= page.errors[:layout].join(", ") %>

app/views/better_together/platforms/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@
154154
<div class="row mt-3">
155155
<div class="mb-3 pb-3 col-md-6 border-bottom">
156156
<%= form.label :community_role_id, "Select Community Role *", class: "form-label" %>
157-
<%= form.collection_select :community_role_id, ::BetterTogether::Role.where(resource_type: "BetterTogether::Community").positioned, :id, :name, { prompt: "Select a platform community role" }, { class: "form-select", required: true } %>
157+
<%= form.collection_select :community_role_id, ::BetterTogether::Role.where(resource_type: "BetterTogether::Community").positioned, :id, :name, { prompt: "Select a platform community role" }, { class: "form-select", required: true, data: { controller: 'better_together--slim-select' } } %>
158158
</div>
159159

160160
<div class="mb-3 pb-3 col-md-6 border-bottom">
161161
<%= form.label :platform_role_id, "Select Platform Role", class: "form-label" %>
162-
<%= form.collection_select :platform_role_id, ::BetterTogether::Role.where(resource_type: "BetterTogether::Platform").positioned, :id, :name, { prompt: "Select a platform role" }, { class: "form-select", title: 'Platform Role' } %>
162+
<%= form.collection_select :platform_role_id, ::BetterTogether::Role.where(resource_type: "BetterTogether::Platform").positioned, :id, :name, { prompt: "Select a platform role" }, { class: "form-select", title: 'Platform Role', data: { controller: 'better_together--slim-select' } } %>
163163
</div>
164164
</div>
165165
</div>

app/views/better_together/social_media_accounts/_social_media_account_fields.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<%= form.hidden_field :_destroy %>
55
<div class="col-md-3">
66
<%= required_label form, :platform, class: "form-label" %>
7-
<%= form.select :platform, BetterTogether::SocialMediaAccount::PLATFORMS.map { |p| [p, p] }, { prompt: t('better_together.select'), required: true }, class: 'form-select' %>
7+
<%= form.select :platform, BetterTogether::SocialMediaAccount::PLATFORMS.map { |p| [p, p] }, { prompt: t('better_together.select'), required: true }, { class: 'form-select', data: { controller: 'better_together--slim-select' } } %>
88
</div>
99
<div class="col-md-3 mt-3 mt-md-0">
1010
<%= required_label form, :privacy, class: "form-label" %>

0 commit comments

Comments
 (0)