1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-06 14:05:20 +02:00

Add default currencies to forms based on preference (#994)

* Add default currencies to forms based on preference

* Remove dev debugging
This commit is contained in:
Zach Gollwitzer 2024-07-17 08:57:17 -04:00 committed by GitHub
parent e51806b98b
commit e9f42c1a65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 35 additions and 20 deletions

View file

@ -1,16 +1,19 @@
<%# locals: (form:, money_method:, default_currency: "USD", disable_currency: false, hide_currency: false, label: nil) %>
<%# locals: (form:, money_method:, default_currency:, disable_currency: false, hide_currency: false, label: nil) %>
<% fallback_label = t(".money-label") %>
<% currency = form.object.send(money_method)&.currency || Money::Currency.new(default_currency) %>
<div class="form-field pr-0" data-controller="money-field">
<%= form.label label || fallback_label, { class: "form-field__label" } %>
<div class="flex items-center gap-1">
<div class="flex items-center grow gap-1">
<span class="text-gray-500 text-sm" data-money-field-target="symbol">$</span>
<%= money_field form, money_method, { inline: true, "data-money-field-target" => "amount", default_currency: default_currency } %>
<span class="text-gray-500 text-sm" data-money-field-target="symbol"><%= currency.symbol %></span>
<%= money_field form, money_method, { inline: true, "data-money-field-target" => "amount", default_currency: currency } %>
</div>
<% unless hide_currency %>
<div>
<%= currency_select form, :currency, { inline: true }, {
<%= currency_select form, :currency, { inline: true, selected: currency.iso_code }, {
class: "form-field__input text-right pr-8 disabled:text-gray-500",
disabled: disable_currency,
data: {