The personal finance app for everyone
Fix transaction form account pre-filling and form styles
Zach Gollwitzer752835f49224
diff --git a/app/assets/tailwind/maybe-design-system.css b/app/assets/tailwind/maybe-design-system.cssindex 4649a6bc..e03ccb1b 100644--- a/app/assets/tailwind/maybe-design-system.css+++ b/app/assets/tailwind/maybe-design-system.css@@ -330,7 +330,7 @@}.form-field__input {- @apply border-none bg-transparent text-sm opacity-100 w-full p-0;+ @apply text-primary border-none bg-transparent text-sm opacity-100 w-full p-0;@apply focus:opacity-100 focus:outline-hidden focus:ring-0;@apply placeholder-shown:opacity-50;@apply disabled:text-subdued;diff --git a/app/views/shared/_transaction_type_tabs.html.erb b/app/views/shared/_transaction_type_tabs.html.erbindex c2b53b2f..b2cfe0fd 100644--- a/app/views/shared/_transaction_type_tabs.html.erb+++ b/app/views/shared/_transaction_type_tabs.html.erb@@ -1,23 +1,23 @@-<fieldset class="bg-gray-50 rounded-lg p-1 grid grid-flow-col justify-stretch gap-x-2">- <% active_tab = local_assigns[:active_tab] || "expense" %>+<%# locals: (active_tab:, account_id: nil) %>- <%= link_to new_transaction_path(nature: "outflow"),+<fieldset class="bg-surface-inset rounded-lg p-1 grid grid-flow-col justify-stretch gap-x-2">+ <%= link_to new_transaction_path(nature: "outflow", account_id: account_id),data: { turbo_frame: :modal },- class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'expense' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>+ class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm #{active_tab == 'expense' ? 'bg-container text-primary shadow-sm' : 'hover:bg-container text-subdued hover:text-primary hover:shadow-sm'}" do %><%= icon "minus-circle" %><%= tag.span t("shared.transaction_tabs.expense") %><% end %>- <%= link_to new_transaction_path(nature: "inflow"),+ <%= link_to new_transaction_path(nature: "inflow", account_id: account_id),data: { turbo_frame: :modal },- class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'income' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>+ class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm #{active_tab == 'income' ? 'bg-container text-primary shadow-sm' : 'hover:bg-container text-subdued hover:text-primary hover:shadow-sm'}" do %><%= icon "plus-circle" %><%= tag.span t("shared.transaction_tabs.income") %><% end %><%= link_to new_transfer_path,data: { turbo_frame: :modal },- class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'transfer' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>+ class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm #{active_tab == 'transfer' ? 'bg-container text-primary shadow-sm' : 'hover:bg-container text-subdued hover:text-primary hover:shadow-sm'}" do %><%= icon "arrow-right-left" %><%= tag.span t("shared.transaction_tabs.transfer") %><% end %>diff --git a/app/views/transactions/_form.html.erb b/app/views/transactions/_form.html.erbindex 4132d3fd..2104f6c9 100644--- a/app/views/transactions/_form.html.erb+++ b/app/views/transactions/_form.html.erb@@ -6,7 +6,7 @@<% end %><section>- <%= render "shared/transaction_type_tabs", active_tab: params[:nature] == "inflow" ? "income" : "expense" %>+ <%= render "shared/transaction_type_tabs", active_tab: params[:nature] == "inflow" ? "income" : "expense", account_id: params[:account_id] %><%= f.hidden_field :nature, value: params[:nature] || "outflow", data: { "transaction-form-target": "natureField" } %><%= f.hidden_field :entryable_type, value: "Transaction" %>