mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 06:57:35 +08:00
disable the sort button when fewer than two items are present
This commit is contained in:
@@ -124,6 +124,20 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
return shownAccountCount;
|
||||
});
|
||||
|
||||
const maxCategoryAccountCount = computed<number>(() => {
|
||||
let maxCount = 0;
|
||||
|
||||
for (const categorizedAccounts of values(allCategorizedAccountsMap.value)) {
|
||||
const accountCount = categorizedAccounts.accounts.length;
|
||||
|
||||
if (accountCount > maxCount) {
|
||||
maxCount = accountCount;
|
||||
}
|
||||
}
|
||||
|
||||
return maxCount;
|
||||
});
|
||||
|
||||
function loadAccountList(accounts: Account[]): void {
|
||||
allAccounts.value = accounts;
|
||||
allAccountsMap.value = {};
|
||||
@@ -1076,6 +1090,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
allVisiblePlainAccounts,
|
||||
allAvailableAccountsCount,
|
||||
allVisibleAccountsCount,
|
||||
maxCategoryAccountCount,
|
||||
// functions
|
||||
updateAccountListInvalidState,
|
||||
resetAccounts,
|
||||
|
||||
@@ -39,6 +39,7 @@ export function useAccountListPageBase() {
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allAccounts);
|
||||
const allCategorizedAccountsMap = computed<Record<number, CategorizedAccount>>(() => accountsStore.allCategorizedAccountsMap);
|
||||
const allAccountCount = computed<number>(() => accountsStore.allAvailableAccountsCount);
|
||||
const maxCategoryAccountCount = computed<number>(() => accountsStore.maxCategoryAccountCount);
|
||||
|
||||
const netAssets = computed<string>(() => {
|
||||
const netAssets: number | HiddenAmount | NumberWithSuffix = accountsStore.getNetAssets(showAccountBalance.value);
|
||||
@@ -101,6 +102,7 @@ export function useAccountListPageBase() {
|
||||
allAccounts,
|
||||
allCategorizedAccountsMap,
|
||||
allAccountCount,
|
||||
maxCategoryAccountCount,
|
||||
netAssets,
|
||||
totalAssets,
|
||||
totalLiabilities,
|
||||
|
||||
@@ -83,15 +83,15 @@
|
||||
:title="tt('Change Group Display Order')"
|
||||
v-if="allTagGroupsWithDefault.length >= 2"
|
||||
@click="showChangeGroupDisplayOrderDialog"></v-list-item>
|
||||
<v-divider class="my-2" v-if="tags.length > 1"/>
|
||||
<v-divider class="my-2"/>
|
||||
<v-list-item :prepend-icon="mdiSortAlphabeticalAscending"
|
||||
:disabled="!tags || tags.length < 2"
|
||||
:title="tt('Sort by Name (A to Z)')"
|
||||
@click="sortByName(false)"
|
||||
v-if="tags.length > 1"></v-list-item>
|
||||
@click="sortByName(false)"></v-list-item>
|
||||
<v-list-item :prepend-icon="mdiSortAlphabeticalDescending"
|
||||
:disabled="!tags || tags.length < 2"
|
||||
:title="tt('Sort by Name (Z to A)')"
|
||||
@click="sortByName(true)"
|
||||
v-if="tags.length > 1"></v-list-item>
|
||||
@click="sortByName(true)"></v-list-item>
|
||||
<v-divider class="my-2"/>
|
||||
<v-list-item :prepend-icon="mdiEyeOutline"
|
||||
:title="tt('Show Hidden Transaction Tags')"
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||
<f7-actions-group>
|
||||
<f7-actions-button @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button :class="{ 'disabled': maxCategoryAccountCount < 2 }" @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Accounts') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Accounts') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
@@ -252,6 +252,7 @@ const {
|
||||
customAccountCategoryOrder,
|
||||
allCategorizedAccountsMap,
|
||||
allAccountCount,
|
||||
maxCategoryAccountCount,
|
||||
netAssets,
|
||||
totalAssets,
|
||||
totalLiabilities,
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||
<f7-actions-group>
|
||||
<f7-actions-button @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button :class="{ 'disabled': !categories || categories.length < 2 }" @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Transaction Categories') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Transaction Categories') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
|
||||
@@ -194,10 +194,10 @@
|
||||
<f7-actions-group v-if="allTagGroupsWithDefault.length >= 2">
|
||||
<f7-actions-button @click="changeTagGroupDisplayOrder">{{ tt('Change Group Display Order') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
<f7-actions-group v-if="tags.length > 1">
|
||||
<f7-actions-button @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button @click="sortByName(false)">{{ tt('Sort by Name (A to Z)') }}</f7-actions-button>
|
||||
<f7-actions-button @click="sortByName(true)">{{ tt('Sort by Name (Z to A)') }}</f7-actions-button>
|
||||
<f7-actions-group>
|
||||
<f7-actions-button :class="{ 'disabled': !tags || tags.length < 2 }" @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button :class="{ 'disabled': !tags || tags.length < 2 }" @click="sortByName(false)">{{ tt('Sort by Name (A to Z)') }}</f7-actions-button>
|
||||
<f7-actions-button :class="{ 'disabled': !tags || tags.length < 2 }" @click="sortByName(true)">{{ tt('Sort by Name (Z to A)') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Transaction Tags') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Transaction Tags') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||
<f7-actions-group>
|
||||
<f7-actions-button @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button :class="{ 'disabled': !templates || templates.length < 2 }" @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Transaction Templates') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Transaction Templates') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
|
||||
Reference in New Issue
Block a user