The personal finance app for everyone (by everyone)
Ruby
chore: drop dead transactions-section preferences (#3021)
Guillem Arias Fauste7f0a6fb6dc6e
diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rbindex 0bbad7abee..d462d98bbc 100644--- a/app/controllers/transactions_controller.rb+++ b/app/controllers/transactions_controller.rb@@ -394,13 +394,6 @@ class TransactionsController < ApplicationControllerendend- def update_preferences- Current.user.update_transactions_preferences(preferences_params)- head :ok- rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved- head :unprocessable_entity- end-def exchange_rateaccount = Current.family.accounts.find(params[:account_id])currency_from = params[:currency]@@ -584,10 +577,6 @@ class TransactionsController < ApplicationControllerCurrent.session.prev_transaction_page_paramsend- def preferences_params- params.require(:preferences).permit(collapsed_sections: {})- end-# Helper methods for convert_to_tradedef resolve_security_for_conversiondiff --git a/app/javascript/controllers/transactions_section_controller.js b/app/javascript/controllers/transactions_section_controller.jsdeleted file mode 100644index 67915a5498..0000000000--- a/app/javascript/controllers/transactions_section_controller.js+++ /dev/null@@ -1,96 +0,0 @@-import { Controller } from "@hotwired/stimulus";--export default class extends Controller {- static targets = ["content", "chevron", "button"];- static values = {- sectionKey: String,- collapsed: Boolean,- };-- connect() {- if (this.collapsedValue) {- this.collapse(false);- }- }-- toggle(event) {- event.preventDefault();- if (this.collapsedValue) {- this.expand();- } else {- this.collapse();- }- }-- handleToggleKeydown(event) {- // Handle Enter and Space keys for keyboard accessibility- if (event.key === "Enter" || event.key === " ") {- event.preventDefault();- event.stopPropagation();- this.toggle(event);- }- }-- collapse(persist = true) {- this.contentTarget.classList.add("hidden");- this.chevronTarget.classList.add("-rotate-90");- this.collapsedValue = true;- if (this.hasButtonTarget) {- this.buttonTarget.setAttribute("aria-expanded", "false");- }- if (persist) {- this.savePreference(true);- }- }-- expand() {- this.contentTarget.classList.remove("hidden");- this.chevronTarget.classList.remove("-rotate-90");- this.collapsedValue = false;- if (this.hasButtonTarget) {- this.buttonTarget.setAttribute("aria-expanded", "true");- }- this.savePreference(false);- }-- async savePreference(collapsed) {- const preferences = {- collapsed_sections: {- [this.sectionKeyValue]: collapsed,- },- };-- const csrfToken = document.querySelector('meta[name="csrf-token"]');- if (!csrfToken) {- console.error(- "[Transactions Section] CSRF token not found. Cannot save preferences.",- );- return;- }-- try {- const response = await fetch("/transactions/update_preferences", {- method: "PATCH",- headers: {- "Content-Type": "application/json",- "X-CSRF-Token": csrfToken.content,- },- body: JSON.stringify({ preferences }),- });-- if (!response.ok) {- const errorData = await response.json().catch(() => ({}));- console.error(- "[Transactions Section] Failed to save preferences:",- response.status,- errorData,- );- }- } catch (error) {- console.error(- "[Transactions Section] Network error saving preferences:",- error,- );- }- }-}diff --git a/app/models/user.rb b/app/models/user.rbindex efc435b3bf..e068a3a4c4 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -385,10 +385,6 @@ class User < ApplicationRecordend# Transactions preferences management- def transactions_section_collapsed?(section_key)- preferences&.dig("transactions_collapsed_sections", section_key) == true- end-def show_split_grouped?preferences&.dig("show_split_grouped") != falseend@@ -405,24 +401,6 @@ class User < ApplicationRecordpreferences&.dig("preview_features_enabled") == trueend- def update_transactions_preferences(prefs)- transaction do- lock!-- updated_prefs = (preferences || {}).deep_dup- prefs.each do |key, value|- if value.is_a?(Hash)- updated_prefs["transactions_#{key}"] ||= {}- updated_prefs["transactions_#{key}"] = updated_prefs["transactions_#{key}"].merge(value)- else- updated_prefs["transactions_#{key}"] = value- end- end-- update!(preferences: updated_prefs)- end- end-privatedef apply_ui_layout_defaultsself.ui_layout = (ui_layout.presence || self.class.default_ui_layout)diff --git a/config/routes.rb b/config/routes.rbindex f6ffcd6ba5..8f3e791165 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -481,7 +481,6 @@ Rails.application.routes.draw docollection dodelete :clear_filter- patch :update_preferencesendmember do