mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 11:34:13 +00:00
* Initial implementation * Tiingo fixes * Adds 2 providers, remove 2 * Add extra checks * FIX a big hotwire race condition // Fix hotwire_combobox race condition: when typing quickly, a slow response for // an early query (e.g. "A") can overwrite the correct results for the final query // (e.g. "AAPL"). We abort the previous in-flight request whenever a new one fires, // so stale Turbo Stream responses never reach the DOM. * pipelock * Update price_test.rb * Reviews * i8n * fixes * fixes * Update tiingo.rb * fixes * Improvements * Big revamp * optimisations * Update 20260408151837_add_offline_reason_to_securities.rb * Add missing tests, fixes * small rank tests * FIX tests * Update show.html.erb * Update resolver.rb * Update usd_converter.rb * Update holdings_controller.rb * Update holdings_controller.rb * Update holdings_controller.rb * Update holdings_controller.rb * Update holdings_controller.rb * Update _yahoo_finance_settings.html.erb
93 lines
4.0 KiB
Plaintext
93 lines
4.0 KiB
Plaintext
<%# locals: (form:, amount_method:, currency_method:, **options) %>
|
|
|
|
<% currency_value = if options[:currency_value_override].present?
|
|
options[:currency_value_override]
|
|
elsif form.object && form.object.respond_to?(currency_method)
|
|
form.object.public_send(currency_method)
|
|
end
|
|
currency = Money::Currency.new(currency_value || options[:default_currency] || "USD") %>
|
|
|
|
<div class="form-field <%= options[:container_class] %>"
|
|
data-controller="money-field"
|
|
<% if options[:precision].present? %> data-money-field-precision-value="<%= options[:precision] %>"<% end %>
|
|
<% if options[:step].present? %> data-money-field-step-value="<%= options[:step] %>"<% end %>>
|
|
<% if options[:label_tooltip] %>
|
|
<div class="form-field__header">
|
|
<%= form.label options[:label] || t(".label"), class: "form-field__label" do %>
|
|
<%= options[:label] || t(".label") %>
|
|
<% if options[:required] %>
|
|
<span class="text-red-500 ml-0.5">*</span>
|
|
<% end %>
|
|
<% end %>
|
|
<div class="form-field__actions">
|
|
<div data-controller="tooltip">
|
|
<%= icon "help-circle", size: "sm", color: "default", class: "cursor-help" %>
|
|
<div role="tooltip" data-tooltip-target="tooltip" class="tooltip bg-gray-700 text-sm p-2 rounded w-64 text-white">
|
|
<%= options[:label_tooltip] %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="form-field__body">
|
|
<% unless options[:label_tooltip] %>
|
|
<%= form.label options[:label] || t(".label"), class: "form-field__label" do %>
|
|
<%= options[:label] || t(".label") %>
|
|
<% if options[:required] %>
|
|
<span class="text-red-500 ml-0.5">*</span>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<div class="flex items-center gap-1">
|
|
<div class="flex items-center grow gap-1">
|
|
<span class="text-subdued text-sm" data-money-field-target="symbol">
|
|
<%= currency.symbol %>
|
|
</span>
|
|
|
|
<%= form.number_field amount_method,
|
|
class: "form-field__input",
|
|
inline: true,
|
|
placeholder: "100",
|
|
value: if options[:value]
|
|
sprintf("%.#{options[:precision].presence || currency.default_precision}f", options[:value])
|
|
elsif form.object && form.object.respond_to?(amount_method)
|
|
val = form.object.public_send(amount_method)
|
|
sprintf("%.#{options[:precision].presence || currency.default_precision}f", val) if val.present?
|
|
end,
|
|
min: options[:min] || -99999999999999,
|
|
max: options[:max] || 99999999999999,
|
|
step: options[:step] || currency.step,
|
|
disabled: options[:disabled],
|
|
data: (options[:amount_data] || {}).merge({
|
|
"money-field-target": "amount",
|
|
"auto-submit-form-target": ("auto" if options[:auto_submit])
|
|
}.compact),
|
|
required: options[:required] %>
|
|
</div>
|
|
|
|
<% unless options[:hide_currency] %>
|
|
<div>
|
|
<% currency_data = (options[:currency_data] || {}).merge({
|
|
"money-field-target": "currency",
|
|
"auto-submit-form-target": ("auto" if options[:auto_submit])
|
|
}.compact)
|
|
# Preserve any existing action and append money-field handler
|
|
existing_action = currency_data.delete("action")
|
|
currency_data["action"] = ["change->money-field#handleCurrencyChange", existing_action].compact.join(" ")
|
|
%>
|
|
<%= form.select currency_method,
|
|
Money::Currency.as_options.map(&:iso_code),
|
|
{ inline: true, selected: currency.iso_code },
|
|
{
|
|
class: "w-fit pr-5 disabled:text-subdued form-field__input",
|
|
disabled: options[:disable_currency],
|
|
data: currency_data
|
|
} %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|