Rewrite categories to be nested below groups
This commit is contained in:
parent
f93888cbbc
commit
510c91205d
@ -15,13 +15,15 @@ const budgetsStore = useBudgetsStore();
|
|||||||
const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID);
|
const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID);
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const categoriesForMonth = accountStore.CategoriesForMonth;
|
const categoriesForMonth = accountStore.CategoriesForMonthAndGroup;
|
||||||
const Categories = computed(() => {
|
|
||||||
return [...categoriesForMonth(selected.value.Year, selected.value.Month)];
|
function GetCategories(group : string) {
|
||||||
});
|
return [...categoriesForMonth(selected.value.Year, selected.value.Month, group)];
|
||||||
const hiddenCategoriesForMonth = accountStore.HiddenCategoriesForMonth;
|
};
|
||||||
const HiddenCategories = computed(() => {
|
|
||||||
return [...hiddenCategoriesForMonth(selected.value.Year, selected.value.Month)];
|
const groupsForMonth = accountStore.CategoryGroupsForMonth;
|
||||||
|
const GroupsForMonth = computed(() => {
|
||||||
|
return [...groupsForMonth(selected.value.Year, selected.value.Month)];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +69,6 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<table class="container col-lg-12" id="content">
|
<table class="container col-lg-12" id="content">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Group</th>
|
|
||||||
<th>Category</th>
|
<th>Category</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@ -76,26 +77,9 @@ onMounted(() => {
|
|||||||
<th>Activity</th>
|
<th>Activity</th>
|
||||||
<th>Available</th>
|
<th>Available</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="category in Categories">
|
<tbody v-for="group in GroupsForMonth">
|
||||||
<td>{{ category.Group }}</td>
|
<p class="text-lg font-bold">{{ group }}</p>
|
||||||
<td>{{ category.Name }}</td>
|
<tr v-for="category in GetCategories(group)">
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td class="text-right">
|
|
||||||
<Currency :value="category.AvailableLastMonth" />
|
|
||||||
</td>
|
|
||||||
<td class="text-right">
|
|
||||||
<Currency :value="category.Assigned" />
|
|
||||||
</td>
|
|
||||||
<td class="text-right">
|
|
||||||
<Currency :value="category.Activity" />
|
|
||||||
</td>
|
|
||||||
<td class="text-right">
|
|
||||||
<Currency :value="category.Available" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-for="category in HiddenCategories">
|
|
||||||
<td>{{ category.Group }}</td>
|
|
||||||
<td>{{ category.Name }}</td>
|
<td>{{ category.Name }}</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -112,5 +96,6 @@ onMounted(() => {
|
|||||||
<Currency :value="category.Available" />
|
<Currency :value="category.Available" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
|
@ -54,17 +54,29 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
AccountsList(state) {
|
AccountsList(state) {
|
||||||
return [...state.Accounts.values()];
|
return [...state.Accounts.values()];
|
||||||
},
|
},
|
||||||
CategoriesForMonth: (state) => (year: number, month: number) => {
|
AllCategoriesForMonth: (state) => (year: number, month: number) => {
|
||||||
const yearMap = state.Months.get(year);
|
const yearMap = state.Months.get(year);
|
||||||
const monthMap = yearMap?.get(month);
|
const monthMap = yearMap?.get(month);
|
||||||
console.log("MTH", monthMap)
|
return [...monthMap?.values() || []];
|
||||||
return [...monthMap?.values() || []].filter(x => x.Group != "Hidden Categories");
|
|
||||||
},
|
},
|
||||||
HiddenCategoriesForMonth: (state) => (year: number, month: number) => {
|
CategoryGroupsForMonth(state) {
|
||||||
const yearMap = state.Months.get(year);
|
return (year: number, month: number) => {
|
||||||
const monthMap = yearMap?.get(month);
|
const categories = this.AllCategoriesForMonth(year, month);
|
||||||
console.log("MTH", monthMap)
|
const categoryGroups = [];
|
||||||
return [...monthMap?.values() || []].filter(x => x.Group == "Hidden Categories");
|
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 {
|
CurrentAccount(state): Account | undefined {
|
||||||
if (state.CurrentAccountID == null)
|
if (state.CurrentAccountID == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user