Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accounts by_group should omit empty groups, render empty UI #558

Closed
zachgoll opened this issue Mar 20, 2024 · 3 comments
Closed

Accounts by_group should omit empty groups, render empty UI #558

zachgoll opened this issue Mar 20, 2024 · 3 comments

Comments

@zachgoll
Copy link
Collaborator

Currently, if user has not created any accounts, they see this dashboard screen:

CleanShot 2024-03-20 at 13 04 41

Problems to address

Empty State

If there are no accounts, dashboard should probably show something like what we have for accounts page:

CleanShot 2024-03-20 at 13 06 18

Partial Empty State

If the user has a few accounts, but doesn't have an account for each Accountable type, we should show a "No accounts" message:

CleanShot 2024-03-20 at 13 07 53

And finally, if the entire group (i.e. "liabilities") has no accounts, we should probably show a "No [group] yet" message:

CleanShot 2024-03-20 at 13 09 52

@zachgoll
Copy link
Collaborator Author

Here's where everything is being grouped:

def self.by_group(period = Period.all)
grouped_accounts = { assets: ValueGroup.new("Assets"), liabilities: ValueGroup.new("Liabilities") }
Accountable.by_classification.each do |classification, types|
types.each do |type|
group = grouped_accounts[classification.to_sym].add_child_node(type)
Accountable.from_type(type).includes(:account).each do |accountable|
account = accountable.account
value_node = group.add_value_node(account)
value_node.attach_series(account.series(period))
end
end
end
grouped_accounts
end

And to fix this, we could probably add an empty? method on the ValueGroup class:

def value_nodes
return [ self ] unless value.nil?
children.flat_map { |child| child.value_nodes }
end

Something like:

def empty?
  value_nodes.empty?
end

@claudey
Copy link
Contributor

claudey commented May 3, 2024

@zachgoll I think #707 fixes the first part of this issue, the Empty State problem to address.

@zachgoll
Copy link
Collaborator Author

zachgoll commented May 3, 2024

@claudey you are correct, I'll go ahead and close this issue out.

This was for a prior version of the UI, so I think #707 actually addresses all of it!

@zachgoll zachgoll closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants