mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
* Fix #921 * Fix linter errors * Fix test failure * Remove unused keys * Add back html rendering * Remove .tool-versions from repository * Fix failing test
This commit is contained in:
parent
3d4def59d6
commit
9e1d8a753b
3 changed files with 11 additions and 8 deletions
|
@ -15,7 +15,10 @@ class Account::TransactionsController < ApplicationController
|
||||||
@transaction.update! transaction_params
|
@transaction.update! transaction_params
|
||||||
@transaction.sync_account_later
|
@transaction.sync_account_later
|
||||||
|
|
||||||
redirect_back_or_to account_transaction_url(@transaction.account, @transaction), notice: t(".success")
|
respond_to do |format|
|
||||||
|
format.html { redirect_back_or_to account_transaction_path(@account, @transaction), notice: t(".success") }
|
||||||
|
format.turbo_stream { render turbo_stream: turbo_stream.replace(@transaction) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -39,6 +42,6 @@ class Account::TransactionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def transaction_params
|
def transaction_params
|
||||||
params.require(:transaction).permit(:name, :date, :amount, :currency, :notes, :excluded, :category_id, :merchant_id, tag_ids: [])
|
params.require(:account_transaction).permit(:name, :date, :amount, :currency, :notes, :excluded, :category_id, :merchant_id, tag_ids: [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
<div class="pb-6">
|
<div class="pb-6">
|
||||||
<%= form_with model: @transaction, html: { data: { controller: "auto-submit-form" } } do |f| %>
|
<%= form_with model: [@account, @transaction], url: account_transaction_path, html: { data: { controller: "auto-submit-form" } } do |f| %>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<%= f.text_field :name, label: t(".name_label"), "data-auto-submit-form-target": "auto" %>
|
<%= f.text_field :name, label: t(".name_label"), "data-auto-submit-form-target": "auto" %>
|
||||||
<%= f.date_field :date, label: t(".date_label"), max: Date.today, "data-auto-submit-form-target": "auto" %>
|
<%= f.date_field :date, label: t(".date_label"), max: Date.today, "data-auto-submit-form-target": "auto" %>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
<div class="pb-6 space-y-2">
|
<div class="pb-6 space-y-2">
|
||||||
<%= form_with model: @transaction, html: { data: { controller: "auto-submit-form" } } do |f| %>
|
<%= form_with model: [@account, @transaction], url: account_transaction_path, html: { data: { controller: "auto-submit-form" } } do |f| %>
|
||||||
<%= f.select :tag_ids,
|
<%= f.select :tag_ids,
|
||||||
options_for_select(Current.family.tags.alphabetically.pluck(:name, :id), @transaction.tag_ids),
|
options_for_select(Current.family.tags.alphabetically.pluck(:name, :id), @transaction.tag_ids),
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
<div class="pb-6">
|
<div class="pb-6">
|
||||||
|
|
||||||
<%= form_with model: @transaction, html: { class: "p-3 space-y-3", data: { controller: "auto-submit-form" } } do |f| %>
|
<%= form_with model: [@account, @transaction], url: account_transaction_path, html: { class: "p-3 space-y-3", data: { controller: "auto-submit-form" } } do |f| %>
|
||||||
<div class="flex cursor-pointer items-center gap-2 justify-between">
|
<div class="flex cursor-pointer items-center gap-2 justify-between">
|
||||||
<div class="text-sm space-y-1">
|
<div class="text-sm space-y-1">
|
||||||
<h4 class="text-gray-900"><%= t(".exclude_title") %></h4>
|
<h4 class="text-gray-900"><%= t(".exclude_title") %></h4>
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
|
|
||||||
<div class="relative inline-block select-none">
|
<div class="relative inline-block select-none">
|
||||||
<%= f.check_box :excluded, class: "sr-only peer", "data-auto-submit-form-target": "auto" %>
|
<%= f.check_box :excluded, class: "sr-only peer", "data-auto-submit-form-target": "auto" %>
|
||||||
<label for="transaction_excluded" class="maybe-switch"></label>
|
<label for="account_transaction_excluded" class="maybe-switch"></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= button_to t(".delete"),
|
<%= button_to t(".delete"),
|
||||||
account_transaction_path(@transaction),
|
account_transaction_path(@account, @transaction),
|
||||||
method: :delete,
|
method: :delete,
|
||||||
class: "rounded-lg px-3 py-2 text-red-500 text-sm font-medium border border-alpha-black-200",
|
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" } %>
|
data: { turbo_confirm: true, turbo_frame: "_top" } %>
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Account::TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
test "should update transaction" do
|
test "should update transaction" do
|
||||||
patch account_transaction_url(@transaction.account, @transaction), params: {
|
patch account_transaction_url(@transaction.account, @transaction), params: {
|
||||||
transaction: {
|
account_transaction: {
|
||||||
account_id: @transaction.account_id,
|
account_id: @transaction.account_id,
|
||||||
amount: @transaction.amount,
|
amount: @transaction.amount,
|
||||||
currency: @transaction.currency,
|
currency: @transaction.currency,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue