Skip to content

Commit 287cbdc

Browse files
committed
Fix usage of "ui/forms/select" in few components
Following the change in UI select component, forcing `choices` to be an array, needed to change few store credit components passing their options as a string. Also removes blank option for currency selector, since there is a default selected value, and currency cannot be blank, so there is no reason to allow selecting a blank option there.
1 parent 66d7668 commit 287cbdc

File tree

6 files changed

+9
-27
lines changed

6 files changed

+9
-27
lines changed

admin/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<%= render component("ui/forms/field").select(
77
f,
88
:store_credit_reason_id,
9-
store_credit_reasons_select_options.html_safe,
10-
include_blank: t('spree.choose_reason'),
9+
@store_credit_reasons.map { [_1.name, _1.id] },
10+
include_blank: t('.choose_reason'),
1111
html: { required: true }
1212
) %>
1313
</div>

admin/app/components/solidus_admin/users/store_credits/edit_amount/component.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ def form_id
1414
def form_url
1515
solidus_admin.update_amount_user_store_credit_path(@user, @store_credit, **search_filter_params)
1616
end
17-
18-
def store_credit_reasons_select_options
19-
# Placeholder + Store Credit Reasons
20-
"<option value>#{t('.choose_reason')}</option>" + options_from_collection_for_select(@store_credit_reasons, :id, :name)
21-
end
2217
end

admin/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<%= render component("ui/forms/field").select(
66
f,
77
:store_credit_reason_id,
8-
store_credit_reasons_select_options.html_safe,
9-
include_blank: t('spree.choose_reason'),
8+
@store_credit_reasons.map { [_1.name, _1.id] },
9+
include_blank: t('.choose_reason'),
1010
html: { required: true }
1111
) %>
1212
</div>

admin/app/components/solidus_admin/users/store_credits/edit_validity/component.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ def form_id
1414
def form_url
1515
solidus_admin.invalidate_user_store_credit_path(@user, @store_credit, **search_filter_params)
1616
end
17-
18-
def store_credit_reasons_select_options
19-
# Placeholder + Store Credit Reasons
20-
"<option value>#{t('.choose_reason')}</option>" + options_from_collection_for_select(@store_credit_reasons, :id, :name)
21-
end
2217
end

admin/app/components/solidus_admin/users/store_credits/new/component.html.erb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
<%= render component("ui/forms/field").select(
77
f,
88
:currency,
9-
currency_select_options.html_safe,
10-
include_blank: t("spree.currency"),
9+
Spree::Config.available_currencies.map { [_1.iso_code, _1.iso_code] },
10+
placeholder: t("spree.currency"),
11+
value: Spree::Config.currency,
1112
html: { required: true }
1213
) %>
1314
<%= render component("ui/forms/field").select(
1415
f,
1516
:category_id,
16-
store_credit_categories_select_options.html_safe,
17-
include_blank: t("spree.category"),
17+
@store_credit_categories.map { [_1.name, _1.id] },
18+
include_blank: t(".choose_category"),
1819
html: { required: true }
1920
) %>
2021
<%= render component("ui/forms/field").text_field(f, :memo) %>

admin/app/components/solidus_admin/users/store_credits/new/component.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,4 @@ def initialize(user:, store_credit:, categories:)
1010
def form_url
1111
solidus_admin.user_store_credits_path(@user, **search_filter_params)
1212
end
13-
14-
def currency_select_options
15-
options_from_collection_for_select(Spree::Config.available_currencies, :iso_code, :iso_code, Spree::Config.currency)
16-
end
17-
18-
def store_credit_categories_select_options
19-
# Placeholder + Store Credit Categories
20-
"<option value>#{t('.choose_category')}</option>" + options_from_collection_for_select(@store_credit_categories, :id, :name)
21-
end
2213
end

0 commit comments

Comments
 (0)