always display account name even if the account is hidden

This commit is contained in:
MaysWind
2023-08-21 23:35:21 +08:00
parent e7f9eb6e06
commit 21f5ef469b
2 changed files with 26 additions and 7 deletions
+7 -5
View File
@@ -11,14 +11,15 @@
> >
<template #selection> <template #selection>
<div class="d-flex align-center text-truncate cursor-pointer"> <div class="d-flex align-center text-truncate cursor-pointer">
<span class="text-truncate" v-if="!selectedPrimaryItem && !selectedSecondaryItem">{{ noItemDisplayName }}</span> <span class="text-truncate" v-if="selectionText">{{ selectionText }}</span>
<span class="text-truncate" v-if="showPrimaryName && selectedPrimaryItem">{{ primaryItemDisplayName }}</span> <span class="text-truncate" v-if="!selectionText && !selectedPrimaryItem && !selectedSecondaryItem">{{ noItemDisplayName }}</span>
<v-icon class="disabled" :icon="icons.chevronRight" size="23" v-if="showPrimaryName && selectedPrimaryItem && selectedSecondaryItem" /> <span class="text-truncate" v-if="!selectionText && showPrimaryName && selectedPrimaryItem">{{ primaryItemDisplayName }}</span>
<v-icon class="disabled" :icon="icons.chevronRight" size="23" v-if="!selectionText && showPrimaryName && selectedPrimaryItem && selectedSecondaryItem" />
<ItemIcon class="mr-2" icon-type="account" size="21.5px" <ItemIcon class="mr-2" icon-type="account" size="21.5px"
:icon-id="selectedSecondaryItem ? selectedSecondaryItem[secondaryIconField] : null" :icon-id="selectedSecondaryItem ? selectedSecondaryItem[secondaryIconField] : null"
:color="selectedSecondaryItem ? selectedSecondaryItem[secondaryColorField] : null" :color="selectedSecondaryItem ? selectedSecondaryItem[secondaryColorField] : null"
v-if="selectedSecondaryItem && showSecondaryIcon" /> v-if="!selectionText && selectedSecondaryItem && showSecondaryIcon" />
<span class="text-truncate" v-if="selectedSecondaryItem">{{ secondaryItemDisplayName }}</span> <span class="text-truncate" v-if="!selectionText && selectedSecondaryItem">{{ secondaryItemDisplayName }}</span>
</div> </div>
</template> </template>
@@ -85,6 +86,7 @@ export default {
'disabled', 'disabled',
'readonly', 'readonly',
'label', 'label',
'selectionText',
'showPrimaryName', 'showPrimaryName',
'showSecondaryIcon', 'showSecondaryIcon',
'primaryKeyField', 'primaryKeyField',
@@ -130,7 +130,7 @@
secondary-icon-field="icon" secondary-icon-type="account" secondary-color-field="color" secondary-icon-field="icon" secondary-icon-type="account" secondary-color-field="color"
:readonly="mode === 'view'" :readonly="mode === 'view'"
:disabled="loading || submitting || !allVisibleAccounts.length" :disabled="loading || submitting || !allVisibleAccounts.length"
:show-secondary-icon="true" :selection-text="sourceAccountName"
:label="$t(sourceAccountTitle)" :label="$t(sourceAccountTitle)"
:placeholder="$t(sourceAccountTitle)" :placeholder="$t(sourceAccountTitle)"
:items="categorizedAccounts" :items="categorizedAccounts"
@@ -148,7 +148,7 @@
secondary-icon-field="icon" secondary-icon-type="account" secondary-color-field="color" secondary-icon-field="icon" secondary-icon-type="account" secondary-color-field="color"
:readonly="mode === 'view'" :readonly="mode === 'view'"
:disabled="loading || submitting || !allVisibleAccounts.length" :disabled="loading || submitting || !allVisibleAccounts.length"
:show-secondary-icon="true" :selection-text="destinationAccountName"
:label="$t('Destination Account')" :label="$t('Destination Account')"
:placeholder="$t('Destination Account')" :placeholder="$t('Destination Account')"
:items="categorizedAccounts" :items="categorizedAccounts"
@@ -316,6 +316,9 @@ import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import categoryConstants from '@/consts/category.js'; import categoryConstants from '@/consts/category.js';
import transactionConstants from '@/consts/transaction.js'; import transactionConstants from '@/consts/transaction.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
import {
getNameByKeyValue
} from '@/lib/common.js';
import { import {
getUtcOffsetByUtcOffsetMinutes, getUtcOffsetByUtcOffsetMinutes,
getTimezoneOffsetMinutes, getTimezoneOffsetMinutes,
@@ -475,6 +478,20 @@ export default {
const firstAvailableCategoryId = getFirstAvailableCategoryId(this.allCategories[this.allCategoryTypes.Transfer]); const firstAvailableCategoryId = getFirstAvailableCategoryId(this.allCategories[this.allCategoryTypes.Transfer]);
return firstAvailableCategoryId !== ''; return firstAvailableCategoryId !== '';
}, },
sourceAccountName() {
if (this.transaction.sourceAccountId) {
return getNameByKeyValue(this.allAccounts, this.transaction.sourceAccountId, 'id', 'name');
} else {
return this.$t('None');
}
},
destinationAccountName() {
if (this.transaction.destinationAccountId) {
return getNameByKeyValue(this.allAccounts, this.transaction.destinationAccountId, 'id', 'name');
} else {
return this.$t('None');
}
},
transactionDisplayTimezone() { transactionDisplayTimezone() {
return `UTC${getUtcOffsetByUtcOffsetMinutes(this.transaction.utcOffset)}`; return `UTC${getUtcOffsetByUtcOffsetMinutes(this.transaction.utcOffset)}`;
}, },