Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Added ability to bulk-edit transaction names for multiple selected transactions (#1553)

maverickee352dada4e5
diff --git a/app/controllers/transactions/bulk_updates_controller.rb b/app/controllers/transactions/bulk_updates_controller.rb
index 82d4c6ddfd..133452f219 100644
--- a/app/controllers/transactions/bulk_updates_controller.rb
+++ b/app/controllers/transactions/bulk_updates_controller.rb
@@ -16,7 +16,7 @@ class Transactions::BulkUpdatesController < ApplicationController
private
def bulk_update_params
params.require(:bulk_update)
- .permit(:date, :notes, :category_id, :merchant_id, entry_ids: [], tag_ids: [])
+ .permit(:date, :notes, :name, :category_id, :merchant_id, entry_ids: [], tag_ids: [])
end
# Check if tag_ids was explicitly provided in the request.
diff --git a/app/models/entry.rb b/app/models/entry.rb
index 48b216f36e..042ea6957e 100644
--- a/app/models/entry.rb
+++ b/app/models/entry.rb
@@ -440,6 +440,7 @@ class Entry < ApplicationRecord
bulk_attributes = {
date: bulk_update_params[:date],
notes: bulk_update_params[:notes],
+ name: bulk_update_params[:name],
entryable_attributes: {
category_id: bulk_update_params[:category_id],
merchant_id: bulk_update_params[:merchant_id]
diff --git a/app/views/transactions/bulk_updates/new.html.erb b/app/views/transactions/bulk_updates/new.html.erb
index 0aee4d8907..7affac23e6 100644
--- a/app/views/transactions/bulk_updates/new.html.erb
+++ b/app/views/transactions/bulk_updates/new.html.erb
@@ -10,6 +10,7 @@
<%= render DS::Disclosure.new(title: "Transactions", open: true) do %>
<div class="space-y-2">
+ <%= form.text_field :name, label: t("transactions.bulk_updates.new.name_label"), placeholder: t("transactions.bulk_updates.new.name_placeholder") %>
<%= form.collection_select :category_id, Current.family.categories.alphabetically, :id, :name, { prompt: "Select a category", label: "Category", class: "text-subdued" } %>
<%= form.collection_select :merchant_id, Current.family.available_merchants_for(Current.user).alphabetically, :id, :name, { prompt: "Select a merchant", label: "Merchant", class: "text-subdued" } %>
<%= form.select :tag_ids, Current.family.tags.alphabetically.pluck(:name, :id), { include_blank: "None", multiple: true, label: "Tags", include_hidden: false } %>
diff --git a/config/locales/views/transactions/en.yml b/config/locales/views/transactions/en.yml
index cc57756451..8336576eea 100644
--- a/config/locales/views/transactions/en.yml
+++ b/config/locales/views/transactions/en.yml
@@ -1,6 +1,10 @@
---
en:
transactions:
+ bulk_updates:
+ new:
+ name_label: Name
+ name_placeholder: Enter a name that will be applied to selected transactions
unknown_name: Unknown transaction
selection_bar:
duplicate: Duplicate