support changing account category order
This commit is contained in:
@@ -2,6 +2,7 @@ import { ref, computed, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import type { TypeAndDisplayName } from '@/core/base.ts';
|
||||
@@ -25,13 +26,16 @@ export interface DayAndDisplayName {
|
||||
export function useAccountEditPageBase() {
|
||||
const { tt, getAllAccountCategories, getAllAccountTypes, getMonthdayShortName } = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const defaultAccountCategory = AccountCategory.values(settingsStore.appSettings.accountCategoryOrders)[0] ?? AccountCategory.Default;
|
||||
|
||||
const editAccountId = ref<string | null>(null);
|
||||
const clientSessionId = ref<string>('');
|
||||
const loading = ref<boolean>(false);
|
||||
const submitting = ref<boolean>(false);
|
||||
const account = ref<Account>(Account.createNewAccount(userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount()));
|
||||
const account = ref<Account>(Account.createNewAccount(defaultAccountCategory, userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount()));
|
||||
const subAccounts = ref<Account[]>([]);
|
||||
|
||||
const title = computed<string>(() => {
|
||||
@@ -72,7 +76,8 @@ export function useAccountEditPageBase() {
|
||||
|
||||
const inputIsEmpty = computed<boolean>(() => !!inputEmptyProblemMessage.value);
|
||||
|
||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories());
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories(customAccountCategoryOrder.value));
|
||||
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
||||
|
||||
const allAvailableMonthDays = computed<DayAndDisplayName[]>(() => {
|
||||
@@ -181,6 +186,8 @@ export function useAccountEditPageBase() {
|
||||
});
|
||||
|
||||
return {
|
||||
// constants
|
||||
defaultAccountCategory,
|
||||
// states
|
||||
editAccountId,
|
||||
clientSessionId,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useAccountsStore } from '@/stores/account.ts';
|
||||
|
||||
import type { HiddenAmount, NumberWithSuffix } from '@/core/numeral.ts';
|
||||
import type { WeekDayValue } from '@/core/datetime.ts';
|
||||
import { type AccountCategory, AccountType } from '@/core/account.ts';
|
||||
import { AccountCategory, AccountType } from '@/core/account.ts';
|
||||
import type { Account, CategorizedAccount } from '@/models/account.ts';
|
||||
|
||||
import { isObject, isNumber, isString } from '@/lib/common.ts';
|
||||
@@ -29,6 +29,9 @@ export function useAccountListPageBase() {
|
||||
set: (value) => settingsStore.setShowAccountBalance(value)
|
||||
});
|
||||
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const defaultAccountCategory = computed<AccountCategory>(() => AccountCategory.values(customAccountCategoryOrder.value)[0] ?? AccountCategory.Default);
|
||||
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
const fiscalYearStart = computed<number>(() => userStore.currentUserFiscalYearStart);
|
||||
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
||||
@@ -90,6 +93,8 @@ export function useAccountListPageBase() {
|
||||
displayOrderModified,
|
||||
// computed states
|
||||
showAccountBalance,
|
||||
customAccountCategoryOrder,
|
||||
defaultAccountCategory,
|
||||
firstDayOfWeek,
|
||||
fiscalYearStart,
|
||||
defaultCurrency,
|
||||
|
||||
@@ -19,9 +19,10 @@ export function useMoveAllTransactionsPageBase() {
|
||||
const toAccountName = ref<string>('');
|
||||
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
|
||||
const displayToAccountName = computed<string>(() => {
|
||||
if (!toAccountId.value) {
|
||||
|
||||
Reference in New Issue
Block a user