Rewrite categories to be nested below groups
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2022-02-23 14:10:54 +00:00
parent f93888cbbc
commit 510c91205d
2 changed files with 49 additions and 52 deletions

View File

@ -54,17 +54,29 @@ export const useAccountStore = defineStore("budget/account", {
AccountsList(state) {
return [...state.Accounts.values()];
},
CategoriesForMonth: (state) => (year: number, month: number) => {
AllCategoriesForMonth: (state) => (year: number, month: number) => {
const yearMap = state.Months.get(year);
const monthMap = yearMap?.get(month);
console.log("MTH", monthMap)
return [...monthMap?.values() || []].filter(x => x.Group != "Hidden Categories");
return [...monthMap?.values() || []];
},
HiddenCategoriesForMonth: (state) => (year: number, month: number) => {
const yearMap = state.Months.get(year);
const monthMap = yearMap?.get(month);
console.log("MTH", monthMap)
return [...monthMap?.values() || []].filter(x => x.Group == "Hidden Categories");
CategoryGroupsForMonth(state) {
return (year: number, month: number) => {
const categories = this.AllCategoriesForMonth(year, month);
const categoryGroups = [];
let prev = undefined;
for (const category of categories) {
if(category.Group != prev)
categoryGroups.push(category.Group);
prev = category.Group;
}
return categoryGroups;
}
},
CategoriesForMonthAndGroup(state) {
return (year: number, month: number, group : string) => {
const categories = this.AllCategoriesForMonth(year, month);
return categories.filter(x => x.Group == group);
}
},
CurrentAccount(state): Account | undefined {
if (state.CurrentAccountID == null)