mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Add tags selection and notes input to new transaction form (#2008)
* feat: Add tags selection and notes input to new transaction form * feat: Add tag selection to transactions bulk update form
This commit is contained in:
parent
8648f11413
commit
48c8499b70
6 changed files with 30 additions and 2 deletions
|
@ -27,7 +27,7 @@ class Account::TransactionsController < ApplicationController
|
|||
end
|
||||
|
||||
def bulk_update_params
|
||||
params.require(:bulk_update).permit(:date, :notes, :category_id, :merchant_id, entry_ids: [])
|
||||
params.require(:bulk_update).permit(:date, :notes, :category_id, :merchant_id, entry_ids: [], tag_ids: [])
|
||||
end
|
||||
|
||||
def search_params
|
||||
|
|
|
@ -67,7 +67,8 @@ class Account::Entry < ApplicationRecord
|
|||
notes: bulk_update_params[:notes],
|
||||
entryable_attributes: {
|
||||
category_id: bulk_update_params[:category_id],
|
||||
merchant_id: bulk_update_params[:merchant_id]
|
||||
merchant_id: bulk_update_params[:merchant_id],
|
||||
tag_ids: bulk_update_params[:tag_ids]
|
||||
}.compact_blank
|
||||
}.compact_blank
|
||||
|
||||
|
|
|
@ -31,6 +31,24 @@
|
|||
<%= f.date_field :date, label: t(".date"), required: true, min: Account::Entry.min_supported_date, max: Date.current, value: Date.current %>
|
||||
</section>
|
||||
|
||||
<%= disclosure t(".details"), default_open: false do %>
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
<%= ef.select :tag_ids,
|
||||
Current.family.tags.alphabetically.pluck(:name, :id),
|
||||
{
|
||||
include_blank: t(".none"),
|
||||
multiple: true,
|
||||
label: t(".tags_label"),
|
||||
container_class: "h-40"
|
||||
}%>
|
||||
<% end %>
|
||||
<%= f.text_area :notes,
|
||||
label: t(".note_label"),
|
||||
placeholder: t(".note_placeholder"),
|
||||
rows: 5,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
<% end %>
|
||||
|
||||
<section>
|
||||
<%= f.submit t(".submit") %>
|
||||
</section>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
<div class="space-y-2">
|
||||
<%= form.collection_select :category_id, Current.family.categories.alphabetically, :id, :name, { prompt: t(".category_placeholder"), label: t(".category_label"), class: "text-subdued" } %>
|
||||
<%= form.collection_select :merchant_id, Current.family.merchants.alphabetically, :id, :name, { prompt: t(".merchant_placeholder"), label: t(".merchant_label"), class: "text-subdued" } %>
|
||||
<%= form.select :tag_ids, Current.family.tags.alphabetically.pluck(:name, :id), { include_blank: t(".none"), multiple: true, label: t(".tag_label"), container_class: "h-40" } %>
|
||||
<%= form.text_area :notes, label: t(".note_label"), placeholder: t(".note_placeholder"), rows: 5 %>
|
||||
</div>
|
||||
</details>
|
||||
|
|
|
@ -12,10 +12,12 @@ en:
|
|||
details: Details
|
||||
merchant_label: Merchant
|
||||
merchant_placeholder: Select a merchant
|
||||
none: (none)
|
||||
note_label: Notes
|
||||
note_placeholder: Enter a note that will be applied to selected transactions
|
||||
overview: Overview
|
||||
save: Save
|
||||
tag_label: Tags
|
||||
bulk_update:
|
||||
success: "%{count} transactions updated"
|
||||
form:
|
||||
|
@ -29,7 +31,11 @@ en:
|
|||
description_placeholder: Describe transaction
|
||||
expense: Expense
|
||||
income: Income
|
||||
none: (none)
|
||||
note_label: Notes
|
||||
note_placeholder: Enter a note
|
||||
submit: Add transaction
|
||||
tags_label: Tags
|
||||
transfer: Transfer
|
||||
new:
|
||||
new_transaction: New transaction
|
||||
|
|
|
@ -99,6 +99,7 @@ class Account::TransactionsControllerTest < ActionDispatch::IntegrationTest
|
|||
date: 1.day.ago.to_date,
|
||||
category_id: Category.second.id,
|
||||
merchant_id: Merchant.second.id,
|
||||
tag_ids: [ Tag.first.id, Tag.second.id ],
|
||||
notes: "Updated note"
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +113,7 @@ class Account::TransactionsControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_equal Category.second, transaction.account_transaction.category
|
||||
assert_equal Merchant.second, transaction.account_transaction.merchant
|
||||
assert_equal "Updated note", transaction.notes
|
||||
assert_equal [ Tag.first.id, Tag.second.id ], transaction.entryable.tag_ids.sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue