mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Consolidate and simplify account pages (#2462)
* Remove ScrollFocusable * Consolidate and simplify account pages * Lint fixes * Fix tab param initialization * Remove stale files * Remove stale route, make accountable routes clearer
This commit is contained in:
parent
3eea5a9891
commit
8c97c9d31a
41 changed files with 252 additions and 269 deletions
|
@ -1,5 +1,5 @@
|
|||
class AccountsController < ApplicationController
|
||||
before_action :set_account, only: %i[sync chart sparkline toggle_active]
|
||||
before_action :set_account, only: %i[sync sparkline toggle_active show destroy]
|
||||
include Periodable
|
||||
|
||||
def index
|
||||
|
@ -9,6 +9,15 @@ class AccountsController < ApplicationController
|
|||
render layout: "settings"
|
||||
end
|
||||
|
||||
def show
|
||||
@chart_view = params[:chart_view] || "balance"
|
||||
@tab = params[:tab]
|
||||
@q = params.fetch(:q, {}).permit(:search)
|
||||
entries = @account.entries.search(@q).reverse_chronological
|
||||
|
||||
@pagy, @entries = pagy(entries, limit: params[:per_page] || "10")
|
||||
end
|
||||
|
||||
def sync
|
||||
unless @account.syncing?
|
||||
@account.sync_later
|
||||
|
@ -17,11 +26,6 @@ class AccountsController < ApplicationController
|
|||
redirect_to account_path(@account)
|
||||
end
|
||||
|
||||
def chart
|
||||
@chart_view = params[:chart_view] || "balance"
|
||||
render layout: "application"
|
||||
end
|
||||
|
||||
def sparkline
|
||||
etag_key = @account.family.build_cache_key("#{@account.id}_sparkline", invalidate_on_data_updates: true)
|
||||
|
||||
|
@ -42,6 +46,15 @@ class AccountsController < ApplicationController
|
|||
redirect_to accounts_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @account.linked?
|
||||
redirect_to account_path(@account), alert: "Cannot delete a linked account"
|
||||
else
|
||||
@account.destroy_later
|
||||
redirect_to accounts_path, notice: "Account scheduled for deletion"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def family
|
||||
Current.family
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue