mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Add customizable menu order for user accounts (#44)
* Add customizable menu order for user accounts Introduces a MenuOrder model and concern to allow users to select their preferred account ordering (by name or balance, ascending or descending). Adds a default_order field to users, updates user preferences UI, and applies the selected order to balance sheet account listings. * Rename MenuOrder to AccountOrder and update user order field Refactors the MenuOrder model to AccountOrder and updates all references accordingly. Replaces the user's default_order field with default_account_order, including migration changes, validations, and form fields. Updates localization and schema to reflect the new naming. * Update balance_sheet.rb * Fix for nil Current.user when rake runs in balance_sheet model --------- Signed-off-by: Aluisio Pereira <oaluiser@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ class User < ApplicationRecord
|
||||
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validate :ensure_valid_profile_image
|
||||
validates :default_period, inclusion: { in: Period::PERIODS.keys }
|
||||
validates :default_account_order, inclusion: { in: AccountOrder::ORDERS.keys }
|
||||
normalizes :email, with: ->(email) { email.strip.downcase }
|
||||
normalizes :unconfirmed_email, with: ->(email) { email&.strip&.downcase }
|
||||
|
||||
@@ -163,6 +164,10 @@ class User < ApplicationRecord
|
||||
!onboarded?
|
||||
end
|
||||
|
||||
def account_order
|
||||
AccountOrder.find(default_account_order) || AccountOrder.default
|
||||
end
|
||||
|
||||
private
|
||||
def ensure_valid_profile_image
|
||||
return unless profile_image.attached?
|
||||
|
||||
Reference in New Issue
Block a user