Files
ubicloud/views/components/form/country_select.erb
Enes Cakir be56a9139f Fix arguments for UI components
Some arguments for UI components are optional, so we don't have to
provide all of them when using them. I had added a `defined?(name)`
check to use default values when an argument is not provided.

Jeremy pointed out that it was working by accident. In the code `name =
defined?(name)`, `defined?(name)` always returns `local-variable`
because it’s on the right-hand side of the assignment, while the local
variable is on the left-hand side.

When we remove the `defined?` calls, the remaining code is equivalent to
`||=`.
2024-11-12 10:24:27 +03:00

25 lines
555 B
Plaintext

<% name ||= "country"
label ||= "Country"
selected = flash.dig("old", name) || selected
description ||= nil
attributes ||= {} %>
<%== render(
"components/form/select",
locals: {
name: name,
label: label,
selected: selected,
placeholder: "Select a Country",
options:
ISO3166::Country
.all
.reject { Config.sanctioned_countries.include?(_1.alpha2) }
.sort_by(&:common_name)
.map { |c| [c.alpha2, c.common_name] }
.to_h,
description: description,
attributes: attributes
}
) %>