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

Improve account transaction, trade, and valuation editing and sync experience (#1506)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Consolidate entry controller logic

* Transaction builder

* Update trades controller to use new params

* Load account charts in turbo frames, fix PG overflow

* Consolidate tests

* Tests passing

* Remove unused code

* Add client side trade form validations
This commit is contained in:
Zach Gollwitzer 2024-11-27 16:01:50 -05:00 committed by GitHub
parent 76f2714006
commit c3248cd796
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
97 changed files with 1103 additions and 1159 deletions

View file

@ -1,9 +1,12 @@
<%# locals: (entry:) %>
<%= styled_form_with model: [entry.account, entry],
url: entry.new_record? ? account_valuations_path(entry.account) : account_entry_path(entry.account, entry),
class: "space-y-4",
data: { turbo: false } do |form| %>
<%= styled_form_with model: entry, url: account_valuations_path, class: "space-y-4" do |form| %>
<%= form.hidden_field :account_id %>
<% if entry.errors.any? %>
<%= render "shared/form_errors", model: entry %>
<% end %>
<div class="space-y-3">
<%= form.date_field :date, label: true, required: true, value: Date.today, min: Account::Entry.min_supported_date, max: Date.today %>
<%= form.money_field :amount, label: t(".amount"), required: true %>

View file

@ -0,0 +1,19 @@
<%# locals: (entry:) %>
<%= tag.header class: "mb-4 space-y-1", id: dom_id(entry, :header) do %>
<span class="text-gray-500 text-sm">
<%= t(".balance") %>
</span>
<div class="flex items-center gap-4">
<h3 class="font-medium">
<span class="text-2xl">
<%= format_money entry.amount_money %>
</span>
</h3>
</div>
<span class="text-sm text-gray-500">
<%= I18n.l(entry.date, format: :long) %>
</span>
<% end %>

View file

@ -1,4 +1,4 @@
<%# locals: (entry:, selectable: true, show_balance: false, origin: nil) %>
<%# locals: (entry:, selectable: true, show_balance: false) %>
<% account = entry.account %>
<% valuation = entry.account_valuation %>
@ -21,7 +21,7 @@
<%= content_tag :p, entry.name %>
<% else %>
<%= link_to valuation.name,
account_entry_path(account, entry),
account_entry_path(entry),
data: { turbo_frame: "drawer", turbo_prefetch: false },
class: "hover:underline hover:text-gray-800" %>
<% end %>

View file

@ -1,30 +1,14 @@
<% entry, account = @entry, @entry.account %>
<%= drawer do %>
<header class="mb-4 space-y-1">
<span class="text-gray-500 text-sm">
<%= t(".balance") %>
</span>
<div class="flex items-center gap-4">
<h3 class="font-medium">
<span class="text-2xl">
<%= format_money entry.amount_money %>
</span>
</h3>
</div>
<span class="text-sm text-gray-500">
<%= I18n.l(entry.date, format: :long) %>
</span>
</header>
<%= drawer(reload_on_close: true) do %>
<%= render "account/valuations/header", entry: %>
<div class="space-y-2">
<!-- Overview Section -->
<%= disclosure t(".overview") do %>
<div class="pb-4">
<%= styled_form_with model: [account, entry],
url: account_entry_path(account, entry),
<%= styled_form_with model: entry,
url: account_entry_path(entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.text_field :name,
@ -48,8 +32,8 @@
<!-- Details Section -->
<%= disclosure t(".details") do %>
<div class="pb-4">
<%= styled_form_with model: [account, entry],
url: account_entry_path(account, entry),
<%= styled_form_with model: entry,
url: account_entry_path(entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.text_area :notes,
@ -72,7 +56,7 @@
</div>
<%= button_to t(".delete"),
account_entry_path(account, entry),
account_entry_path(entry),
method: :delete,
class: "rounded-lg px-3 py-2 text-red-500 text-sm font-medium border border-alpha-black-200",
data: { turbo_confirm: true, turbo_frame: "_top" } %>